full-utils 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function V(t){if(!s(t))return [t];let r=t.trim();if(r==="")return [];if(r.startsWith("[")&&r.endsWith("]")&&(r=r.slice(1,-1).trim(),r===""))return [];let n="",e=false,o=null,i=false,u=0,p=0,d=0,S=[],g=()=>{let c=n.trim();c!==""&&S.push(c),n="";};for(let c=0;c<r.length;c++){let f=r[c];if(e){if(n+=f,i){i=false;continue}if(f==="\\"){i=true;continue}f===o&&(e=false,o=null);continue}if(f==='"'||f==="'"){e=true,o=f,n+=f;continue}if(f==="("){u++,n+=f;continue}if(f===")"){u=Math.max(0,u-1),n+=f;continue}if(f==="["){p++,n+=f;continue}if(f==="]"){p=Math.max(0,p-1),n+=f;continue}if(f==="{"){d++,n+=f;continue}if(f==="}"){d=Math.max(0,d-1),n+=f;continue}if(f===","&&u===0&&p===0&&d===0){g();continue}n+=f;}return n.length&&g(),S.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(P(c))return F(c);let f=A(c);if(Number.isFinite(f))return f;if(c==="Infinity")return 1/0;if(c==="-Infinity")return -1/0;let l=String(c||"");if(l.length>=2&&(l.startsWith("'")&&l.endsWith("'")||l.startsWith('"')&&l.endsWith('"')))return l.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(l.startsWith("{")&&l.endsWith("}")||l.startsWith("[")&&l.endsWith("]"))try{return D(l)}catch{}return l})}function H(t,r){if(!Number.isInteger(r)||r<=0)return [];let n=[],e=0;for(;e<t.length;)n.push(t.slice(e,e+r)),e+=r;return n}function F(t){switch(true){case k(t):return t;case y(t):return true;case O(t):return false;case(m(t)&&["true","1","yes","on"].includes(String(t??"").trim().toLowerCase())):return true;case(m(t)&&["false","0","no","off"].includes(String(t??"").trim().toLowerCase())):return false}return false}async function G(t=0){await new Promise(r=>setTimeout(()=>r(true),t));}function v(t){return process.env[t]}function rt(t=1,r=new Date){let n=Math.min(60,Math.max(1,Math.trunc(Math.abs(t)))),e=r.getMinutes(),o=Math.floor(e/n)*n,i=new Date(r);return i.setMinutes(o,0,0),i}function et(t=new Date){let r=d=>String(d).padStart(2,"0"),n=t.getFullYear(),e=r(t.getMonth()+1),o=r(t.getDate()),i=r(t.getHours()),u=r(t.getMinutes()),p=r(t.getSeconds());return `${n}-${e}-${o} ${i}:${u}:${p}`}function it(t){let{days:r=0,hours:n=0,minutes:e=0,seconds:o=0}=t;return r*86400+n*3600+e*60+o}function ut(t){if(!Number.isFinite(t)||t<0)throw new Error("Invalid total seconds");let r=Math.floor(t/86400),n=Math.floor(t%86400/3600),e=Math.floor(t%3600/60),o=t%60;return {days:r,hours:n,minutes:e,seconds:o}}function mt(t){let r=t.split(".").map(i=>Number(i));if(r.length!==4||r.some(i=>!Number.isInteger(i)||i<0||i>255))throw new Error("Invalid IPv4 address");let n=new ArrayBuffer(4),e=new DataView(n),o=0;for(;o<4;)e.setUint8(o,r[o]),o++;return e.getUint32(0,false)}function lt(t){if(!y(t))return "";let r=new ArrayBuffer(4),n=new DataView(r);n.setUint32(0,t,false);let e=[],o=0;for(;o<4;)e.push(n.getUint8(o)),o++;return e.join(".")}function h(t){return Array.isArray(t)}function I(t){return h(t)&&t.length>0}function k(t){return typeof t=="boolean"}function kt(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(s(t)||a(t)){let r=new Date(t);return !Number.isNaN(r.getTime())}return false}var _=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function bt(t){return m(t)?_.test(t):false}function Ft(t){return t!=null}function j(t){return typeof t=="function"}var B=/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/;function Ot(t){if(!s(t))return false;let r=t.trim();return B.test(r)}function $t(t){return s(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function a(t){return typeof t=="number"&&Number.isFinite(t)}function Ct(t){return a(t)&&!Number.isInteger(t)}function Ut(t){return a(t)&&t<0}function O(t){return a(t)&&t<=0}function y(t){return a(t)&&t>0}function $(t){return a(t)&&t>=0}function w(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function L(t){return w(t)&&Object.keys(t).length>0}function Gt(t,{minLength:r=8,maxLength:n=256,requireUppercase:e=true,requireLowercase:o=true,requireDigit:i=true,requireSpecial:u=true}={}){return !(!s(t)||t.length<r||t.length>n||e&&!/[A-ZА-Я]/.test(t)||o&&!/[a-zа-я]/.test(t)||i&&!/\d/.test(t)||u&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function tr(t){if(!m(t)&&!a(t))return false;let r=String(t).trim();return !(r.startsWith("-")||(r.match(/\+/g)||[]).length>1||r.includes("+")&&!r.startsWith("+")||!/^\+?[0-9-]+$/.test(r)||r.length<3||r.length>20||!/[0-9]$/.test(r)||r.includes("--"))}function s(t){return typeof t=="string"}function P(t){if(!m(t))return false;let r=t.trim().toLowerCase();return r==="true"||r==="false"}function m(t){return s(t)&&t.trim().length>0}function fr(t){if(!m(t))return false;let r=t.trim().toLowerCase();return r==="asc"||r==="desc"}function ar(t){return s(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function dr(t){return j(t)&&/^class\s/.test(Function.prototype.toString.call(t))}var J=/^(['"`])([\s\S]*)\1$/;function N(t,r){let n=t.trim(),e=E(n);if(e.ok)return e.value;let o=J.exec(n);return o?o[2]:r?n:null}function E(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function D(t,r=false){if(t===null||a(t)||k(t))return t;if(I(t)){let n=t,e=[];for(let o of n)m(o)?e.push(N(String(o),r)):e.push(o);return e}if(L(t)){let n=t,e={};for(let o of Object.keys(n)){let i=n[o];m(i)?e[o]=N(String(i),r):e[o]=i;}return e}return h(t)||w(t)?t:m(t)?N(String(t),r):null}function Tr(t){try{return w(t)||h(t)?JSON.stringify(t):""}catch{}return ""}function W(t){let r=t.sign<0?"-":"",n=t.digitsInteger.toString();if(t.scale===0)return r+n;let e=t.scale-n.length;if(e>=0)return r+"0."+"0".repeat(e)+n;let o=n.length-t.scale,i=n.slice(0,o),u=n.slice(o);return r+i+"."+u}function C(t){return Number(W(t))}function b(t,r){let n=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[i,u]=r.split(/e/i),[p,d=""]=i.split("."),S=p.replace(/^0+/,"")+d,g=parseInt(u,10)-d.length;return `${S||"0"}e${g}`})());if(!n)throw new Error("Failed to parse exponential notation.");let e=n[1],o=parseInt(n[3],10);if($(o))return e=e+"0".repeat(o),{sign:t,integerPart:e||"0",fractionalPart:""};{let i=-o;if(i>=e.length){let u="0".repeat(i-e.length);return {sign:t,integerPart:"0",fractionalPart:u+e}}else {let u=e.length-i;return {sign:t,integerPart:e.slice(0,u),fractionalPart:e.slice(u)}}}}function M(t){if(typeof t=="bigint"){let r=t<0n?-1:1,n=(t<0n?-t:t).toString();return {sign:r,integerPart:n,fractionalPart:""}}if(typeof t=="number"){if(!Number.isFinite(t))throw new Error("Input number is not finite.");let r=t<0?-1:1,e=Math.abs(t).toExponential(30);return b(r,e)}if(typeof t=="string"){let r=t.trim().replace(",",".");if(!r)throw new Error("Input string is empty.");let n=1;if((r.startsWith("+")||r.startsWith("-"))&&(n=r.startsWith("-")?-1:1,r=r.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(r)){if(/e/i.test(r))return b(n,r);let[e="0",o=""]=r.split(".");return {sign:n,integerPart:e,fractionalPart:o}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function T(t){let{sign:r,integerPart:n,fractionalPart:e}=M(t),o=n.replace(/^0+/,"")||"0",i=e.replace(/0+$/,""),u=o+i||"0";return {sign:r,digitsInteger:BigInt(u),scale:i.length}}function z(t,r,n="half-up"){let e=Math.max(0,Math.trunc(r));if(t.scale<=e)return {...t};let o=t.scale-e,i=10n**BigInt(o),u=t.digitsInteger/i,p=t.digitsInteger%i;if(n==="trunc"||p===0n)return {sign:t.sign,digitsInteger:u,scale:e};let d=i/2n,g=p>=d?u+1n:u;return {sign:t.sign,digitsInteger:g,scale:e}}function A(t,r=1,n=false){try{return C(r>1?z(T(t),r,"half-up"):T(t))}catch(e){if(n)throw e}return 0}function U(t){if(!s(t))return "";let r=x(t);return m(r)?r.toLowerCase():""}function Rr(t){if(!s(t))return "";let r=U(t);return m(r)?r[0].toUpperCase()+r.slice(1):""}function Hr(t){return s(t)&&x(t)===""||t===void 0?null:t}function Yr(t,r="+7"){if(!s(t))return null;let n=x(t).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(n)?n="+"+n.slice(2):/^\d{10}$/.test(n)?n=r+n:/^\d{9,15}$/.test(n)&&!n.startsWith("0")&&(n="+"+n),/^\+\d{10,15}$/.test(n)?n:null}function x(t,r=""){let n=String(s(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return r?n.split(r).filter(e=>!!e).join(r):n}function nn(t){return s(t)&&x(t)===""||t===null?void 0:t}var sn=t=>{if(!s(t))return t;let r=String(x(t)||"");return r===""?null:String(r.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function fn(t=""){return {}}function an(t){if(!m(t))return String(t);let r="____RAW_PERCENT____",n=t.replace(/%(?![0-9A-Fa-f]{2})/g,r),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return n.replace(/%([0-9A-Fa-f]{2})/g,(i,u)=>{let p=u.toUpperCase();return e.has(p)?decodeURIComponent(`%${p}`):`%${p}`}).split(r).join("%")}exports.arrFuncArgs=V;exports.arrSplitPortions=H;exports.boolNormalize=F;exports.dateFloorMin=rt;exports.datePartsSec=it;exports.dateSecParts=ut;exports.dateStr=et;exports.env=v;exports.ipNumStr=lt;exports.ipStrNum=mt;exports.isArr=h;exports.isArrFilled=I;exports.isBool=k;exports.isClass=dr;exports.isDate=kt;exports.isEmail=bt;exports.isExists=Ft;exports.isFunc=j;exports.isIpAddr=Ot;exports.isMacAddr=$t;exports.isNum=a;exports.isNumFloat=Ct;exports.isNumN=Ut;exports.isNumNZ=O;exports.isNumP=y;exports.isNumPZ=$;exports.isObj=w;exports.isObjFilled=L;exports.isPassword=Gt;exports.isPhone=tr;exports.isStr=s;exports.isStrAscDesc=fr;exports.isStrBool=P;exports.isStrFilled=m;exports.isVar=ar;exports.jsonDecode=D;exports.jsonEncode=Tr;exports.jsonParse=E;exports.jsonStrLike=N;exports.numNormalize=A;exports.strLowerCase=U;exports.strNormalCase=Rr;exports.strNormalize=sn;exports.strNull=Hr;exports.strPhone=Yr;exports.strTrim=x;exports.strUndefined=nn;exports.urlDecode=an;exports.urlObj=fn;exports.wait=G;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|