full-utils 2.0.3 → 2.0.5

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/index.d.cts CHANGED
@@ -62,36 +62,36 @@
62
62
  *
63
63
  * @example
64
64
  * // Basic values
65
- * formatStrToFuncArgs('1, true, "hello"'); // => [1, true, "hello"]
65
+ * formatStrToFuncArgsArr('1, true, "hello"'); // => [1, true, "hello"]
66
66
  *
67
67
  * @example
68
68
  * // Bracket-wrapped list
69
- * formatStrToFuncArgs('[1, 2, 3]'); // => [1, 2, 3]
69
+ * formatStrToFuncArgsArr('[1, 2, 3]'); // => [1, 2, 3]
70
70
  *
71
71
  * @example
72
72
  * // Nested structures and quoting
73
- * formatStrToFuncArgs('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
73
+ * formatStrToFuncArgsArr('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
74
74
  *
75
75
  * @example
76
76
  * // Booleans, null/undefined, and Infinity
77
- * formatStrToFuncArgs('yes, NO, null, undefined, Infinity, -Infinity');
77
+ * formatStrToFuncArgsArr('yes, NO, null, undefined, Infinity, -Infinity');
78
78
  * // => [true, false, null, undefined, Infinity, -Infinity]
79
79
  *
80
80
  * @example
81
81
  * // Macro-like token (returned as-is)
82
- * formatStrToFuncArgs('$env(PATH)'); // => ["$env(PATH)"]
82
+ * formatStrToFuncArgsArr('$env(PATH)'); // => ["$env(PATH)"]
83
83
  *
84
84
  * @example
85
85
  * // Escapes inside quotes
86
- * formatStrToFuncArgs('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
86
+ * formatStrToFuncArgsArr('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
87
87
  * // => ['He said: "Hi"', "It's ok", "\\path"]
88
88
  *
89
89
  * @example
90
90
  * // Empty and whitespace inputs
91
- * formatStrToFuncArgs(' '); // => []
92
- * formatStrToFuncArgs('[]'); // => []
93
- * formatStrToFuncArgs('[ ]'); // => []
94
- * formatStrToFuncArgs(' [ a , b ] '); // => ["a", "b"]
91
+ * formatStrToFuncArgsArr(' '); // => []
92
+ * formatStrToFuncArgsArr('[]'); // => []
93
+ * formatStrToFuncArgsArr('[ ]'); // => []
94
+ * formatStrToFuncArgsArr(' [ a , b ] '); // => ["a", "b"]
95
95
  *
96
96
  * @param value - Raw string containing comma-separated arguments.
97
97
  * If `value` is **not** a string, the function returns `[value]` unchanged.
@@ -106,7 +106,7 @@
106
106
  * @public
107
107
  * @since 2.0.0
108
108
  */
109
- declare function formatStrToFuncArgs(value: string): unknown[];
109
+ declare function formatStrToFuncArgsArr(value: string): unknown[];
110
110
 
111
111
  /**
112
112
  * Splits an input array into smaller subarrays (portions) of a given fixed size.
@@ -2828,6 +2828,8 @@ declare function isStrAscDesc(value: unknown): value is 'asc' | 'desc';
2828
2828
  */
2829
2829
  declare function isVar(value: unknown): value is string;
2830
2830
 
2831
+ declare function isClass(value: unknown): boolean;
2832
+
2831
2833
  /**
2832
2834
  * Structural JSON-like type used throughout decoding.
2833
2835
  *
@@ -4494,4 +4496,4 @@ declare function toH(value: any, unit?: string): number;
4494
4496
  */
4495
4497
  declare function extractHost(value?: string): string;
4496
4498
 
4497
- export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgs, formatToBool, formatToLowerCase, formatToNormalCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, isArr, isArrFilled, isBool, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };
4499
+ export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgsArr, formatToBool, formatToLowerCase, formatToNormalCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, 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, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };
package/dist/index.d.ts CHANGED
@@ -62,36 +62,36 @@
62
62
  *
63
63
  * @example
64
64
  * // Basic values
65
- * formatStrToFuncArgs('1, true, "hello"'); // => [1, true, "hello"]
65
+ * formatStrToFuncArgsArr('1, true, "hello"'); // => [1, true, "hello"]
66
66
  *
67
67
  * @example
68
68
  * // Bracket-wrapped list
69
- * formatStrToFuncArgs('[1, 2, 3]'); // => [1, 2, 3]
69
+ * formatStrToFuncArgsArr('[1, 2, 3]'); // => [1, 2, 3]
70
70
  *
71
71
  * @example
72
72
  * // Nested structures and quoting
73
- * formatStrToFuncArgs('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
73
+ * formatStrToFuncArgsArr('{"a":1,"b":[2,3]}, "te,xt", (x,y)'); // => [ {a:1,b:[2,3]}, "te,xt", "(x,y)" ]
74
74
  *
75
75
  * @example
76
76
  * // Booleans, null/undefined, and Infinity
77
- * formatStrToFuncArgs('yes, NO, null, undefined, Infinity, -Infinity');
77
+ * formatStrToFuncArgsArr('yes, NO, null, undefined, Infinity, -Infinity');
78
78
  * // => [true, false, null, undefined, Infinity, -Infinity]
79
79
  *
80
80
  * @example
81
81
  * // Macro-like token (returned as-is)
82
- * formatStrToFuncArgs('$env(PATH)'); // => ["$env(PATH)"]
82
+ * formatStrToFuncArgsArr('$env(PATH)'); // => ["$env(PATH)"]
83
83
  *
84
84
  * @example
85
85
  * // Escapes inside quotes
86
- * formatStrToFuncArgs('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
86
+ * formatStrToFuncArgsArr('"He said: \\"Hi\\"", \'It\\\'s ok\', "\\\\path"');
87
87
  * // => ['He said: "Hi"', "It's ok", "\\path"]
88
88
  *
89
89
  * @example
90
90
  * // Empty and whitespace inputs
91
- * formatStrToFuncArgs(' '); // => []
92
- * formatStrToFuncArgs('[]'); // => []
93
- * formatStrToFuncArgs('[ ]'); // => []
94
- * formatStrToFuncArgs(' [ a , b ] '); // => ["a", "b"]
91
+ * formatStrToFuncArgsArr(' '); // => []
92
+ * formatStrToFuncArgsArr('[]'); // => []
93
+ * formatStrToFuncArgsArr('[ ]'); // => []
94
+ * formatStrToFuncArgsArr(' [ a , b ] '); // => ["a", "b"]
95
95
  *
96
96
  * @param value - Raw string containing comma-separated arguments.
97
97
  * If `value` is **not** a string, the function returns `[value]` unchanged.
@@ -106,7 +106,7 @@
106
106
  * @public
107
107
  * @since 2.0.0
108
108
  */
109
- declare function formatStrToFuncArgs(value: string): unknown[];
109
+ declare function formatStrToFuncArgsArr(value: string): unknown[];
110
110
 
111
111
  /**
112
112
  * Splits an input array into smaller subarrays (portions) of a given fixed size.
@@ -2828,6 +2828,8 @@ declare function isStrAscDesc(value: unknown): value is 'asc' | 'desc';
2828
2828
  */
2829
2829
  declare function isVar(value: unknown): value is string;
2830
2830
 
2831
+ declare function isClass(value: unknown): boolean;
2832
+
2831
2833
  /**
2832
2834
  * Structural JSON-like type used throughout decoding.
2833
2835
  *
@@ -4494,4 +4496,4 @@ declare function toH(value: any, unit?: string): number;
4494
4496
  */
4495
4497
  declare function extractHost(value?: string): string;
4496
4498
 
4497
- export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgs, formatToBool, formatToLowerCase, formatToNormalCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, isArr, isArrFilled, isBool, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };
4499
+ export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgsArr, formatToBool, formatToLowerCase, formatToNormalCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined, ipAddrToNum, 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, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- function ot(t){if(!m(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,s=0,p=0,d=0,h=[],x=()=>{let u=n.trim();u!==""&&h.push(u),n="";};for(let u=0;u<r.length;u++){let f=r[u];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==="("){s++,n+=f;continue}if(f===")"){s=Math.max(0,s-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===","&&s===0&&p===0&&d===0){x();continue}n+=f;}return n.length&&x(),h.map(u=>{if(u.startsWith("$")&&u.includes("(")&&u.endsWith(")"))return u;if(u==="null")return null;if(u==="undefined")return;if(E(u))return $(u);let f=w(u);if(Number.isFinite(f))return f;if(u==="Infinity")return 1/0;if(u==="-Infinity")return -1/0;let l=String(u||"");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 B(l)}catch{}return l})}function st(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 $(t){switch(true){case y(t):return t;case F(t):return true;case R(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 ct(t=0){await new Promise(r=>setTimeout(()=>r(true),t));}function pt(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 dt(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()),s=r(t.getMinutes()),p=r(t.getSeconds());return `${n}-${e}-${o} ${i}:${s}:${p}`}function xt(t){let{days:r=0,hours:n=0,minutes:e=0,seconds:o=0}=t;return r*86400+n*3600+e*60+o}function wt(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 M(t){let[r,n]=t.split("/"),e=b(r),o=n?Number(n):NaN;if(e===null||!Number.isInteger(o)||o<0||o>32)return null;let i=o===0?0:4294967295<<32-o>>>0,s=e&i,p=s|~i>>>0;return [N(s),N(p)]}function Nt(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 It(t){if(!F(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 b(t){if(!m(t))return null;let r=g(t).split(".");if(r.length!==4)return null;let n=0;for(let e=0;e<4;e++){if(!/^\d{1,3}$/.test(r[e]))return null;let o=Number(r[e]);if(o<0||o>255)return null;n=n<<8|o;}return n>>>0}function*j(t,r,n={}){let{includeNetwork:e=true,includeBroadcast:o=true}=n,i,s,p=false,d=null;if(r===void 0&&t.includes("/")){let u=M(t);if(!u)throw new Error(`Invalid CIDR: "${t}"`);let[f,l]=u,[D,Q]=t.split("/");d=Number(Q),i=b(f),s=b(l),p=true;}else {let u=b(t);if(u===null)throw new Error(`Invalid IPv4: "${t}"`);if(i=u,r&&r.trim()!==""){let f=b(r);if(f===null)throw new Error(`Invalid IPv4: "${r}"`);s=f;}else {let f=i>>>24&255,l=i>>>16&255,D=i>>>8&255;s=(f<<24|l<<16|D<<8|255)>>>0;}}i>s&&([i,s]=[s,i]);let h=-1,x=-1;p&&d!==null&&d<=30&&(h=i,x=s);for(let u=i;u<=s;u=u+1>>>0){if(!e&&u===h){if(u===s)break;continue}if(!o&&u===x){if(u===s)break;continue}if(yield N(u),u===4294967295)break}}function Mt(t,r,n={}){let{limit:e=1e6}=n,o=[],i=0;for(let s of j(t,r,n)){if(i>=e)throw new Error(`Range is too large (> ${e}). Use the generator version instead.`);o.push(s),i++;}return o}function N(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new Error(`Invalid IPv4 number: ${t}`);return [t>>>24&255,t>>>16&255,t>>>8&255,t&255].join(".")}function k(t){return Array.isArray(t)}function L(t){return k(t)&&t.length>0}function y(t){return typeof t=="boolean"}function Zt(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(m(t)||c(t)){let r=new Date(t);return !Number.isNaN(r.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 Ht(t){return a(t)?K.test(t):false}function Qt(t){return t!=null}function qt(t){return typeof t=="function"}var q=/^(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 vt(t){if(!m(t))return false;let r=t.trim();return q.test(r)}function nr(t){return m(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function c(t){return typeof t=="number"&&Number.isFinite(t)}function sr(t){return c(t)&&!Number.isInteger(t)}function mr(t){return c(t)&&t<0}function R(t){return c(t)&&t<=0}function F(t){return c(t)&&t>0}function C(t){return c(t)&&t>=0}function T(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function z(t){return T(t)&&Object.keys(t).length>0}function Tr(t,{minLength:r=8,maxLength:n=256,requireUppercase:e=true,requireLowercase:o=true,requireDigit:i=true,requireSpecial:s=true}={}){return !(!m(t)||t.length<r||t.length>n||e&&!/[A-ZА-Я]/.test(t)||o&&!/[a-zа-я]/.test(t)||i&&!/\d/.test(t)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function yr(t){if(!a(t)&&!c(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 m(t){return typeof t=="string"}function E(t){if(!a(t))return false;let r=t.trim().toLowerCase();return r==="true"||r==="false"}function a(t){return m(t)&&t.trim().length>0}function Er(t){if(!a(t))return false;let r=t.trim().toLowerCase();return r==="asc"||r==="desc"}function Mr(t){return m(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}var Y=/^(['"`])([\s\S]*)\1$/;function P(t,r){let n=t.trim(),e=W(n);if(e.ok)return e.value;let o=Y.exec(n);return o?o[2]:r?n:null}function W(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function B(t,r=false){if(t===null||c(t)||y(t))return t;if(L(t)){let n=t,e=[];for(let o of n)a(o)?e.push(P(String(o),r)):e.push(o);return e}if(z(t)){let n=t,e={};for(let o of Object.keys(n)){let i=n[o];a(i)?e[o]=P(String(i),r):e[o]=i;}return e}return k(t)||T(t)?t:a(t)?P(String(t),r):null}function Gr(t){try{return T(t)||k(t)?JSON.stringify(t):""}catch{}return ""}function Vr(t,r){let n=Math.trunc(r);if(n===0)return {...t};if(n>0)return {sign:t.sign,digitsInteger:t.digitsInteger,scale:t.scale+n};let e=10n**BigInt(-n);return {sign:t.sign,digitsInteger:t.digitsInteger*e,scale:t.scale+n}}function A(t,r){let n=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[i,s]=r.split(/e/i),[p,d=""]=i.split("."),h=p.replace(/^0+/,"")+d,x=parseInt(s,10)-d.length;return `${h||"0"}e${x}`})());if(!n)throw new Error("Failed to parse exponential notation.");let e=n[1],o=parseInt(n[3],10);if(C(o))return e=e+"0".repeat(o),{sign:t,integerPart:e||"0",fractionalPart:""};{let i=-o;if(i>=e.length){let s="0".repeat(i-e.length);return {sign:t,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-i;return {sign:t,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function J(t){return Number(U(t))}function U(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),s=n.slice(o);return r+i+"."+s}function w(t,r=1,n=false){try{return J(r>1?Z(O(t),r,"half-up"):O(t))}catch(e){if(n)throw e}return 0}function _(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 A(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 A(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 O(t){let{sign:r,integerPart:n,fractionalPart:e}=_(t),o=n.replace(/^0+/,"")||"0",i=e.replace(/0+$/,""),s=o+i||"0";return {sign:r,digitsInteger:BigInt(s),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),s=t.digitsInteger/i,p=t.digitsInteger%i;if(n==="trunc"||p===0n)return {sign:t.sign,digitsInteger:s,scale:e};let d=i/2n,x=p>=d?s+1n:s;return {sign:t.sign,digitsInteger:x,scale:e}}function G(t){if(!m(t))return "";let r=g(t);return a(r)?r.toLowerCase():""}function an(t){if(!m(t))return "";let r=G(t);return a(r)?r[0].toUpperCase()+r.slice(1):""}function gn(t){return m(t)&&g(t)===""||t===void 0?null:t}function wn(t,r="+7"){if(!m(t))return null;let n=g(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 g(t){return String(m(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"")}function yn(t){return m(t)&&g(t)===""||t===null?void 0:t}var X=1024,H=X*1024,S=H*1024,V=S*1024,v=V*1024;function In(t,r=""){let n=w(t);if(!c(n))throw new Error(`toGB: value "${t}" is not numeric`);let e=String(r).trim().toLowerCase().replace(/\s+/g,""),o=e?e[0]:"g",i;switch(o){case "b":i=n/S;break;case "k":i=n/H;break;case "m":i=n/S;break;case "g":i=n;break;case "t":i=n*(V/S);break;case "p":i=n*(v/S);break;default:i=n;break}if(!c(i))throw new Error(`toGB: result is not finite (value="${t}", unit="${r}")`);return Object.is(i,-0)?0:i}function I(t){return String(t).trim().toLowerCase().replace(/\s+/g,"").replace(/(?:\/?s|hash(?:es)?)$/i,"")}var tt={h:1e-9,k:1e-6,m:.001,g:1,t:1e3,p:1e6,e:1e9};function En(t,r=""){let n=w(t);if(!c(n))return 0;let e=I(r),o=e?e[0]:"g",i=tt[o]??1,s=n*i;if(!c(s))throw new Error(`toGH: result is not finite (value="${n}", unit="${e}")`);return Object.is(s,-0)?0:s}var rt={h:1,k:1e3,m:1e6,g:1e9,t:1e12,p:1e15,e:1e18};function jn(t,r=""){let n=w(t);if(!c(n))return 0;let e=I(r),o=e?e[0]:"h",i=rt[o]??1,s=n*i;if(!c(s))throw new Error(`toH: result is not finite (value="${n}", unit="${e}")`);return Object.is(s,-0)?0:s}var nt=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function zn(t=""){if(!a(t))return "";let r=t.trim(),n=nt.test(r)?r:`http://${r}`;try{return new URL(n).hostname}catch{let o=(r.split("@").pop()||r).split(/[/?#]/,1)[0],i=o.match(/^\[([^\]]+)\]/);return i?i[1]:o.split(":",1)[0]||""}}
2
- export{Vr as changeFixedDecimalScale,M as cidrToRange,A as convertExponentialToParts,zn as extractHost,J as fixedDecimalToNum,U as fixedDecimalToStr,pt as floorDateToMinutes,dt as formatDateToString,ot as formatStrToFuncArgs,$ as formatToBool,G as formatToLowerCase,an as formatToNormalCase,gn as formatToNull,w as formatToNum,wn as formatToPhone,g as formatToTrim,yn as formatToUndefined,Nt as ipAddrToNum,k as isArr,L as isArrFilled,y as isBool,Zt as isDate,Ht as isEmail,Qt as isExists,qt as isFunc,vt as isIpAddr,nr as isMacAddr,c as isNum,sr as isNumFloat,mr as isNumN,R as isNumNZ,F as isNumP,C as isNumPZ,T as isObj,z as isObjFilled,Tr as isPassword,yr as isPhone,m as isStr,Er as isStrAscDesc,E as isStrBool,a as isStrFilled,Mr as isVar,B as jsonDecode,Gr as jsonEncode,_ as normalizeToDecimalComponents,It as numToIpAddr,b as parseIPv4,P as parseStringLike,O as parseToFixedDecimal,xt as partsToSeconds,j as rangeIPv4,Mt as rangeIPv4ToArr,Z as roundFixedDecimal,wt as secondsToParts,st as splitArrToPortions,In as toGB,En as toGH,jn as toH,N as toIPv4,W as tryParseJSON,ct as wait};//# sourceMappingURL=index.mjs.map
1
+ function it(t){if(!m(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,s=0,p=0,d=0,h=[],x=()=>{let u=n.trim();u!==""&&h.push(u),n="";};for(let u=0;u<r.length;u++){let f=r[u];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==="("){s++,n+=f;continue}if(f===")"){s=Math.max(0,s-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===","&&s===0&&p===0&&d===0){x();continue}n+=f;}return n.length&&x(),h.map(u=>{if(u.startsWith("$")&&u.includes("(")&&u.endsWith(")"))return u;if(u==="null")return null;if(u==="undefined")return;if(E(u))return $(u);let f=w(u);if(Number.isFinite(f))return f;if(u==="Infinity")return 1/0;if(u==="-Infinity")return -1/0;let l=String(u||"");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 B(l)}catch{}return l})}function ut(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 $(t){switch(true){case y(t):return t;case F(t):return true;case R(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 at(t=0){await new Promise(r=>setTimeout(()=>r(true),t));}function lt(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 gt(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()),s=r(t.getMinutes()),p=r(t.getSeconds());return `${n}-${e}-${o} ${i}:${s}:${p}`}function ht(t){let{days:r=0,hours:n=0,minutes:e=0,seconds:o=0}=t;return r*86400+n*3600+e*60+o}function bt(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 M(t){let[r,n]=t.split("/"),e=b(r),o=n?Number(n):NaN;if(e===null||!Number.isInteger(o)||o<0||o>32)return null;let i=o===0?0:4294967295<<32-o>>>0,s=e&i,p=s|~i>>>0;return [N(s),N(p)]}function St(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 Dt(t){if(!F(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 b(t){if(!m(t))return null;let r=g(t).split(".");if(r.length!==4)return null;let n=0;for(let e=0;e<4;e++){if(!/^\d{1,3}$/.test(r[e]))return null;let o=Number(r[e]);if(o<0||o>255)return null;n=n<<8|o;}return n>>>0}function*j(t,r,n={}){let{includeNetwork:e=true,includeBroadcast:o=true}=n,i,s,p=false,d=null;if(r===void 0&&t.includes("/")){let u=M(t);if(!u)throw new Error(`Invalid CIDR: "${t}"`);let[f,l]=u,[D,K]=t.split("/");d=Number(K),i=b(f),s=b(l),p=true;}else {let u=b(t);if(u===null)throw new Error(`Invalid IPv4: "${t}"`);if(i=u,r&&r.trim()!==""){let f=b(r);if(f===null)throw new Error(`Invalid IPv4: "${r}"`);s=f;}else {let f=i>>>24&255,l=i>>>16&255,D=i>>>8&255;s=(f<<24|l<<16|D<<8|255)>>>0;}}i>s&&([i,s]=[s,i]);let h=-1,x=-1;p&&d!==null&&d<=30&&(h=i,x=s);for(let u=i;u<=s;u=u+1>>>0){if(!e&&u===h){if(u===s)break;continue}if(!o&&u===x){if(u===s)break;continue}if(yield N(u),u===4294967295)break}}function jt(t,r,n={}){let{limit:e=1e6}=n,o=[],i=0;for(let s of j(t,r,n)){if(i>=e)throw new Error(`Range is too large (> ${e}). Use the generator version instead.`);o.push(s),i++;}return o}function N(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new Error(`Invalid IPv4 number: ${t}`);return [t>>>24&255,t>>>16&255,t>>>8&255,t&255].join(".")}function k(t){return Array.isArray(t)}function C(t){return k(t)&&t.length>0}function y(t){return typeof t=="boolean"}function _t(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(m(t)||c(t)){let r=new Date(t);return !Number.isNaN(r.getTime())}return false}var q=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function Vt(t){return a(t)?q.test(t):false}function Kt(t){return t!=null}function L(t){return typeof t=="function"}var Y=/^(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 vt(t){if(!m(t))return false;let r=t.trim();return Y.test(r)}function nr(t){return m(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function c(t){return typeof t=="number"&&Number.isFinite(t)}function sr(t){return c(t)&&!Number.isInteger(t)}function mr(t){return c(t)&&t<0}function R(t){return c(t)&&t<=0}function F(t){return c(t)&&t>0}function z(t){return c(t)&&t>=0}function T(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function W(t){return T(t)&&Object.keys(t).length>0}function Tr(t,{minLength:r=8,maxLength:n=256,requireUppercase:e=true,requireLowercase:o=true,requireDigit:i=true,requireSpecial:s=true}={}){return !(!m(t)||t.length<r||t.length>n||e&&!/[A-ZА-Я]/.test(t)||o&&!/[a-zа-я]/.test(t)||i&&!/\d/.test(t)||s&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function yr(t){if(!a(t)&&!c(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 m(t){return typeof t=="string"}function E(t){if(!a(t))return false;let r=t.trim().toLowerCase();return r==="true"||r==="false"}function a(t){return m(t)&&t.trim().length>0}function Er(t){if(!a(t))return false;let r=t.trim().toLowerCase();return r==="asc"||r==="desc"}function Mr(t){return m(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function Lr(t){return L(t)&&/^class\s/.test(Function.prototype.toString.call(t))}var X=/^(['"`])([\s\S]*)\1$/;function P(t,r){let n=t.trim(),e=J(n);if(e.ok)return e.value;let o=X.exec(n);return o?o[2]:r?n:null}function J(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function B(t,r=false){if(t===null||c(t)||y(t))return t;if(C(t)){let n=t,e=[];for(let o of n)a(o)?e.push(P(String(o),r)):e.push(o);return e}if(W(t)){let n=t,e={};for(let o of Object.keys(n)){let i=n[o];a(i)?e[o]=P(String(i),r):e[o]=i;}return e}return k(t)||T(t)?t:a(t)?P(String(t),r):null}function Qr(t){try{return T(t)||k(t)?JSON.stringify(t):""}catch{}return ""}function qr(t,r){let n=Math.trunc(r);if(n===0)return {...t};if(n>0)return {sign:t.sign,digitsInteger:t.digitsInteger,scale:t.scale+n};let e=10n**BigInt(-n);return {sign:t.sign,digitsInteger:t.digitsInteger*e,scale:t.scale+n}}function A(t,r){let n=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[i,s]=r.split(/e/i),[p,d=""]=i.split("."),h=p.replace(/^0+/,"")+d,x=parseInt(s,10)-d.length;return `${h||"0"}e${x}`})());if(!n)throw new Error("Failed to parse exponential notation.");let e=n[1],o=parseInt(n[3],10);if(z(o))return e=e+"0".repeat(o),{sign:t,integerPart:e||"0",fractionalPart:""};{let i=-o;if(i>=e.length){let s="0".repeat(i-e.length);return {sign:t,integerPart:"0",fractionalPart:s+e}}else {let s=e.length-i;return {sign:t,integerPart:e.slice(0,s),fractionalPart:e.slice(s)}}}}function U(t){return Number(Z(t))}function Z(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),s=n.slice(o);return r+i+"."+s}function w(t,r=1,n=false){try{return U(r>1?_(O(t),r,"half-up"):O(t))}catch(e){if(n)throw e}return 0}function G(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 A(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 A(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 O(t){let{sign:r,integerPart:n,fractionalPart:e}=G(t),o=n.replace(/^0+/,"")||"0",i=e.replace(/0+$/,""),s=o+i||"0";return {sign:r,digitsInteger:BigInt(s),scale:i.length}}function _(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),s=t.digitsInteger/i,p=t.digitsInteger%i;if(n==="trunc"||p===0n)return {sign:t.sign,digitsInteger:s,scale:e};let d=i/2n,x=p>=d?s+1n:s;return {sign:t.sign,digitsInteger:x,scale:e}}function H(t){if(!m(t))return "";let r=g(t);return a(r)?r.toLowerCase():""}function dn(t){if(!m(t))return "";let r=H(t);return a(r)?r[0].toUpperCase()+r.slice(1):""}function wn(t){return m(t)&&g(t)===""||t===void 0?null:t}function Tn(t,r="+7"){if(!m(t))return null;let n=g(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 g(t){return String(m(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"")}function In(t){return m(t)&&g(t)===""||t===null?void 0:t}var v=1024,V=v*1024,S=V*1024,Q=S*1024,tt=Q*1024;function On(t,r=""){let n=w(t);if(!c(n))throw new Error(`toGB: value "${t}" is not numeric`);let e=String(r).trim().toLowerCase().replace(/\s+/g,""),o=e?e[0]:"g",i;switch(o){case "b":i=n/S;break;case "k":i=n/V;break;case "m":i=n/S;break;case "g":i=n;break;case "t":i=n*(Q/S);break;case "p":i=n*(tt/S);break;default:i=n;break}if(!c(i))throw new Error(`toGB: result is not finite (value="${t}", unit="${r}")`);return Object.is(i,-0)?0:i}function I(t){return String(t).trim().toLowerCase().replace(/\s+/g,"").replace(/(?:\/?s|hash(?:es)?)$/i,"")}var rt={h:1e-9,k:1e-6,m:.001,g:1,t:1e3,p:1e6,e:1e9};function Mn(t,r=""){let n=w(t);if(!c(n))return 0;let e=I(r),o=e?e[0]:"g",i=rt[o]??1,s=n*i;if(!c(s))throw new Error(`toGH: result is not finite (value="${n}", unit="${e}")`);return Object.is(s,-0)?0:s}var nt={h:1,k:1e3,m:1e6,g:1e9,t:1e12,p:1e15,e:1e18};function zn(t,r=""){let n=w(t);if(!c(n))return 0;let e=I(r),o=e?e[0]:"h",i=nt[o]??1,s=n*i;if(!c(s))throw new Error(`toH: result is not finite (value="${n}", unit="${e}")`);return Object.is(s,-0)?0:s}var et=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Un(t=""){if(!a(t))return "";let r=t.trim(),n=et.test(r)?r:`http://${r}`;try{return new URL(n).hostname}catch{let o=(r.split("@").pop()||r).split(/[/?#]/,1)[0],i=o.match(/^\[([^\]]+)\]/);return i?i[1]:o.split(":",1)[0]||""}}
2
+ export{qr as changeFixedDecimalScale,M as cidrToRange,A as convertExponentialToParts,Un as extractHost,U as fixedDecimalToNum,Z as fixedDecimalToStr,lt as floorDateToMinutes,gt as formatDateToString,it as formatStrToFuncArgsArr,$ as formatToBool,H as formatToLowerCase,dn as formatToNormalCase,wn as formatToNull,w as formatToNum,Tn as formatToPhone,g as formatToTrim,In as formatToUndefined,St as ipAddrToNum,k as isArr,C as isArrFilled,y as isBool,Lr as isClass,_t as isDate,Vt as isEmail,Kt as isExists,L as isFunc,vt as isIpAddr,nr as isMacAddr,c as isNum,sr as isNumFloat,mr as isNumN,R as isNumNZ,F as isNumP,z as isNumPZ,T as isObj,W as isObjFilled,Tr as isPassword,yr as isPhone,m as isStr,Er as isStrAscDesc,E as isStrBool,a as isStrFilled,Mr as isVar,B as jsonDecode,Qr as jsonEncode,G as normalizeToDecimalComponents,Dt as numToIpAddr,b as parseIPv4,P as parseStringLike,O as parseToFixedDecimal,ht as partsToSeconds,j as rangeIPv4,jt as rangeIPv4ToArr,_ as roundFixedDecimal,bt as secondsToParts,ut as splitArrToPortions,On as toGB,Mn as toGH,zn as toH,N as toIPv4,J as tryParseJSON,at as wait};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map