@pivanov/utils
Version:
A focused collection of TypeScript utilities for modern web development
8 lines (7 loc) • 2 kB
JavaScript
/*!
* @pivanov/utils v1.0.0
* (c) 2024-present Pavel Ivanov
* Released under the MIT License.
* https://github.com/pivanov/utils
*/
var{defineProperty:G,getOwnPropertyNames:I,getOwnPropertyDescriptor:J}=Object,K=Object.prototype.hasOwnProperty;var H=new WeakMap,L=(q)=>{var B=H.get(q),D;if(B)return B;if(B=G({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function")I(q).map((F)=>!K.call(B,F)&&G(B,F,{get:()=>q[F],enumerable:!(D=J(q,F))||D.enumerable}));return H.set(q,B),B};var N=(q,B)=>{for(var D in B)G(q,D,{get:B[D],enumerable:!0,configurable:!0,set:(F)=>B[D]=()=>F})};var d={};N(d,{isUndefined:()=>W,isString:()=>R,isSet:()=>C,isRegExp:()=>j,isRecord:()=>V,isPromise:()=>z,isPrimitive:()=>P,isObject:()=>U,isNumber:()=>Q,isNull:()=>X,isNil:()=>Y,isMap:()=>A,isFunction:()=>T,isError:()=>x,isEmpty:()=>b,isDefined:()=>Z,isDate:()=>$,isBoolean:()=>O,isArray:()=>_});module.exports=L(d);var O=(q)=>{return typeof q==="boolean"},Q=(q)=>{return typeof q==="number"},R=(q)=>{return typeof q==="string"},T=(q)=>{return typeof q==="function"},U=(q)=>{if(q===null||typeof q!=="object")return!1;let B=Object.getPrototypeOf(q);return B===Object.prototype||B===null},V=(q)=>{return typeof q==="object"&&q!==null},W=(q)=>{return q===void 0},X=(q)=>{return q===null},Y=(q)=>{return q===null||q===void 0},Z=(q)=>{return q!==void 0},_=(q)=>{return Array.isArray(q)},$=(q)=>{return q instanceof Date},j=(q)=>{return q instanceof RegExp},x=(q)=>{return q instanceof Error},z=(q)=>{return q!==null&&(typeof q==="object"||typeof q==="function")&&typeof q.then==="function"},A=(q)=>{return q instanceof Map},C=(q)=>{return q instanceof Set},P=(q)=>{if(q===null||q===void 0)return!0;let B=typeof q;return B==="string"||B==="number"||B==="boolean"||B==="bigint"||B==="symbol"},b=(q)=>{if(q===null||q===void 0)return!0;if(typeof q==="string"||Array.isArray(q))return q.length===0;if(q instanceof Map||q instanceof Set)return q.size===0;if(typeof q==="object")return Object.keys(q).length===0;return!1};