@gvray/eskit
Version:
A rich and colorful toolkit about typescript and javascript.
31 lines • 910 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Checks if a value is null or undefined.
* 检查值是否为null或undefined。
*
* @param value - The value to check / 要检查的值
* @returns True if the value is null or undefined / 如果值是null或undefined则返回true
*
* @example
* ```typescript
* isNil(null) // true
* isNil(undefined) // true
* isNil(void 0) // true (void 0 is undefined)
* isNil('') // false
* isNil(0) // false
* isNil(false) // false
* isNil([]) // false
* isNil({}) // false
* isNil(NaN) // false
*
* // Useful for optional chaining checks
* const obj = { a: null, b: undefined, c: 'value' }
* Object.keys(obj).filter(key => !isNil(obj[key])) // ['c']
* ```
*
* @since 1.0.0
*/
var isNil = function (value) { return value === null || value === undefined; };
exports.default = isNil;
//# sourceMappingURL=isNil.js.map