froebel
Version:
TypeScript utility library
25 lines (19 loc) • 668 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nullish = exports.notNullish = void 0;
/** Checks if `value` is nullish. Literal types are narrowed accordingly. */
const nullish = value => value === undefined || value === null;
exports.nullish = nullish;
/**
* Checks if `value` is not nullish. Literal types are narrowed accordingly.
*
* @example
* ```
* const nums = (...values: (number | undefined)[]): number[] => values.filter(notNullish)
* ```
*/
const notNullish = value => value !== null && value !== undefined;
exports.notNullish = notNullish;
module.exports = Object.assign(exports.default || {}, exports);