full-utils 3.0.1 → 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 +18 -14
- package/dist/index.d.ts +18 -14
- 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, PasswordOptions, TimeParts, arrFuncArgs, arrSplitPortions, boolNormalize, dateFloorMin, datePartsSec, dateSecParts, dateStr,
|
|
1
|
+
export { JSONLike, PasswordOptions, TimeParts, arrFuncArgs, arrSplitPortions, 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,
|
|
1
|
+
export { JSONLike, PasswordOptions, TimeParts, arrFuncArgs, arrSplitPortions, 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,k=[],N=()=>{let c=r.trim();c!==""&&k.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(),k.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 T(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 Tt(t){if(!T(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 T(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("."),k=p.replace(/^0+/,"")+d,N=parseInt(s,10)-d.length;return `${k||"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 Tr(t,n,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:p=0,halfCloseAfterWrite:d=false,lineTerminator:k=""}={}){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(!T(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});}T(i)&&(y=setTimeout(()=>S(h("ETIMEDOUT","Connect timed out")),i),y&&A(y.unref)&&y.unref()),T(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(T(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=k?t+k: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,or as formatToPhone,Tt 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,T 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,Tr as netTCP,W as numNormalize,q as strLowerCase,Xn as strNormalCase,dr as strNormalize,rr as strNull,w as strTrim,mr as strUndefined,xr as urlObj,ut as wait};//# sourceMappingURL=node.mjs.map
|
|
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,m=0,d=0,k=[],b=()=>{let c=r.trim();c!==""&&k.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==="["){m++,r+=f;continue}if(f==="]"){m=Math.max(0,m-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&&m===0&&d===0){b();continue}r+=f;}return r.length&&b(),k.map(c=>{if(c.startsWith("$")&&c.includes("(")&&c.endsWith(")"))return c;if(c==="null")return null;if(c==="undefined")return;if(M(c))return R(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 z(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 R(t){switch(true){case E(t):return t;case T(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){return process.env[t]}function mt(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 pt(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()),m=n(t.getSeconds());return `${r}-${e}-${i} ${o}:${s}:${m}`}function gt(t){let{days:n=0,hours:r=0,minutes:e=0,seconds:i=0}=t;return n*86400+r*3600+e*60+i}function ht(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 yt(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 Nt(t){if(!T(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 _(t){return F(t)&&t.length>0}function E(t){return typeof t=="boolean"}function At(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(u(t)||p(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 Bt(t){return a(t)?K.test(t):false}function $t(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 zt(t){if(!u(t))return false;let n=t.trim();return X.test(n)}function _t(t){return u(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function p(t){return typeof t=="number"&&Number.isFinite(t)}function Qt(t){return p(t)&&!Number.isInteger(t)}function Yt(t){return p(t)&&t<0}function U(t){return p(t)&&t<=0}function T(t){return p(t)&&t>0}function J(t){return p(t)&&t>=0}function O(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function Z(t){return O(t)&&Object.keys(t).length>0}function fn(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 mn(t){if(!a(t)&&!p(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 M(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 yn(t){if(!a(t))return false;let n=t.trim().toLowerCase();return n==="asc"||n==="desc"}function kn(t){return u(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function Pn(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=V(r);if(e.ok)return e.value;let i=v.exec(r);return i?i[2]:n?r:null}function V(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function z(t,n=false){if(t===null||p(t)||E(t))return t;if(_(t)){let r=t,e=[];for(let i of r)a(i)?e.push(I(String(i),n)):e.push(i);return e}if(Z(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 $n(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 H(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),[m,d=""]=o.split("."),k=m.replace(/^0+/,"")+d,b=parseInt(s,10)-d.length;return `${k||"0"}e${b}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if(J(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 G(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}=G(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,m=t.digitsInteger%o;if(r==="trunc"||m===0n)return {sign:t.sign,digitsInteger:s,scale:e};let d=o/2n,b=m>=d?s+1n:s;return {sign:t.sign,digitsInteger:b,scale:e}}function W(t,n=1,r=false){try{return H(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 tr(t){if(!u(t))return "";let n=q(t);return a(n)?n[0].toUpperCase()+n.slice(1):""}function ir(t){return u(t)&&w(t)===""||t===void 0?null:t}function ur(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,n=""){let r=String(u(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return n?r.split(n).filter(e=>!!e).join(n):r}function pr(t){return u(t)&&w(t)===""||t===null?void 0:t}var xr=t=>{if(!u(t))return t;let n=String(w(t)||"");return n===""?null:String(n.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function wr(t=""){return {}}function Tr(t){if(!a(t))return String(t);let n="____RAW_PERCENT____",r=t.replace(/%(?![0-9A-Fa-f]{2})/g,n),e=new Set(["22","7B","7D","3A","2C","5B","5D","5C"]);return r.replace(/%([0-9A-Fa-f]{2})/g,(o,s)=>{let m=s.toUpperCase();return e.has(m)?decodeURIComponent(`%${m}`):`%${m}`}).split(n).join("%")}function h(t,n){let r=new Error(n??t);return r.code=t,r}var L=null;async function Fr(t,n,{port:r=4028,timeoutMs:e=0,connectTimeoutMs:i=0,encoding:o="utf8",signal:s,maxBytes:m=0,halfCloseAfterWrite:d=false,lineTerminator:k=""}={}){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(!T(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 l=new L.Socket,P=false,D=0,y=null,C=()=>{l.destroyed||l.destroy(h("EABORT","Operation cancelled")),S(h("EABORT","Operation cancelled"));},S=(x,N)=>{P||(P=true,l.removeAllListeners(),s&&s.removeEventListener("abort",C),l.destroyed||l.destroy(),y&&clearTimeout(y),x?g(x):f(N??""));};if(s){if(s.aborted)return S(h("EABORT","Operation cancelled"));s.addEventListener("abort",C,{once:true});}T(i)&&(y=setTimeout(()=>S(h("ETIMEDOUT","Connect timed out")),i),y&&A(y.unref)&&y.unref()),T(e)&&(l.setTimeout(e),l.once("timeout",()=>S(h("ETIMEDOUT","Idle timeout"))));let B=[];l.on("data",x=>{if(P)return;let N=Buffer.isBuffer(x)?x:Buffer.from(x,c);if(T(m)&&D+N.length>m)return S(h("ERESPONSE_TOO_LARGE","Response exceeds maxBytes"));B.push(N),D+=N.length;}),l.once("end",()=>{if(P)return;let x=Buffer.concat(B,D).toString(c);S(void 0,x);}),l.once("close",x=>{if(P)return;let N=Buffer.concat(B,D).toString(c);x?S(h("ECLOSE","Socket closed with error")):S(void 0,N);}),l.once("error",x=>{P||S(x);}),l.once("connect",()=>{y&&(clearTimeout(y),y=null);let x=k?t+k:t;l.write(x,c)?d&&l.end():l.once("drain",()=>{d&&!P&&l.end();});}),l.connect({host:n,port:r});})}export{nt as arrFuncArgs,et as arrSplitPortions,R as boolNormalize,mt as dateFloorMin,gt as datePartsSec,ht as dateSecParts,pt as dateStr,ct as env,Nt as ipNumStr,yt as ipStrNum,F as isArr,_ as isArrFilled,E as isBool,Pn as isClass,At as isDate,Bt as isEmail,$t as isExists,A as isFunc,zt as isIpAddr,_t as isMacAddr,p as isNum,Qt as isNumFloat,Yt as isNumN,U as isNumNZ,T as isNumP,J as isNumPZ,O as isObj,Z as isObjFilled,fn as isPassword,mn as isPhone,u as isStr,yn as isStrAscDesc,M as isStrBool,a as isStrFilled,kn as isVar,z as jsonDecode,$n as jsonEncode,V as jsonParse,I as jsonStrLike,Fr as netTCP,W as numNormalize,q as strLowerCase,tr as strNormalCase,xr as strNormalize,ir as strNull,ur as strPhone,w as strTrim,pr as strUndefined,Tr as urlDecode,wr as urlObj,ut as wait};//# sourceMappingURL=node.mjs.map
|
|
2
2
|
//# sourceMappingURL=node.mjs.map
|