foxts
Version:
Opinionated collection of common TypeScript utils by @SukkaW
2 lines (1 loc) • 997 B
JavaScript
function e(e){switch(e){case null:return e=>null!==e;case void 0:return e=>void 0!==e;case!1:return e=>!1!==e;case"nullish":return e=>null!=e;case"falsy":return e=>!!e;default:s(e,"argument")}}function r(e){switch(e){case null:return e=>null===e;case void 0:return e=>void 0===e;case!1:return e=>!1===e;case"nullish":return e=>null==e;case"falsy":return e=>!e;case"truthy":return e=>!!e;default:s(e,"argument")}}Object.defineProperty(exports,"__esModule",{value:!0});const n=r("truthy"),t=r("falsy"),u=e(null),l=e("nullish");function s(e,r="value"){throw TypeError(`Unexpected ${r}: ${e} as ${JSON.stringify(typeof e)}, should be "never"`)}exports.invariant=function(e,r='[foxts/invariant] "value" is null or undefined'){if(null==e)throw TypeError(r)},exports.is=r,exports.isFalsy=t,exports.isNonNull=u,exports.isNonNullish=l,exports.isTruthy=n,exports.never=s,exports.not=e,exports.nullthrow=function(e,r='[foxts/invariant] "value" is null or undefined'){if(null==e)throw TypeError(r);return e};