@xylabs/exists
v5.0.65
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/exists
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/exists
Functions
functions
exists
function exists<T>(x?): 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
T
T
Parameters
x?
The object which is potentially undefined or null
null | T
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
