full-utils 3.0.5 → 3.0.7
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 -1
- package/dist/index.d.ts +6 -1
- 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/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { JSONLike, JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, jsonParse, jsonStrLike, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.cjs';
|
|
1
|
+
export { JSONLike, JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isBoolOrBoolTree, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isObjFlat, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, jsonParse, jsonStrLike, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Options controlling TCP connection behavior, request formatting, and response handling.
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { JSONLike, JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, jsonParse, jsonStrLike, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.js';
|
|
1
|
+
export { JSONLike, JsonLike, PasswordOptions, TimeParts, UniqueDeepOptions, arrFuncArgs, arrReplaceTemplate, arrSplitBatches, arrUniqueDeep, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, env, ipNumStr, ipStrNum, isArr, isArrFilled, isBool, isBoolOrBoolTree, isClass, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isObjFlat, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, jsonParse, jsonStrLike, numNormalize, strLowerCase, strNormalCase, strNormalize, strNull, strPhone, strTrim, strUndefined, urlDecode, urlObj, wait } from './index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Options controlling TCP connection behavior, request formatting, and response handling.
|
package/dist/node.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function cn(n){if(!u(n))return [n];let t=n.trim();if(t==="")return [];if(t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1).trim(),t===""))return [];let r="",e=false,i=null,o=false,s=0,l=0,m=0,h=[],N=()=>{let c=r.trim();c!==""&&h.push(c),r="";};for(let c=0;c<t.length;c++){let f=t[c];if(e){if(r+=f,o){o=false;continue}if(f==="\\"){o=true;continue}f===i&&(e=false,i=null);continue}if(f==='"'||f==="'"){e=true,i=f,r+=f;continue}if(f==="("){s++,r+=f;continue}if(f===")"){s=Math.max(0,s-1),r+=f;continue}if(f==="["){l++,r+=f;continue}if(f==="]"){l=Math.max(0,l-1),r+=f;continue}if(f==="{"){m++,r+=f;continue}if(f==="}"){m=Math.max(0,m-1),r+=f;continue}if(f===","&&s===0&&l===0&&m===0){N();continue}r+=f;}return r.length&&N(),h.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(M(c))return C(c);let f=U(c);if(Number.isFinite(f))return f;if(c==="Infinity")return 1/0;if(c==="-Infinity")return -1/0;let g=String(c||"");if(g.length>=2&&(g.startsWith("'")&&g.endsWith("'")||g.startsWith('"')&&g.endsWith('"')))return g.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(g.startsWith("{")&&g.endsWith("}")||g.startsWith("[")&&g.endsWith("]"))try{return J(g)}catch{}return g})}function ln(n,t){if(!Number.isInteger(t)||t<=0)return [];let r=[],e=0;for(;e<n.length;)r.push(n.slice(e,e+t)),e+=t;return r}function W(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return n==null||typeof n!="object"||n instanceof Date}function nn(n,t){return Array.isArray(n)?Array.isArray(t)?t:[t]:t}function L(n,t){if(n==null)return n;if(v(t))return nn(n,t);if(Array.isArray(n))return n.map(i=>L(i,t));if(!W(n)||!W(t))return n;let r={...n},e=false;for(let i of Object.keys(t)){if(!(i in n))continue;let o=L(n[i],t[i]);o!==n[i]&&(r[i]=o,e=true);}return e?r:n}function pn(n,t){return L(n,t)}function tn(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)}function rn(n){let t=new WeakSet,r=e=>{if(e===null)return "null";let i=typeof e;if(i==="string")return JSON.stringify(e);if(i==="number")return Number.isNaN(e)?'"__NaN__"':String(e);if(i==="boolean")return e?"true":"false";if(i==="undefined")return '"__undefined__"';if(i==="bigint")return `"__bigint__:${String(e)}"`;if(i==="function")return '"__function__"';if(e instanceof Date)return `"__date__:${e.toISOString()}"`;if(Array.isArray(e))return "["+e.map(r).join(",")+"]";if(i==="object"&&e){let o=e;return t.has(o)?'"__circular__"':(t.add(o),"{"+Object.keys(o).sort().map(m=>JSON.stringify(m)+":"+r(o[m])).join(",")+"}")}return JSON.stringify(String(e))};return r(n)}function en(n){if(n===null)return "null";let t=typeof n;return t==="string"?"s:"+n:t==="number"?"n:"+(Number.isNaN(n)?"__NaN__":n):t==="boolean"?"b:"+n:t==="undefined"?"u:":t==="bigint"?"bi:"+String(n):n instanceof Date?"d:"+n.toISOString():"o:"+rn(n)}function gn(n,t){let r=t?.keyFn??en,e=i=>{if(Array.isArray(i)){let o=i.map(e),s=new Set,l=[];for(let m of o){let h=r(m);s.has(h)||(s.add(h),l.push(m));}return l}if(tn(i)){let o={};for(let s of Object.keys(i))o[s]=e(i[s]);return o}return i};return e(n)}function C(n){switch(true){case F(n):return n;case S(n):return true;case z(n):return false;case(a(n)&&["true","1","yes","on"].includes(String(n??"").trim().toLowerCase())):return true;case(a(n)&&["false","0","no","off"].includes(String(n??"").trim().toLowerCase())):return false}return false}async function wn(n=0){await new Promise(t=>setTimeout(()=>t(true),n));}function bn(n){return process.env[n]}function Tn(n=1,t=new Date){let r=Math.min(60,Math.max(1,Math.trunc(Math.abs(n)))),e=t.getMinutes(),i=Math.floor(e/r)*r,o=new Date(t);return o.setMinutes(i,0,0),o}function On(n=new Date){let t=m=>String(m).padStart(2,"0"),r=n.getFullYear(),e=t(n.getMonth()+1),i=t(n.getDate()),o=t(n.getHours()),s=t(n.getMinutes()),l=t(n.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${l}`}function An(n){let{days:t=0,hours:r=0,minutes:e=0,seconds:i=0}=n;return t*86400+r*3600+e*60+i}function Fn(n){if(!Number.isFinite(n)||n<0)throw new Error("Invalid total seconds");let t=Math.floor(n/86400),r=Math.floor(n%86400/3600),e=Math.floor(n%3600/60),i=n%60;return {days:t,hours:r,minutes:e,seconds:i}}function _n(n){let t=n.split(".").map(o=>Number(o));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0||o>255))throw new Error("Invalid IPv4 address");let r=new ArrayBuffer(4),e=new DataView(r),i=0;for(;i<4;)e.setUint8(i,t[i]),i++;return e.getUint32(0,false)}function Bn(n){if(!S(n))return "";let t=new ArrayBuffer(4),r=new DataView(t);r.setUint32(0,n,false);let e=[],i=0;for(;i<4;)e.push(r.getUint8(i)),i++;return e.join(".")}function P(n){return Array.isArray(n)}function Z(n){return P(n)&&n.length>0}function F(n){return typeof n=="boolean"}function Wn(n){if(n instanceof Date)return !Number.isNaN(n.getTime());if(u(n)||d(n)){let t=new Date(n);return !Number.isNaN(t.getTime())}return false}var on=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function Vn(n){return a(n)?on.test(n):false}function qn(n){return n!=null}function E(n){return typeof n=="function"}var sn=/^(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 Yn(n){if(!u(n))return false;let t=n.trim();return sn.test(t)}function nt(n){return u(n)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(n)}function d(n){return typeof n=="number"&&Number.isFinite(n)}function it(n){return d(n)&&!Number.isInteger(n)}function ut(n){return d(n)&&n<0}function z(n){return d(n)&&n<=0}function S(n){return d(n)&&n>0}function V(n){return d(n)&&n>=0}function A(n){return typeof n=="object"&&n!==null&&Object.prototype.toString.call(n)==="[object Object]"&&!Array.isArray(n)}function Q(n){return A(n)&&Object.keys(n).length>0}function wt(n,{minLength:t=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:s=true}={}){return !(!u(n)||n.length<t||n.length>r||e&&!/[A-ZА-Я]/.test(n)||i&&!/[a-zа-я]/.test(n)||o&&!/\d/.test(n)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(n))}function St(n){if(!a(n)&&!d(n))return false;let t=String(n).trim();return !(t.startsWith("-")||(t.match(/\+/g)||[]).length>1||t.includes("+")&&!t.startsWith("+")||!/^\+?[0-9-]+$/.test(t)||t.length<3||t.length>20||!/[0-9]$/.test(t)||t.includes("--"))}function u(n){return typeof n=="string"}function M(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="true"||t==="false"}function a(n){return u(n)&&n.trim().length>0}function Et(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="asc"||t==="desc"}function It(n){return u(n)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)}function Rt(n){return E(n)&&/^class\s/.test(Function.prototype.toString.call(n))}var un=/^(['"`])([\s\S]*)\1$/;function _(n,t){let r=n.trim(),e=q(r);if(e.ok)return e.value;let i=un.exec(r);return i?i[2]:t?r:null}function q(n){try{return {ok:!0,value:JSON.parse(n)}}catch{}return {ok:false}}function J(n,t=false){if(n===null||d(n)||F(n))return n;if(Z(n)){let r=n,e=[];for(let i of r)a(i)?e.push(_(String(i),t)):e.push(i);return e}if(Q(n)){let r=n,e={};for(let i of Object.keys(r)){let o=r[i];a(o)?e[i]=_(String(o),t):e[i]=o;}return e}return P(n)||A(n)?n:a(n)?_(String(n),t):null}function Qt(n){try{return A(n)||P(n)?JSON.stringify(n):""}catch{}return ""}function H(n){let t=n.sign<0?"-":"",r=n.digitsInteger.toString();if(n.scale===0)return t+r;let e=n.scale-r.length;if(e>=0)return t+"0."+"0".repeat(e)+r;let i=r.length-n.scale,o=r.slice(0,i),s=r.slice(i);return t+o+"."+s}function K(n){return Number(H(n))}function B(n,t){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,s]=t.split(/e/i),[l,m=""]=o.split("."),h=l.replace(/^0+/,"")+m,N=parseInt(s,10)-m.length;return `${h||"0"}e${N}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(V(i))return e=e+"0".repeat(i),{sign:n,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let s="0".repeat(o-e.length);return {sign:n,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-o;return {sign:n,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function G(n){if(typeof n=="bigint"){let t=n<0n?-1:1,r=(n<0n?-n:n).toString();return {sign:t,integerPart:r,fractionalPart:""}}if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("Input number is not finite.");let t=n<0?-1:1,e=Math.abs(n).toExponential(30);return B(t,e)}if(typeof n=="string"){let t=n.trim().replace(",",".");if(!t)throw new Error("Input string is empty.");let r=1;if((t.startsWith("+")||t.startsWith("-"))&&(r=t.startsWith("-")?-1:1,t=t.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(t)){if(/e/i.test(t))return B(r,t);let[e="0",i=""]=t.split(".");return {sign:r,integerPart:e,fractionalPart:i}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function R(n){let{sign:t,integerPart:r,fractionalPart:e}=G(n),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),s=i+o||"0";return {sign:t,digitsInteger:BigInt(s),scale:o.length}}function Y(n,t,r="half-up"){let e=Math.max(0,Math.trunc(t));if(n.scale<=e)return {...n};let i=n.scale-e,o=10n**BigInt(i),s=n.digitsInteger/o,l=n.digitsInteger%o;if(r==="trunc"||l===0n)return {sign:n.sign,digitsInteger:s,scale:e};let m=o/2n,N=l>=m?s+1n:s;return {sign:n.sign,digitsInteger:N,scale:e}}function U(n,t=1,r=false){try{return K(t>1?Y(R(n),t,"half-up"):R(n))}catch(e){if(r)throw e}return 0}function X(n){if(!u(n))return "";let t=w(n);return a(t)?t.toLowerCase():""}function lr(n){if(!u(n))return "";let t=X(n);return a(t)?t[0].toUpperCase()+t.slice(1):""}function gr(n){return u(n)&&w(n)===""||n===void 0?null:n}function hr(n,t="+7"){if(!u(n))return null;let r=w(n).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(r)?r="+"+r.slice(2):/^\d{10}$/.test(r)?r=t+r:/^\d{9,15}$/.test(r)&&!r.startsWith("0")&&(r="+"+r),/^\+\d{10,15}$/.test(r)?r:null}function w(n,t=""){let r=String(u(n)?n.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return t?r.split(t).filter(e=>!!e).join(t):r}function Nr(n){return u(n)&&w(n)===""||n===null?void 0:n}var Ar=n=>{if(!u(n))return n;let t=String(w(n)||"");return t===""?null:String(t.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function Fr(n=""){return {}}function jr(n){if(!a(n))return String(n);let t="____RAW_PERCENT____",r=n.replace(/%(?![0-9A-Fa-f]{2})/g,t),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return r.replace(/%([0-9A-Fa-f]{2})/g,(o,s)=>{let l=s.toUpperCase();return e.has(l)?decodeURIComponent(`%${l}`):`%${l}`}).split(t).join("%")}function x(n,t){let r=new Error(t??n);return r.code=n,r}var j=null;async function $r(n,t,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:l=0,halfCloseAfterWrite:m=false,lineTerminator:h=""}={}){if(!(typeof process<"u"&&!!process.versions?.node))throw x("ENODEONLY","connectTCP is Node-only");if(!a(t))throw x("EBADHOST","`host` must be a non-empty string");if(!a(n))throw x("EBADMSG","`message` must be a non-empty string");if(!S(r)||r<1||r>65535)throw x("EBADPORT","`port` must be an integer in range 1..65535");let c=o.toLowerCase()==="utf-8"?"utf8":o;if(!j)try{j=await import('net');}catch{}if(!j)throw x("ENETIMPORT","FATAL: node:net import failed");return new Promise((f,g)=>{let p=new j.Socket,O=false,D=0,k=null,$=()=>{p.destroyed||p.destroy(x("EABORT","Operation cancelled")),b(x("EABORT","Operation cancelled"));},b=(y,T)=>{O||(O=true,p.removeAllListeners(),s&&s.removeEventListener("abort",$),p.destroyed||p.destroy(),k&&clearTimeout(k),y?g(y):f(T??""));};if(s){if(s.aborted)return b(x("EABORT","Operation cancelled"));s.addEventListener("abort",$,{once:true});}S(i)&&(k=setTimeout(()=>b(x("ETIMEDOUT","Connect timed out")),i),k&&E(k.unref)&&k.unref()),S(e)&&(p.setTimeout(e),p.once("timeout",()=>b(x("ETIMEDOUT","Idle timeout"))));let I=[];p.on("data",y=>{if(O)return;let T=Buffer.isBuffer(y)?y:Buffer.from(y,c);if(S(l)&&D+T.length>l)return b(x("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));I.push(T),D+=T.length;}),p.once("end",()=>{if(O)return;let y=Buffer.concat(I,D).toString(c);b(void 0,y);}),p.once("close",y=>{if(O)return;let T=Buffer.concat(I,D).toString(c);y?b(x("ECLOSE","Socket closed with error")):b(void 0,T);}),p.once("error",y=>{O||b(y);}),p.once("connect",()=>{k&&(clearTimeout(k),k=null);let y=h?n+h:n;p.write(y,c)?m&&p.end():p.once("drain",()=>{m&&!O&&p.end();});}),p.connect({host:t,port:r});})}export{cn as arrFuncArgs,pn as arrReplaceTemplate,ln as arrSplitBatches,gn as arrUniqueDeep,C as boolNormalize,Tn as dateFloorMin,An as datePartsSec,Fn as dateSecParts,On as dateStr,bn as env,Bn as ipNumStr,_n as ipStrNum,P as isArr,Z as isArrFilled,F as isBool,Rt as isClass,Wn as isDate,Vn as isEmail,qn as isExists,E as isFunc,Yn as isIpAddr,nt as isMacAddr,d as isNum,it as isNumFloat,ut as isNumN,z as isNumNZ,S as isNumP,V as isNumPZ,A as isObj,Q as isObjFilled,wt as isPassword,St as isPhone,u as isStr,Et as isStrAscDesc,M as isStrBool,a as isStrFilled,It as isVar,J as jsonDecode,Qt as jsonEncode,q as jsonParse,_ as jsonStrLike,$r as netTCP,U as numNormalize,X as strLowerCase,lr as strNormalCase,Ar as strNormalize,gr as strNull,hr as strPhone,w as strTrim,Nr as strUndefined,jr as urlDecode,Fr as urlObj,wn as wait};//# sourceMappingURL=node.mjs.map
|
|
1
|
+
function an(n){if(!u(n))return [n];let t=n.trim();if(t==="")return [];if(t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1).trim(),t===""))return [];let r="",e=false,i=null,o=false,s=0,l=0,m=0,x=[],P=()=>{let c=r.trim();c!==""&&x.push(c),r="";};for(let c=0;c<t.length;c++){let f=t[c];if(e){if(r+=f,o){o=false;continue}if(f==="\\"){o=true;continue}f===i&&(e=false,i=null);continue}if(f==='"'||f==="'"){e=true,i=f,r+=f;continue}if(f==="("){s++,r+=f;continue}if(f===")"){s=Math.max(0,s-1),r+=f;continue}if(f==="["){l++,r+=f;continue}if(f==="]"){l=Math.max(0,l-1),r+=f;continue}if(f==="{"){m++,r+=f;continue}if(f==="}"){m=Math.max(0,m-1),r+=f;continue}if(f===","&&s===0&&l===0&&m===0){P();continue}r+=f;}return r.length&&P(),x.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(J(c))return M(c);let f=W(c);if(Number.isFinite(f))return f;if(c==="Infinity")return 1/0;if(c==="-Infinity")return -1/0;let g=String(c||"");if(g.length>=2&&(g.startsWith("'")&&g.endsWith("'")||g.startsWith('"')&&g.endsWith('"')))return g.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(g.startsWith("{")&&g.endsWith("}")||g.startsWith("[")&&g.endsWith("]"))try{return U(g)}catch{}return g})}function mn(n,t){if(!Number.isInteger(t)||t<=0)return [];let r=[],e=0;for(;e<n.length;)r.push(n.slice(e,e+t)),e+=t;return r}function z(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return n==null||typeof n!="object"||n instanceof Date}function nn(n,t){return Array.isArray(n)?Array.isArray(t)?t:[t]:t}function B(n,t){if(n==null)return n;if(v(t))return nn(n,t);if(Array.isArray(n))return n.map(i=>B(i,t));if(!z(n)||!z(t))return n;let r={...n},e=false;for(let i of Object.keys(t)){if(!(i in n))continue;let o=B(n[i],t[i]);o!==n[i]&&(r[i]=o,e=true);}return e?r:n}function dn(n,t){return B(n,t)}function tn(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)}function rn(n){let t=new WeakSet,r=e=>{if(e===null)return "null";let i=typeof e;if(i==="string")return JSON.stringify(e);if(i==="number")return Number.isNaN(e)?'"__NaN__"':String(e);if(i==="boolean")return e?"true":"false";if(i==="undefined")return '"__undefined__"';if(i==="bigint")return `"__bigint__:${String(e)}"`;if(i==="function")return '"__function__"';if(e instanceof Date)return `"__date__:${e.toISOString()}"`;if(Array.isArray(e))return "["+e.map(r).join(",")+"]";if(i==="object"&&e){let o=e;return t.has(o)?'"__circular__"':(t.add(o),"{"+Object.keys(o).sort().map(m=>JSON.stringify(m)+":"+r(o[m])).join(",")+"}")}return JSON.stringify(String(e))};return r(n)}function en(n){if(n===null)return "null";let t=typeof n;return t==="string"?"s:"+n:t==="number"?"n:"+(Number.isNaN(n)?"__NaN__":n):t==="boolean"?"b:"+n:t==="undefined"?"u:":t==="bigint"?"bi:"+String(n):n instanceof Date?"d:"+n.toISOString():"o:"+rn(n)}function yn(n,t){let r=t?.keyFn??en,e=i=>{if(Array.isArray(i)){let o=i.map(e),s=new Set,l=[];for(let m of o){let x=r(m);s.has(x)||(s.add(x),l.push(m));}return l}if(tn(i)){let o={};for(let s of Object.keys(i))o[s]=e(i[s]);return o}return i};return e(n)}function M(n){switch(true){case A(n):return n;case S(n):return true;case Z(n):return false;case(a(n)&&["true","1","yes","on"].includes(String(n??"").trim().toLowerCase())):return true;case(a(n)&&["false","0","no","off"].includes(String(n??"").trim().toLowerCase())):return false}return false}async function kn(n=0){await new Promise(t=>setTimeout(()=>t(true),n));}function Sn(n){return process.env[n]}function Nn(n=1,t=new Date){let r=Math.min(60,Math.max(1,Math.trunc(Math.abs(n)))),e=t.getMinutes(),i=Math.floor(e/r)*r,o=new Date(t);return o.setMinutes(i,0,0),o}function Pn(n=new Date){let t=m=>String(m).padStart(2,"0"),r=n.getFullYear(),e=t(n.getMonth()+1),i=t(n.getDate()),o=t(n.getHours()),s=t(n.getMinutes()),l=t(n.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${l}`}function An(n){let{days:t=0,hours:r=0,minutes:e=0,seconds:i=0}=n;return t*86400+r*3600+e*60+i}function jn(n){if(!Number.isFinite(n)||n<0)throw new Error("Invalid total seconds");let t=Math.floor(n/86400),r=Math.floor(n%86400/3600),e=Math.floor(n%3600/60),i=n%60;return {days:t,hours:r,minutes:e,seconds:i}}function _n(n){let t=n.split(".").map(o=>Number(o));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0||o>255))throw new Error("Invalid IPv4 address");let r=new ArrayBuffer(4),e=new DataView(r),i=0;for(;i<4;)e.setUint8(i,t[i]),i++;return e.getUint32(0,false)}function Rn(n){if(!S(n))return "";let t=new ArrayBuffer(4),r=new DataView(t);r.setUint32(0,n,false);let e=[],i=0;for(;i<4;)e.push(r.getUint8(i)),i++;return e.join(".")}function N(n){return Array.isArray(n)}function V(n){return N(n)&&n.length>0}function A(n){return typeof n=="boolean"}function D(n){return O(n)&&Object.keys(n).length>0}function on(n){if(A(n))return true;if(!D(n))return false;for(let t of Object.keys(n))if(!on(n[t]))return false;return true}function Hn(n){if(n instanceof Date)return !Number.isNaN(n.getTime());if(u(n)||d(n)){let t=new Date(n);return !Number.isNaN(t.getTime())}return false}var sn=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function Yn(n){return a(n)?sn.test(n):false}function vn(n){return n!=null}function j(n){return typeof n=="function"}var un=/^(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 et(n){if(!u(n))return false;let t=n.trim();return un.test(t)}function st(n){return u(n)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(n)}function d(n){return typeof n=="number"&&Number.isFinite(n)}function at(n){return d(n)&&!Number.isInteger(n)}function pt(n){return d(n)&&n<0}function Z(n){return d(n)&&n<=0}function S(n){return d(n)&&n>0}function Q(n){return d(n)&&n>=0}function O(n){return typeof n=="object"&&n!==null&&Object.prototype.toString.call(n)==="[object Object]"&&!Array.isArray(n)&&!(n instanceof Date)}function Pt(n){return D(n)?Object.values(n).every(t=>t===null||!O(t)&&!N(t)||!j(t)):false}function Dt(n,{minLength:t=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:s=true}={}){return !(!u(n)||n.length<t||n.length>r||e&&!/[A-ZА-Я]/.test(n)||i&&!/[a-zа-я]/.test(n)||o&&!/\d/.test(n)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(n))}function _t(n){if(!a(n)&&!d(n))return false;let t=String(n).trim();return !(t.startsWith("-")||(t.match(/\+/g)||[]).length>1||t.includes("+")&&!t.startsWith("+")||!/^\+?[0-9-]+$/.test(t)||t.length<3||t.length>20||!/[0-9]$/.test(t)||t.includes("--"))}function u(n){return typeof n=="string"}function J(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="true"||t==="false"}function a(n){return u(n)&&n.trim().length>0}function Jt(n){if(!a(n))return false;let t=n.trim().toLowerCase();return t==="asc"||t==="desc"}function zt(n){return u(n)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)}function Qt(n){return j(n)&&/^class\s/.test(Function.prototype.toString.call(n))}var fn=/^(['"`])([\s\S]*)\1$/;function _(n,t){let r=n.trim(),e=q(r);if(e.ok)return e.value;let i=fn.exec(r);return i?i[2]:t?r:null}function q(n){try{return {ok:!0,value:JSON.parse(n)}}catch{}return {ok:false}}function U(n,t=false){if(n===null||d(n)||A(n))return n;if(V(n)){let r=n,e=[];for(let i of r)a(i)?e.push(_(String(i),t)):e.push(i);return e}if(D(n)){let r=n,e={};for(let i of Object.keys(r)){let o=r[i];a(o)?e[i]=_(String(o),t):e[i]=o;}return e}return N(n)||O(n)?n:a(n)?_(String(n),t):null}function rr(n){try{return O(n)||N(n)?JSON.stringify(n):""}catch{}return ""}function H(n){let t=n.sign<0?"-":"",r=n.digitsInteger.toString();if(n.scale===0)return t+r;let e=n.scale-r.length;if(e>=0)return t+"0."+"0".repeat(e)+r;let i=r.length-n.scale,o=r.slice(0,i),s=r.slice(i);return t+o+"."+s}function K(n){return Number(H(n))}function R(n,t){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,s]=t.split(/e/i),[l,m=""]=o.split("."),x=l.replace(/^0+/,"")+m,P=parseInt(s,10)-m.length;return `${x||"0"}e${P}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(Q(i))return e=e+"0".repeat(i),{sign:n,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let s="0".repeat(o-e.length);return {sign:n,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-o;return {sign:n,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function G(n){if(typeof n=="bigint"){let t=n<0n?-1:1,r=(n<0n?-n:n).toString();return {sign:t,integerPart:r,fractionalPart:""}}if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("Input number is not finite.");let t=n<0?-1:1,e=Math.abs(n).toExponential(30);return R(t,e)}if(typeof n=="string"){let t=n.trim().replace(",",".");if(!t)throw new Error("Input string is empty.");let r=1;if((t.startsWith("+")||t.startsWith("-"))&&(r=t.startsWith("-")?-1:1,t=t.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(t)){if(/e/i.test(t))return R(r,t);let[e="0",i=""]=t.split(".");return {sign:r,integerPart:e,fractionalPart:i}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function $(n){let{sign:t,integerPart:r,fractionalPart:e}=G(n),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),s=i+o||"0";return {sign:t,digitsInteger:BigInt(s),scale:o.length}}function Y(n,t,r="half-up"){let e=Math.max(0,Math.trunc(t));if(n.scale<=e)return {...n};let i=n.scale-e,o=10n**BigInt(i),s=n.digitsInteger/o,l=n.digitsInteger%o;if(r==="trunc"||l===0n)return {sign:n.sign,digitsInteger:s,scale:e};let m=o/2n,P=l>=m?s+1n:s;return {sign:n.sign,digitsInteger:P,scale:e}}function W(n,t=1,r=false){try{return K(t>1?Y($(n),t,"half-up"):$(n))}catch(e){if(r)throw e}return 0}function X(n){if(!u(n))return "";let t=w(n);return a(t)?t.toLowerCase():""}function hr(n){if(!u(n))return "";let t=X(n);return a(t)?t[0].toUpperCase()+t.slice(1):""}function Or(n){return u(n)&&w(n)===""||n===void 0?null:n}function Ar(n,t="+7"){if(!u(n))return null;let r=w(n).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(r)?r="+"+r.slice(2):/^\d{10}$/.test(r)?r=t+r:/^\d{9,15}$/.test(r)&&!r.startsWith("0")&&(r="+"+r),/^\+\d{10,15}$/.test(r)?r:null}function w(n,t=""){let r=String(u(n)?n.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return t?r.split(t).filter(e=>!!e).join(t):r}function Lr(n){return u(n)&&w(n)===""||n===null?void 0:n}var $r=n=>{if(!u(n))return n;let t=String(w(n)||"");return t===""?null:String(t.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function Mr(n=""){return {}}function Wr(n){if(!a(n))return String(n);let t="____RAW_PERCENT____",r=n.replace(/%(?![0-9A-Fa-f]{2})/g,t),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return r.replace(/%([0-9A-Fa-f]{2})/g,(o,s)=>{let l=s.toUpperCase();return e.has(l)?decodeURIComponent(`%${l}`):`%${l}`}).split(t).join("%")}function b(n,t){let r=new Error(t??n);return r.code=n,r}var I=null;async function qr(n,t,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:l=0,halfCloseAfterWrite:m=false,lineTerminator:x=""}={}){if(!(typeof process<"u"&&!!process.versions?.node))throw b("ENODEONLY","connectTCP is Node-only");if(!a(t))throw b("EBADHOST","`host` must be a non-empty string");if(!a(n))throw b("EBADMSG","`message` must be a non-empty string");if(!S(r)||r<1||r>65535)throw b("EBADPORT","`port` must be an integer in range 1..65535");let c=o.toLowerCase()==="utf-8"?"utf8":o;if(!I)try{I=await import('net');}catch{}if(!I)throw b("ENETIMPORT","FATAL: node:net import failed");return new Promise((f,g)=>{let p=new I.Socket,F=false,E=0,k=null,C=()=>{p.destroyed||p.destroy(b("EABORT","Operation cancelled")),h(b("EABORT","Operation cancelled"));},h=(y,T)=>{F||(F=true,p.removeAllListeners(),s&&s.removeEventListener("abort",C),p.destroyed||p.destroy(),k&&clearTimeout(k),y?g(y):f(T??""));};if(s){if(s.aborted)return h(b("EABORT","Operation cancelled"));s.addEventListener("abort",C,{once:true});}S(i)&&(k=setTimeout(()=>h(b("ETIMEDOUT","Connect timed out")),i),k&&j(k.unref)&&k.unref()),S(e)&&(p.setTimeout(e),p.once("timeout",()=>h(b("ETIMEDOUT","Idle timeout"))));let L=[];p.on("data",y=>{if(F)return;let T=Buffer.isBuffer(y)?y:Buffer.from(y,c);if(S(l)&&E+T.length>l)return h(b("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));L.push(T),E+=T.length;}),p.once("end",()=>{if(F)return;let y=Buffer.concat(L,E).toString(c);h(void 0,y);}),p.once("close",y=>{if(F)return;let T=Buffer.concat(L,E).toString(c);y?h(b("ECLOSE","Socket closed with error")):h(void 0,T);}),p.once("error",y=>{F||h(y);}),p.once("connect",()=>{k&&(clearTimeout(k),k=null);let y=x?n+x:n;p.write(y,c)?m&&p.end():p.once("drain",()=>{m&&!F&&p.end();});}),p.connect({host:t,port:r});})}export{an as arrFuncArgs,dn as arrReplaceTemplate,mn as arrSplitBatches,yn as arrUniqueDeep,M as boolNormalize,Nn as dateFloorMin,An as datePartsSec,jn as dateSecParts,Pn as dateStr,Sn as env,Rn as ipNumStr,_n as ipStrNum,N as isArr,V as isArrFilled,A as isBool,on as isBoolOrBoolTree,Qt as isClass,Hn as isDate,Yn as isEmail,vn as isExists,j as isFunc,et as isIpAddr,st as isMacAddr,d as isNum,at as isNumFloat,pt as isNumN,Z as isNumNZ,S as isNumP,Q as isNumPZ,O as isObj,D as isObjFilled,Pt as isObjFlat,Dt as isPassword,_t as isPhone,u as isStr,Jt as isStrAscDesc,J as isStrBool,a as isStrFilled,zt as isVar,U as jsonDecode,rr as jsonEncode,q as jsonParse,_ as jsonStrLike,qr as netTCP,W as numNormalize,X as strLowerCase,hr as strNormalCase,$r as strNormalize,Or as strNull,Ar as strPhone,w as strTrim,Lr as strUndefined,Wr as urlDecode,Mr as urlObj,kn as wait};//# sourceMappingURL=node.mjs.map
|
|
2
2
|
//# sourceMappingURL=node.mjs.map
|