es-toolkit-clean
Version:
A lightweight, TypeScript-first library for cleaning JavaScript objects by removing undefined values, empty strings, empty arrays, functions, and other unwanted properties. Built on es-toolkit for superior performance.
3 lines (2 loc) • 1.97 kB
JavaScript
;var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var a=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},d=(n,t,e,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of A(t))!E.call(n,i)&&i!==e&&f(n,i,{get:()=>t[i],enumerable:!(u=x(t,i))||u.enumerable});return n};var h=n=>d(f({},"__esModule",{value:!0}),n);var S={};a(S,{isArguments:()=>p,isArray:()=>c,isArrayLike:()=>b,isEmpty:()=>s,isEmptyArr:()=>g,isEmptyArray:()=>O,isEmptyObject:()=>w,isEmptyString:()=>m,isNumber:()=>L,isObjectLike:()=>B,isPrototype:()=>k,rejectEmpty:()=>j});module.exports=h(S);var o=require("es-toolkit"),r=require("es-toolkit/predicate"),y=require("../utils/helpers");function k(n){const t=n.constructor,e=typeof t=="function"&&t.prototype?t.prototype:Object.prototype;return n===e}function p(n){return n!==null&&typeof n=="object"&&(0,y.getTag)(n)==="[object Arguments]"}function b(n){return n!=null&&typeof n!="function"&&(0,r.isLength)(n.length)}function s(n){if(n==null)return!0;if(b(n))return typeof n.splice!="function"&&typeof n!="string"&&(typeof Buffer=="undefined"||!Buffer.isBuffer(n))&&!(0,r.isTypedArray)(n)&&!p(n)?!1:n.length===0;if(typeof n=="object"){if(n instanceof Map||n instanceof Set)return n.size===0;const t=Object.keys(n);return k(n)?t.filter(e=>e!=="constructor").length===0:t.length===0}return!0}function c(n){return Array.isArray(n)}function L(n){return typeof n=="number"||n instanceof Number}const m=n=>(0,r.isString)(n)&&s((0,o.trim)(n)),w=n=>(0,r.isPlainObject)(n)&&s((0,o.pickBy)(n,o.identity)),g=n=>c(n)&&s((0,o.compact)(n)),j=n=>n.filter(t=>!m(t)&&!w(t)&&!g(t)),O=n=>c(n)&&s((0,o.compact)(j(n)));function B(n){return n===null||typeof n!="object"||c(n)||p(n)||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error||n instanceof Promise?!1:!(0,r.isPlainObject)(n)}
//# sourceMappingURL=validators.js.map