UNPKG

@xylabs/exists

Version:

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

8 lines (7 loc) 672 B
{ "version": 3, "sources": ["../../src/index.ts"], "sourcesContent": ["/**\n * Used to type narrow an object which is possibly null or undefined. Works well\n * with functional Array methods. For example:\n * @example\n * const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []\n * @param x The object which is potentially undefined or null\n * @returns False if the object is null/undefined, true otherwise\n */\nexport const exists = <T>(x?: T | null): x is NonNullable<T> => {\n return x === undefined || x === null ? false : true\n}\n"], "mappings": ";AAQO,IAAM,SAAS,CAAI,MAAsC;AAC9D,SAAO,MAAM,UAAa,MAAM,OAAO,QAAQ;AACjD;", "names": [] }