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/browser.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
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';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
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';
|
package/dist/browser.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function V(t){if(!s(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,u=0,l=0,d=0,S=[],x=()=>{let a=r.trim();a!==""&&S.push(a),r="";};for(let a=0;a<n.length;a++){let c=n[a];if(e){if(r+=c,o){o=false;continue}if(c==="\\"){o=true;continue}c===i&&(e=false,i=null);continue}if(c==='"'||c==="'"){e=true,i=c,r+=c;continue}if(c==="("){u++,r+=c;continue}if(c===")"){u=Math.max(0,u-1),r+=c;continue}if(c==="["){l++,r+=c;continue}if(c==="]"){l=Math.max(0,l-1),r+=c;continue}if(c==="{"){d++,r+=c;continue}if(c==="}"){d=Math.max(0,d-1),r+=c;continue}if(c===","&&u===0&&l===0&&d===0){x();continue}r+=c;}return r.length&&x(),S.map(a=>{if(a.startsWith("$")&&a.includes("(")&&a.endsWith(")"))return a;if(a==="null")return null;if(a==="undefined")return;if(P(a))return F(a);let c=A(a);if(Number.isFinite(c))return c;if(a==="Infinity")return 1/0;if(a==="-Infinity")return -1/0;let p=String(a||"");if(p.length>=2&&(p.startsWith("'")&&p.endsWith("'")||p.startsWith('"')&&p.endsWith('"')))return p.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');if(p.startsWith("{")&&p.endsWith("}")||p.startsWith("[")&&p.endsWith("]"))try{return D(p)}catch{}return p})}function H(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 F(t){switch(true){case k(t):return t;case N(t):return true;case O(t):return false;case(f(t)&&["true","1","yes","on"].includes(String(t??"").trim().toLowerCase())):return true;case(f(t)&&["false","0","no","off"].includes(String(t??"").trim().toLowerCase())):return false}return false}async function G(t=0){await new Promise(n=>setTimeout(()=>n(true),t));}function v(t){return process.env[t]}function nt(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 et(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()),u=n(t.getMinutes()),l=n(t.getSeconds());return `${r}-${e}-${i} ${o}:${u}:${l}`}function ot(t){let{days:n=0,hours:r=0,minutes:e=0,seconds:i=0}=t;return n*86400+r*3600+e*60+i}function ut(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 ft(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 pt(t){if(!N(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 h(t){return Array.isArray(t)}function I(t){return h(t)&&t.length>0}function k(t){return typeof t=="boolean"}function kt(t){if(t instanceof Date)return !Number.isNaN(t.getTime());if(s(t)||m(t)){let n=new Date(t);return !Number.isNaN(n.getTime())}return false}var _=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;function yt(t){return f(t)?_.test(t):false}function Ft(t){return t!=null}function j(t){return typeof t=="function"}var B=/^(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 Ot(t){if(!s(t))return false;let n=t.trim();return B.test(n)}function $t(t){return s(t)&&/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(t)}function m(t){return typeof t=="number"&&Number.isFinite(t)}function Ct(t){return m(t)&&!Number.isInteger(t)}function Ut(t){return m(t)&&t<0}function O(t){return m(t)&&t<=0}function N(t){return m(t)&&t>0}function $(t){return m(t)&&t>=0}function w(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"&&!Array.isArray(t)}function L(t){return w(t)&&Object.keys(t).length>0}function Gt(t,{minLength:n=8,maxLength:r=256,requireUppercase:e=true,requireLowercase:i=true,requireDigit:o=true,requireSpecial:u=true}={}){return !(!s(t)||t.length<n||t.length>r||e&&!/[A-ZА-Я]/.test(t)||i&&!/[a-zа-я]/.test(t)||o&&!/\d/.test(t)||u&&!/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(t))}function tn(t){if(!f(t)&&!m(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 s(t){return typeof t=="string"}function P(t){if(!f(t))return false;let n=t.trim().toLowerCase();return n==="true"||n==="false"}function f(t){return s(t)&&t.trim().length>0}function fn(t){if(!f(t))return false;let n=t.trim().toLowerCase();return n==="asc"||n==="desc"}function ln(t){return s(t)&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}function gn(t){return j(t)&&/^class\s/.test(Function.prototype.toString.call(t))}var J=/^(['"`])([\s\S]*)\1$/;function b(t,n){let r=t.trim(),e=E(r);if(e.ok)return e.value;let i=J.exec(r);return i?i[2]:n?r:null}function E(t){try{return {ok:!0,value:JSON.parse(t)}}catch{}return {ok:false}}function D(t,n=false){if(t===null||m(t)||k(t))return t;if(I(t)){let r=t,e=[];for(let i of r)f(i)?e.push(b(String(i),n)):e.push(i);return e}if(L(t)){let r=t,e={};for(let i of Object.keys(r)){let o=r[i];f(o)?e[i]=b(String(o),n):e[i]=o;}return e}return h(t)||w(t)?t:f(t)?b(String(t),n):null}function Fn(t){try{return w(t)||h(t)?JSON.stringify(t):""}catch{}return ""}function W(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),u=r.slice(i);return n+o+"."+u}function C(t){return Number(W(t))}function y(t,n){let r=/^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec((()=>{let[o,u]=n.split(/e/i),[l,d=""]=o.split("."),S=l.replace(/^0+/,"")+d,x=parseInt(u,10)-d.length;return `${S||"0"}e${x}`})());if(!r)throw new Error("Failed to parse exponential notation.");let e=r[1],i=parseInt(r[3],10);if($(i))return e=e+"0".repeat(i),{sign:t,integerPart:e||"0",fractionalPart:""};{let o=-i;if(o>=e.length){let u="0".repeat(o-e.length);return {sign:t,integerPart:"0",fractionalPart:u+e}}else {let u=e.length-o;return {sign:t,integerPart:e.slice(0,u),fractionalPart:e.slice(u)}}}}function M(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 y(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 y(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(t){let{sign:n,integerPart:r,fractionalPart:e}=M(t),i=r.replace(/^0+/,"")||"0",o=e.replace(/0+$/,""),u=i+o||"0";return {sign:n,digitsInteger:BigInt(u),scale:o.length}}function z(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),u=t.digitsInteger/o,l=t.digitsInteger%o;if(r==="trunc"||l===0n)return {sign:t.sign,digitsInteger:u,scale:e};let d=o/2n,x=l>=d?u+1n:u;return {sign:t.sign,digitsInteger:x,scale:e}}function A(t,n=1,r=false){try{return C(n>1?z(T(t),n,"half-up"):T(t))}catch(e){if(r)throw e}return 0}function U(t){if(!s(t))return "";let n=g(t);return f(n)?n.toLowerCase():""}function Zn(t){if(!s(t))return "";let n=U(t);return f(n)?n[0].toUpperCase()+n.slice(1):""}function qn(t){return s(t)&&g(t)===""||t===void 0?null:t}function Gn(t,n="+7"){if(!s(t))return null;let r=g(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 g(t,n=""){let r=String(s(t)?t.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g,""):"");return n?r.split(n).filter(e=>!!e).join(n):r}function er(t){return s(t)&&g(t)===""||t===null?void 0:t}var sr=t=>{if(!s(t))return t;let n=String(g(t)||"");return n===""?null:String(n.toLowerCase()||"").replace(/\s+/g," ").replace(/\t+/g,"").replace(/\n+/g,"")};function cr(t=""){return {}}function mr(t){if(!f(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,u)=>{let l=u.toUpperCase();return e.has(l)?decodeURIComponent(`%${l}`):`%${l}`}).split(n).join("%")}export{V as arrFuncArgs,H as arrSplitPortions,F as boolNormalize,nt as dateFloorMin,ot as datePartsSec,ut as dateSecParts,et as dateStr,v as env,pt as ipNumStr,ft as ipStrNum,h as isArr,I as isArrFilled,k as isBool,gn as isClass,kt as isDate,yt as isEmail,Ft as isExists,j as isFunc,Ot as isIpAddr,$t as isMacAddr,m as isNum,Ct as isNumFloat,Ut as isNumN,O as isNumNZ,N as isNumP,$ as isNumPZ,w as isObj,L as isObjFilled,Gt as isPassword,tn as isPhone,s as isStr,fn as isStrAscDesc,P as isStrBool,f as isStrFilled,ln as isVar,D as jsonDecode,Fn as jsonEncode,E as jsonParse,b as jsonStrLike,A as numNormalize,U as strLowerCase,Zn as strNormalCase,sr as strNormalize,qn as strNull,Gn as strPhone,g as strTrim,er as strUndefined,mr as urlDecode,cr as urlObj,G as wait};//# sourceMappingURL=browser.mjs.map
|
|
2
2
|
//# sourceMappingURL=browser.mjs.map
|