full-utils 3.0.2 → 3.0.4

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/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { JSONLike, PasswordOptions, TimeParts, arrFuncArgs, arrSplitPortions, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, 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, 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, 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';
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, PasswordOptions, TimeParts, arrFuncArgs, arrSplitPortions, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr, 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, 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, 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';
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 nt(t){if(!u(t))return [t];let n=t.trim();if(n==="")return [];if(n.startsWith("[")&&n.endsWith("]")&&(n=n.slice(1,-1).trim(),n===""))return [];let r="",e=false,i=null,o=false,s=0,p=0,d=0,T=[],N=()=>{let c=r.trim();c!==""&&T.push(c),r="";};for(let c=0;c<n.length;c++){let f=n[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==="["){p++,r+=f;continue}if(f==="]"){p=Math.max(0,p-1),r+=f;continue}if(f==="{"){d++,r+=f;continue}if(f==="}"){d=Math.max(0,d-1),r+=f;continue}if(f===","&&s===0&&p===0&&d===0){N();continue}r+=f;}return r.length&&N(),T.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(z(c))return C(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 R(g)}catch{}return g})}function et(t,n){if(!Number.isInteger(n)||n<=0)return [];let r=[],e=0;for(;e<t.length;)r.push(t.slice(e,e+n)),e+=n;return r}function C(t){switch(true){case E(t):return t;case k(t):return true;case U(t):return false;case(a(t)&&["true","1","yes","on"].includes(String(t??"").trim().toLowerCase())):return true;case(a(t)&&["false","0","no","off"].includes(String(t??"").trim().toLowerCase())):return false}return false}async function ut(t=0){await new Promise(n=>setTimeout(()=>n(true),t));}function ct(t=1,n=new Date){let r=Math.min(60,Math.max(1,Math.trunc(Math.abs(t)))),e=n.getMinutes(),i=Math.floor(e/r)*r,o=new Date(n);return o.setMinutes(i,0,0),o}function mt(t=new Date){let n=d=>String(d).padStart(2,"0"),r=t.getFullYear(),e=n(t.getMonth()+1),i=n(t.getDate()),o=n(t.getHours()),s=n(t.getMinutes()),p=n(t.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${p}`}function pt(t){let{days:n=0,hours:r=0,minutes:e=0,seconds:i=0}=t;return n*86400+r*3600+e*60+i}function gt(t){if(!Number.isFinite(t)||t<0)throw new Error("Invalid total seconds");let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),e=Math.floor(t%3600/60),i=t%60;return {days:n,hours:r,minutes:e,seconds:i}}function ht(t){let n=t.split(".").map(o=>Number(o));if(n.length!==4||n.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,n[i]),i++;return e.getUint32(0,false)}function kt(t){if(!k(t))return "";let n=new ArrayBuffer(4),r=new DataView(n);r.setUint32(0,t,false);let e=[],i=0;for(;i<4;)e.push(r.getUint8(i)),i++;return e.join(".")}function F(t){return Array.isArray(t)}function J(t){return F(t)&&t.length>0}function E(t){return typeof t=="boolean"}function Dt(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(u(t)||l(t)){let n=new Date(t);return !Number.isNaN(n.getTime())}return false}var K=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function It(t){return a(t)?K.test(t):false}function Bt(t){return t!=null}function A(t){return typeof t=="function"}var X=/^(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 Ct(t){if(!u(t))return false;let n=t.trim();return X.test(n)}function Wt(t){return u(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function l(t){return typeof t=="number"&&Number.isFinite(t)}function Vt(t){return l(t)&&!Number.isInteger(t)}function Gt(t){return l(t)&&t<0}function U(t){return l(t)&&t<=0}function k(t){return l(t)&&t>0}function Z(t){return l(t)&&t>=0}function O(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function V(t){return O(t)&&Object.keys(t).length>0}function sn(t,{minLength:n=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:s=true}={}){return !(!u(t)||t.length<n||t.length>r||e&&!/[A-ZА-Я]/.test(t)||i&&!/[a-zа-я]/.test(t)||o&&!/\d/.test(t)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function cn(t){if(!a(t)&&!l(t))return false;let n=String(t).trim();return !(n.startsWith("-")||(n.match(/\+/g)||[]).length>1||n.includes("+")&&!n.startsWith("+")||!/^\+?[0-9-]+$/.test(n)||n.length<3||n.length>20||!/[0-9]$/.test(n)||n.includes("--"))}function u(t){return typeof t=="string"}function z(t){if(!a(t))return false;let n=t.trim().toLowerCase();return n==="true"||n==="false"}function a(t){return u(t)&&t.trim().length>0}function hn(t){if(!a(t))return false;let n=t.trim().toLowerCase();return n==="asc"||n==="desc"}function Sn(t){return u(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function bn(t){return A(t)&&/^class\s/.test(Function.prototype.toString.call(t))}var v=/^(['"`])([\s\S]*)\1$/;function I(t,n){let r=t.trim(),e=_(r);if(e.ok)return e.value;let i=v.exec(r);return i?i[2]:n?r:null}function _(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function R(t,n=false){if(t===null||l(t)||E(t))return t;if(J(t)){let r=t,e=[];for(let i of r)a(i)?e.push(I(String(i),n)):e.push(i);return e}if(V(t)){let r=t,e={};for(let i of Object.keys(r)){let o=r[i];a(o)?e[i]=I(String(o),n):e[i]=o;}return e}return F(t)||O(t)?t:a(t)?I(String(t),n):null}function Bn(t){try{return O(t)||F(t)?JSON.stringify(t):""}catch{}return ""}function Q(t){let n=t.sign<0?"-":"",r=t.digitsInteger.toString();if(t.scale===0)return n+r;let e=t.scale-r.length;if(e>=0)return n+"0."+"0".repeat(e)+r;let i=r.length-t.scale,o=r.slice(0,i),s=r.slice(i);return n+o+"."+s}function G(t){return Number(Q(t))}function j(t,n){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,s]=n.split(/e/i),[p,d=""]=o.split("."),T=p.replace(/^0+/,"")+d,N=parseInt(s,10)-d.length;return `${T||"0"}e${N}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(Z(i))return e=e+"0".repeat(i),{sign:t,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let s="0".repeat(o-e.length);return {sign:t,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-o;return {sign:t,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function H(t){if(typeof t=="bigint"){let n=t<0n?-1:1,r=(t<0n?-t:t).toString();return {sign:n,integerPart:r,fractionalPart:""}}if(typeof t=="number"){if(!Number.isFinite(t))throw new Error("Input number is not finite.");let n=t<0?-1:1,e=Math.abs(t).toExponential(30);return j(n,e)}if(typeof t=="string"){let n=t.trim().replace(",",".");if(!n)throw new Error("Input string is empty.");let r=1;if((n.startsWith("+")||n.startsWith("-"))&&(r=n.startsWith("-")?-1:1,n=n.slice(1)),/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(n)){if(/e/i.test(n))return j(r,n);let[e="0",i=""]=n.split(".");return {sign:r,integerPart:e,fractionalPart:i}}throw new Error("Invalid numeric string.")}throw new Error("Unsupported input type.")}function $(t){let{sign:n,integerPart:r,fractionalPart:e}=H(t),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),s=i+o||"0";return {sign:n,digitsInteger:BigInt(s),scale:o.length}}function Y(t,n,r="half-up"){let e=Math.max(0,Math.trunc(n));if(t.scale<=e)return {...t};let i=t.scale-e,o=10n**BigInt(i),s=t.digitsInteger/o,p=t.digitsInteger%o;if(r==="trunc"||p===0n)return {sign:t.sign,digitsInteger:s,scale:e};let d=o/2n,N=p>=d?s+1n:s;return {sign:t.sign,digitsInteger:N,scale:e}}function W(t,n=1,r=false){try{return G(n>1?Y($(t),n,"half-up"):$(t))}catch(e){if(r)throw e}return 0}function q(t){if(!u(t))return "";let n=w(t);return a(n)?n.toLowerCase():""}function Xn(t){if(!u(t))return "";let n=q(t);return a(n)?n[0].toUpperCase()+n.slice(1):""}function rr(t){return u(t)&&w(t)===""||t===void 0?null:t}function or(t,n="+7"){if(!u(t))return null;let r=w(t).replace(/[\s\-().]/g,"");return /^00\d{8,15}$/.test(r)?r="+"+r.slice(2):/^\d{10}$/.test(r)?r=n+r:/^\d{9,15}$/.test(r)&&!r.startsWith("0")&&(r="+"+r),/^\+\d{10,15}$/.test(r)?r:null}function w(t){return String(u(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"")}function mr(t){return u(t)&&w(t)===""||t===null?void 0:t}var dr=t=>{if(!u(t))return t;let n=String(w(t)||"");return n===""?null:n.toLowerCase()};function xr(t=""){return {}}function h(t,n){let r=new Error(n??t);return r.code=t,r}var L=null;async function kr(t,n,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:p=0,halfCloseAfterWrite:d=false,lineTerminator:T=""}={}){if(!(typeof process<"u"&&!!process.versions?.node))throw h("ENODEONLY","connectTCP is Node-only");if(!a(n))throw h("EBADHOST","`host` must be a non-empty string");if(!a(t))throw h("EBADMSG","`message` must be a non-empty string");if(!k(r)||r<1||r>65535)throw h("EBADPORT","`port` must be an integer in range 1..65535");let c=o.toLowerCase()==="utf-8"?"utf8":o;if(!L)try{L=await import('net');}catch{}if(!L)throw h("ENETIMPORT","FATAL: node:net import failed");return new Promise((f,g)=>{let m=new L.Socket,P=false,D=0,y=null,M=()=>{m.destroyed||m.destroy(h("EABORT","Operation cancelled")),S(h("EABORT","Operation cancelled"));},S=(x,b)=>{P||(P=true,m.removeAllListeners(),s&&s.removeEventListener("abort",M),m.destroyed||m.destroy(),y&&clearTimeout(y),x?g(x):f(b??""));};if(s){if(s.aborted)return S(h("EABORT","Operation cancelled"));s.addEventListener("abort",M,{once:true});}k(i)&&(y=setTimeout(()=>S(h("ETIMEDOUT","Connect timed out")),i),y&&A(y.unref)&&y.unref()),k(e)&&(m.setTimeout(e),m.once("timeout",()=>S(h("ETIMEDOUT","Idle timeout"))));let B=[];m.on("data",x=>{if(P)return;let b=Buffer.isBuffer(x)?x:Buffer.from(x,c);if(k(p)&&D+b.length>p)return S(h("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));B.push(b),D+=b.length;}),m.once("end",()=>{if(P)return;let x=Buffer.concat(B,D).toString(c);S(void 0,x);}),m.once("close",x=>{if(P)return;let b=Buffer.concat(B,D).toString(c);x?S(h("ECLOSE","Socket closed with error")):S(void 0,b);}),m.once("error",x=>{P||S(x);}),m.once("connect",()=>{y&&(clearTimeout(y),y=null);let x=T?t+T:t;m.write(x,c)?d&&m.end():m.once("drain",()=>{d&&!P&&m.end();});}),m.connect({host:n,port:r});})}export{nt as arrFuncArgs,et as arrSplitPortions,C as boolNormalize,ct as dateFloorMin,pt as datePartsSec,gt as dateSecParts,mt as dateStr,kt as ipNumStr,ht as ipStrNum,F as isArr,J as isArrFilled,E as isBool,bn as isClass,Dt as isDate,It as isEmail,Bt as isExists,A as isFunc,Ct as isIpAddr,Wt as isMacAddr,l as isNum,Vt as isNumFloat,Gt as isNumN,U as isNumNZ,k as isNumP,Z as isNumPZ,O as isObj,V as isObjFilled,sn as isPassword,cn as isPhone,u as isStr,hn as isStrAscDesc,z as isStrBool,a as isStrFilled,Sn as isVar,R as jsonDecode,Bn as jsonEncode,_ as jsonParse,I as jsonStrLike,kr as netTCP,W as numNormalize,q as strLowerCase,Xn as strNormalCase,dr as strNormalize,rr as strNull,or as strPhone,w as strTrim,mr as strUndefined,xr as urlObj,ut as wait};//# sourceMappingURL=node.mjs.map
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
2
2
  //# sourceMappingURL=node.mjs.map