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.49 kB
JavaScript
import{compact as i,identity as f,pickBy as p,trim as u}from"es-toolkit";import{isLength as y,isPlainObject as s,isString as k,isTypedArray as b}from"es-toolkit/predicate";import{getTag as m}from"../utils/helpers";function w(n){const t=n.constructor,r=typeof t=="function"&&t.prototype?t.prototype:Object.prototype;return n===r}function c(n){return n!==null&&typeof n=="object"&&m(n)==="[object Arguments]"}function g(n){return n!=null&&typeof n!="function"&&y(n.length)}function o(n){if(n==null)return!0;if(g(n))return typeof n.splice!="function"&&typeof n!="string"&&(typeof Buffer=="undefined"||!Buffer.isBuffer(n))&&!b(n)&&!c(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 w(n)?t.filter(r=>r!=="constructor").length===0:t.length===0}return!0}function e(n){return Array.isArray(n)}function L(n){return typeof n=="number"||n instanceof Number}const j=n=>k(n)&&o(u(n)),x=n=>s(n)&&o(p(n,f)),A=n=>e(n)&&o(i(n)),E=n=>n.filter(t=>!j(t)&&!x(t)&&!A(t)),O=n=>e(n)&&o(i(E(n)));function B(n){return n===null||typeof n!="object"||e(n)||c(n)||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error||n instanceof Promise?!1:!s(n)}export{c as isArguments,e as isArray,g as isArrayLike,o as isEmpty,A as isEmptyArr,O as isEmptyArray,x as isEmptyObject,j as isEmptyString,L as isNumber,B as isObjectLike,w as isPrototype,E as rejectEmpty};
//# sourceMappingURL=validators.js.map