UNPKG

is.modern

Version:

MayBe on Return constructor and useful functions

35 lines (34 loc) 1.42 kB
(() => { "use strict"; const is = Object.assign((t) => { try { return t.constructor; } catch (e) { return t; } }, { "array": (t) => is(t) === Array, "blank": (t) => t === "", "boolean": (t) => is(t) === Boolean, "defined": (t) => is(t) !== undefined, "function": (t) => is(t) === Function, "generator": (t) => is(t) === is(function* (){}), "iterable": (t) => is(t) === is(function* (){}()), "held": (t) => (p) => t instanceof p, "nan": (t) => is.number(t) && isNaN(t), "null": (t) => is(t) === null, "number": (t) => is(t) === Number, "object": (t) => is(t) === Object, "pure": (t) => is.object(t) || is.array(t), "self": (t) => is.valid(t) && is(t).prototype === t, "string": (t) => is(t) === String, "symbol": (t) => is(t) === Symbol, "there": (t) => Object.keys(t).length !== 0, "valid": (t) => !is.nan(t) && !is.blank(t) && is(t) !== t, "client": this.constructor.name === "Window", "server": this.constructor.name === "Object", "worker": Object.getPrototypeOf(this.constructor.prototype) !== null && Object.getPrototypeOf(this.constructor.prototype).constructor.name === "WorkerGlobalScope" }); is.server && (module.exports = is); is.server || Object.assign(this, {is}); })();