UNPKG

@eljs/utils

Version:
115 lines (113 loc) 3.24 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/type/index.ts var index_exports = {}; __export(index_exports, { isArray: () => isArray, isAsyncFunction: () => isAsyncFunction, isBoolean: () => isBoolean, isESModule: () => isESModule, isFunction: () => isFunction, isGeneratorFunction: () => isGeneratorFunction, isNull: () => isNull, isObject: () => isObject, isPlainObject: () => isPlainObject, isPromise: () => isPromise, isString: () => isString, isUndefined: () => isUndefined }); module.exports = __toCommonJS(index_exports); function isTypeOf(target, type) { if (!type) { return false; } try { type = type.toLocaleLowerCase(); if (target === void 0) { return type === "undefined"; } if (target === null) { return type === "null"; } return Object.prototype.toString.call(target).toLocaleLowerCase() === `[object ${type}]`; } catch (err) { return false; } } function isUndefined(target) { return isTypeOf(target, "undefined"); } function isNull(target) { return isTypeOf(target, "null"); } function isString(target) { return isTypeOf(target, "string"); } function isObject(target) { return isTypeOf(target, "Object"); } function isArray(target) { return isTypeOf(target, "array"); } function isFunction(target) { return isTypeOf(target, "function"); } function isBoolean(target) { return isTypeOf(target, "boolean"); } function isPlainObject(target) { if (!isObject(target)) { return false; } const proto = Object.getPrototypeOf(target); if (proto === null) { return true; } let baseProto = proto; while (Object.getPrototypeOf(baseProto) !== null) { baseProto = Object.getPrototypeOf(baseProto); } return baseProto === proto; } function isPromise(target) { return target && typeof target.then === "function"; } function isGeneratorFunction(target) { return typeof target === "function" && target.constructor.name === "GeneratorFunction"; } function isAsyncFunction(target) { return typeof target === "function" && target.constructor.name === "AsyncFunction"; } function isESModule(module2) { return !!module2 && typeof module2 === "object" && module2.__esModule === true && "default" in module2; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { isArray, isAsyncFunction, isBoolean, isESModule, isFunction, isGeneratorFunction, isNull, isObject, isPlainObject, isPromise, isString, isUndefined });