full-utils 2.0.4 → 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/browser.cjs +2 -2
- 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 +2 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +2 -2
- 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 +2 -2
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -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
|
*
|
|
@@ -4150,8 +4152,6 @@ declare function formatToTrim(value: unknown): string;
|
|
|
4150
4152
|
*/
|
|
4151
4153
|
declare function formatToUndefined(value: unknown): {} | undefined;
|
|
4152
4154
|
|
|
4153
|
-
declare function formatArrToSqlWhenCaseStr(d: Array<any>): string;
|
|
4154
|
-
|
|
4155
4155
|
/**
|
|
4156
4156
|
* Converts a numeric value with a given unit (bytes, KB, MB, GB, TB, PB)
|
|
4157
4157
|
* into gigabytes (`GB`).
|
|
@@ -4496,4 +4496,4 @@ declare function toH(value: any, unit?: string): number;
|
|
|
4496
4496
|
*/
|
|
4497
4497
|
declare function extractHost(value?: string): string;
|
|
4498
4498
|
|
|
4499
|
-
export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes,
|
|
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
|
@@ -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
|
*
|
|
@@ -4150,8 +4152,6 @@ declare function formatToTrim(value: unknown): string;
|
|
|
4150
4152
|
*/
|
|
4151
4153
|
declare function formatToUndefined(value: unknown): {} | undefined;
|
|
4152
4154
|
|
|
4153
|
-
declare function formatArrToSqlWhenCaseStr(d: Array<any>): string;
|
|
4154
|
-
|
|
4155
4155
|
/**
|
|
4156
4156
|
* Converts a numeric value with a given unit (bytes, KB, MB, GB, TB, PB)
|
|
4157
4157
|
* into gigabytes (`GB`).
|
|
@@ -4496,4 +4496,4 @@ declare function toH(value: any, unit?: string): number;
|
|
|
4496
4496
|
*/
|
|
4497
4497
|
declare function extractHost(value?: string): string;
|
|
4498
4498
|
|
|
4499
|
-
export { type FixedDecimal, type JSONLike, type PasswordOptions, type RangeIPv4Options, type TimeParts, changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes,
|
|
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 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 f=n.trim();f!==""&&h.push(f),n="";};for(let f=0;f<r.length;f++){let u=r[f];if(e){if(n+=u,i){i=false;continue}if(u==="\\"){i=true;continue}u===o&&(e=false,o=null);continue}if(u==='"'||u==="'"){e=true,o=u,n+=u;continue}if(u==="("){s++,n+=u;continue}if(u===")"){s=Math.max(0,s-1),n+=u;continue}if(u==="["){p++,n+=u;continue}if(u==="]"){p=Math.max(0,p-1),n+=u;continue}if(u==="{"){d++,n+=u;continue}if(u==="}"){d=Math.max(0,d-1),n+=u;continue}if(u===","&&s===0&&p===0&&d===0){x();continue}n+=u;}return n.length&&x(),h.map(f=>{if(f.startsWith("$")&&f.includes("(")&&f.endsWith(")"))return f;if(f==="null")return null;if(f==="undefined")return;if(P(f))return F(f);let u=w(f);if(Number.isFinite(u))return u;if(f==="Infinity")return 1/0;if(f==="-Infinity")return -1/0;let l=String(f||"");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 R(l)}catch{}return l})}function ft(t,r){if(!Number.isInteger(r)||r<=0)return [];let n=[],e=0;for(;e<t.length;)n.push(t.slice(e,e+r)),e+=r;return n}function F(t){switch(true){case T(t):return t;case I(t):return true;case j(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 L(t){let[r,n]=t.split("/"),e=k(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 [S(s),S(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(!I(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 k(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*C(t,r,n={}){let{includeNetwork:e=true,includeBroadcast:o=true}=n,i,s,p=false,d=null;if(r===void 0&&t.includes("/")){let f=L(t);if(!f)throw new Error(`Invalid CIDR: "${t}"`);let[u,l]=f,[O,q]=t.split("/");d=Number(q),i=k(u),s=k(l),p=true;}else {let f=k(t);if(f===null)throw new Error(`Invalid IPv4: "${t}"`);if(i=f,r&&r.trim()!==""){let u=k(r);if(u===null)throw new Error(`Invalid IPv4: "${r}"`);s=u;}else {let u=i>>>24&255,l=i>>>16&255,O=i>>>8&255;s=(u<<24|l<<16|O<<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 f=i;f<=s;f=f+1>>>0){if(!e&&f===h){if(f===s)break;continue}if(!o&&f===x){if(f===s)break;continue}if(yield S(f),f===4294967295)break}}function Lt(t,r,n={}){let{limit:e=1e6}=n,o=[],i=0;for(let s of C(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 S(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 b(t){return Array.isArray(t)}function D(t){return b(t)&&t.length>0}function T(t){return typeof t=="boolean"}function Ht(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 Vt(t){return a(t)?K.test(t):false}function M(t){return t!=null}function Kt(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 j(t){return c(t)&&t<=0}function I(t){return c(t)&&t>0}function W(t){return c(t)&&t>=0}function N(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function z(t){return N(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 P(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 jr(t){return m(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}var X=/^(['"`])([\s\S]*)\1$/;function A(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 R(t,r=false){if(t===null||c(t)||T(t))return t;if(D(t)){let n=t,e=[];for(let o of n)a(o)?e.push(A(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]=A(String(i),r):e[o]=i;}return e}return b(t)||N(t)?t:a(t)?A(String(t),r):null}function _r(t){try{return N(t)||b(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 E(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(W(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?H(B(t),r,"half-up"):B(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 E(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 E(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 B(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 H(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}function En(t){let r="",n={},e=[];for(r in t[0])r!=="id"&&(n[r]=[]);t.forEach(o=>{let i="";for(i in o)if(b(n[i])){let s=`"${o[i]}"`;(T(o[i])||P(o[i]))&&(s=Number(F(o[i]))),M(o[i])||(s="NULL"),n[i].push(`WHEN "${o.id}" THEN ${s}`);}});for(r in t[0])D(n[r])&&e.push(`${r} = CASE id ${n[r].join(" ")} END`);return e.join(",")}var v=1024,V=v*1024,y=V*1024,Q=y*1024,tt=Q*1024;function jn(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/y;break;case "k":i=n/V;break;case "m":i=n/y;break;case "g":i=n;break;case "t":i=n*(Q/y);break;case "p":i=n*(tt/y);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 $(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 zn(t,r=""){let n=w(t);if(!c(n))return 0;let e=$(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 Hn(t,r=""){let n=w(t);if(!c(n))return 0;let e=$(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 Vn(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{
|
|
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
|