@xylabs/exists
v5.0.87
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Downloads
10,686
Readme
@xylabs/exists
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/exists
Functions
| Function | Description | | ------ | ------ | | exists | Used to type narrow an object which is possibly null or undefined. Works well with functional Array methods. For example: |
functions
exists
function exists<T>(x?: T | null): x is NonNullable<T>;Used to type narrow an object which is possibly null or undefined. Works well with functional Array methods. For example:
Type Parameters
| Type Parameter |
| ------ |
| T |
Parameters
| Parameter | Type | Description |
| ------ | ------ | ------ |
| x? | T | null | The object which is potentially undefined or null |
Returns
x is NonNullable<T>
False if the object is null/undefined, true otherwise
Example
const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []Part of sdk-js
Maintainers
License
See the LICENSE file for license details
