helper-fns
Advanced tools
Comparing version 2.6.15 to 2.6.16
@@ -105,3 +105,3 @@ import { Buffer } from 'node:buffer'; | ||
declare function slash(string_: string): string; | ||
declare function orderedToken(identifier?: string): (string_: string) => string; | ||
declare function orderedToken(string_: string, identifier?: string): string; | ||
@@ -108,0 +108,0 @@ declare function isDefined<T = any>(value?: T): value is T; |
@@ -1,1 +0,1 @@ | ||
var w=Object.defineProperty;var m=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(t,n,e)=>n in t?w(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,x=(t,n)=>{for(var e in n||(n={}))k.call(n,e)&&g(t,e,n[e]);if(m)for(var e of m(n))O.call(n,e)&&g(t,e,n[e]);return t};function L(t,n,e=!0){return e?[...t,...n]:[...new Set([...t,...n])]}function B(t,n){return t.filter(e=>!n.includes(e))}function U(t,n){return t.filter(e=>n.includes(e))}function W(t){return t.flat(Number.POSITIVE_INFINITY)}function $(t){return[...new Set(t)]}function z(t,n=0){return t.reduce((e,r)=>e+r,n)}function V(t,n=1){return t.slice(0,-n)}function Y(t,n){let e=new Set(n);return t.filter(r=>e.has(r))}function q(t,n){let e=t.findIndex(r=>!n(r));return e===-1?[]:t.slice(e)}var J=(t,n=1)=>t.slice(n);function G(t){let n=t.length;for(;n>0;){let e=Math.floor(Math.random()*n--),r=t[n];t[n]=t[e],t[e]=r}return t}function H(t,n,e){return t.splice(e,0,t.splice(n,1)[0]),t}function X(t,n){return Array.from({length:n},e=>t[Math.round(Math.random()*(t.length-1))])}function Q(t,n){if(!t)throw new Error(n)}var f=t=>Object.prototype.toString.call(t);function Z(){}import{Buffer as p}from"buffer";import d from"crypto";import S from"fs";function y(t){return(typeof t=="object"||Array.isArray(t))&&Object.entries(t||{}).length===0}function ot(...t){return JSON.stringify(t)}var it=()=>+Date.now();function st(...t){return n=>{let e=n;for(let r of t)e=r(e);return e}}function ut(t,n=2){let e=new RegExp(`^-?\\d+(?:.\\d{0,${n||-1}})?`);return Number.parseFloat(t.toString().match(e)[0])}function ct(t){return!!JSON.parse(t)===JSON.parse(t)?JSON.parse(t):Number.isNaN(Number(t))?t:Number.parseFloat(t)}function at(t){let n;return function(...e){let{immediate:r,func:o,wait:s}=t,c=()=>{n=void 0,r||o.apply(this,e)},i=r&&!n;clearTimeout(n),n=setTimeout(c,s),i&&o.apply(this,e)}}function pt(t){console.time("timeTaken");let n=t();return console.timeEnd("timeTaken"),[n,performance.now()]}function ft(t){t<0&&(t=-t);let n={day:Math.floor(t/864e5),hour:Math.floor(t/36e5)%24,minute:Math.floor(t/6e4)%60,second:Math.floor(t/1e3)%60,millisecond:Math.floor(t)%1e3};return Object.entries(n).filter(e=>e[1]!==0).map(([e,r])=>`${r} ${e}${r===1?"":"s"}`).join(", ")}function T(t){return new Date(t)instanceof Date}function lt(t){let n=p.from(t.config.key,"hex"),e=p.from(t.config.iv,"hex"),r=d.createCipheriv("aes-256-cbc",n,e),o=r.update(t.text,"utf8","base64");return o+=r.final("base64"),o}function mt(t){let n=p.from(t.config.key,"hex"),e=p.from(t.config.iv,"hex"),r=d.createDecipheriv("aes-256-cbc",n,e);return r.update(t.text,"base64","utf8")+r.final("utf8")}function gt(t){return new Promise((n,e)=>{S.readFile(t,{encoding:"utf8"},(r,o)=>{r?e(r):n(o)})})}function xt(...t){return n=>{let e=Promise.resolve(n);for(let r=t.length-1;r>=0;r--){let o=t[r];e=e.then(o)}return e}}function h(t,n){return t.toISOString()===n.toISOString()}function dt(t){return new Promise(n=>{setTimeout(n,t)})}function yt(t,n,e){let r=process.env.DUE_DATE,o=new Date(r),s=new Date,c=Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()),i=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate()),u=Math.floor((i-c)/(1e3*60*60*24));if(u>0){let a=u*200;return a<0&&(a=0),setTimeout(e,a)}}function ht(t){let n={};for(let[e,r]of Object.entries(t))r!==null&&(n[e]=r);return n}function bt(t){for(let n in t)t[n]===void 0&&delete t[n];return t}function wt(t,n){let e={};for(let r of n)e[r]=t[r];return e}function kt(t,n){let e=x({},t);for(let r of n)delete e[r];return e}function Ot(t,n,e){t.sort((r,o)=>{for(let[s,c]of n.entries()){let i=e.get(s)||"asc",u=r[c],a=o[c];if(u!==a)return i==="asc"?u>a?1:-1:u<a?1:-1}return 0})}function St(t,n){Object.fromEntries(Object.keys(n).map(e=>[t[e]||e,n[e]]))}function At(t,n){return t.map(e=>e[n])}function Dt(t,n){return t.map(e=>e[n])}function Mt(t){return Object.keys(t).map(n=>t[n]).join(",")}function It(t){let n={};return Object.assign(n,t),n}function Rt(t,n){let e={};for(let r of t){let o=r[n];e[o]||(e[o]=[]),e[o].push(r)}return e}function Et(t){let n={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[t[e]]=e);return n}function Nt(t,n){return n in t}import{Buffer as A}from"buffer";function D(t){return t!==void 0}var M=t=>typeof t=="boolean";function b(t){return typeof t=="function"}var I=t=>typeof t=="number";function l(t){return typeof t=="string"}function R(t){return f(t)==="[object Object]"}var E=t=>t===null;function N(t){return Array.isArray(t)}function j(t){return typeof t=="bigint"}function v(t){return t instanceof A}function K(t){return b(t)&&t.toString().startsWith("class ")}function C(t){return f(t)==="[object RegExp]"}var Ft={isArray:N,isBoolean:M,isDefined:D,isFunction:b,isNull:E,isNumber:I,isObject:R,isString:l,isBigint:j,isBuffer:v,isClass:K,isDate:T,isEmpty:y,isSameDate:h,isRegExp:C};function Ut(t){if(!l(t))return"";let n=/^[\W_]+|[\W_]+$/g;return t.trim().replaceAll(n,"")}function Wt(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():""}function $t(t){return t.replaceAll(/&|<|>|'|"/g,n=>({"&":"&","<":"<",">":">","'":"'",""":'"'})[n]||n)}function zt(t){return t.replaceAll(/\b[a-z]/g,n=>n.toUpperCase())}function Vt(t){return t?t.charAt(0).toLowerCase()+t.slice(1):""}function Yt(t){return Array.from({length:t}).map(()=>Math.floor(Math.random()*16).toString(16)).join("")}function qt(t,n){return t.split(n)[1]}function Jt(t,n){return t.split(n)[0]}function Gt(t){let n=/\./g,[e,r]=t.split("@"),[o]=e.split("+");o=o.replaceAll(n,"");let s=`${o.toLowerCase()}@${r.toLowerCase()}`;return Number(s),s}function Ht(t,n){return n.endsWith(t)?n:n+t}function P(t=1,n=9){let e=Math.ceil(Math.min(t,n)),r=Math.floor(Math.max(t,n));return Math.floor(e+Math.random()*(r-e+1))}function Xt(t,n){let{separator:e="-"}=n||{};return t.toString().toLowerCase().normalize("NFD").replaceAll(/[\u0300-\u036F]/g,"").replaceAll(/[^\d a-z-]/g,"").replaceAll(/\s+/g,e)}function _t(t,n){return n.startsWith(t)?n:t+n}function Qt(t={}){return new URLSearchParams(t).toString()}function Zt(t,n){let e=/{{(.*?)}}/g;return t.replaceAll(e,(r,o)=>{let c=o.trim().split("."),i=n;for(let u of c)if(i&&u in i)i=i[u];else{i=void 0;break}return i===void 0?"":String(i)})}function tn(t){let n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e="0123456789",r="!@#$%^&*_-+=",o=[n];t.numbers&&o.push(e),t.symbols&&o.push(r);let s=[];for(let c=0;c<t.length;c++){let i=Math.trunc(Math.random()*o.length),u=o[i],a=Math.trunc(Math.random()*u.length);s.push(u.charAt(a))}return s.join("")}function nn(t){return t.replaceAll("\\","/")}function en(t="X"){return function(n){for(;n.includes(t);)n=n.replace(t,String(P()));return n}}export{Q as assert,ct as autoParseValues,Wt as capitalize,zt as capitalizeEveryWord,Ut as chop,U as common,xt as composeAsync,It as copyObject,at as debounce,mt as decrypt,dt as delay,B as difference,J as drop,V as dropRight,q as dropWhile,lt as encrypt,_t as ensurePrefix,Ht as ensureSuffix,Mt as enumToString,ut as fixedDecimal,W as flattenDeep,ft as formatDuration,Rt as groupBy,Y as intersection,Et as invertObject,Ft as is,N as isArray,j as isBigint,M as isBoolean,v as isBuffer,K as isClass,T as isDate,D as isDefined,y as isEmpty,b as isFunction,Nt as isKeyOf,E as isNull,I as isNumber,R as isObject,C as isRegExp,h as isSameDate,l as isString,Vt as lowerFirst,H as move,Z as noop,Gt as normalizeEmail,Dt as objectArrayToArray,kt as omit,Ot as orderBy,en as orderedToken,wt as pick,st as pipe,At as pluck,Yt as randomHex,P as randomNumber,tn as randomString,gt as readFile,ht as removeNull,bt as removeUndefined,St as renameKeys,ot as resolverArgs,X as sample,G as shuffle,nn as slash,Xt as slugify,qt as stringAfter,Jt as stringBefore,Qt as stringifyQueryParameters,z as sumOfAnArray,Zt as template,yt as throttler,pt as timeTaken,it as timestamp,f as toString,$t as unescapeHTML,L as union,$ as unique}; | ||
var w=Object.defineProperty;var m=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(t,n,e)=>n in t?w(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,x=(t,n)=>{for(var e in n||(n={}))k.call(n,e)&&g(t,e,n[e]);if(m)for(var e of m(n))O.call(n,e)&&g(t,e,n[e]);return t};function L(t,n,e=!0){return e?[...t,...n]:[...new Set([...t,...n])]}function B(t,n){return t.filter(e=>!n.includes(e))}function U(t,n){return t.filter(e=>n.includes(e))}function W(t){return t.flat(Number.POSITIVE_INFINITY)}function $(t){return[...new Set(t)]}function z(t,n=0){return t.reduce((e,r)=>e+r,n)}function V(t,n=1){return t.slice(0,-n)}function Y(t,n){let e=new Set(n);return t.filter(r=>e.has(r))}function q(t,n){let e=t.findIndex(r=>!n(r));return e===-1?[]:t.slice(e)}var J=(t,n=1)=>t.slice(n);function G(t){let n=t.length;for(;n>0;){let e=Math.floor(Math.random()*n--),r=t[n];t[n]=t[e],t[e]=r}return t}function H(t,n,e){return t.splice(e,0,t.splice(n,1)[0]),t}function X(t,n){return Array.from({length:n},e=>t[Math.round(Math.random()*(t.length-1))])}function Q(t,n){if(!t)throw new Error(n)}var f=t=>Object.prototype.toString.call(t);function Z(){}import{Buffer as p}from"buffer";import d from"crypto";import S from"fs";function y(t){return(typeof t=="object"||Array.isArray(t))&&Object.entries(t||{}).length===0}function ot(...t){return JSON.stringify(t)}var it=()=>+Date.now();function st(...t){return n=>{let e=n;for(let r of t)e=r(e);return e}}function ut(t,n=2){let e=new RegExp(`^-?\\d+(?:.\\d{0,${n||-1}})?`);return Number.parseFloat(t.toString().match(e)[0])}function ct(t){return!!JSON.parse(t)===JSON.parse(t)?JSON.parse(t):Number.isNaN(Number(t))?t:Number.parseFloat(t)}function at(t){let n;return function(...e){let{immediate:r,func:o,wait:s}=t,c=()=>{n=void 0,r||o.apply(this,e)},i=r&&!n;clearTimeout(n),n=setTimeout(c,s),i&&o.apply(this,e)}}function pt(t){console.time("timeTaken");let n=t();return console.timeEnd("timeTaken"),[n,performance.now()]}function ft(t){t<0&&(t=-t);let n={day:Math.floor(t/864e5),hour:Math.floor(t/36e5)%24,minute:Math.floor(t/6e4)%60,second:Math.floor(t/1e3)%60,millisecond:Math.floor(t)%1e3};return Object.entries(n).filter(e=>e[1]!==0).map(([e,r])=>`${r} ${e}${r===1?"":"s"}`).join(", ")}function T(t){return new Date(t)instanceof Date}function lt(t){let n=p.from(t.config.key,"hex"),e=p.from(t.config.iv,"hex"),r=d.createCipheriv("aes-256-cbc",n,e),o=r.update(t.text,"utf8","base64");return o+=r.final("base64"),o}function mt(t){let n=p.from(t.config.key,"hex"),e=p.from(t.config.iv,"hex"),r=d.createDecipheriv("aes-256-cbc",n,e);return r.update(t.text,"base64","utf8")+r.final("utf8")}function gt(t){return new Promise((n,e)=>{S.readFile(t,{encoding:"utf8"},(r,o)=>{r?e(r):n(o)})})}function xt(...t){return n=>{let e=Promise.resolve(n);for(let r=t.length-1;r>=0;r--){let o=t[r];e=e.then(o)}return e}}function h(t,n){return t.toISOString()===n.toISOString()}function dt(t){return new Promise(n=>{setTimeout(n,t)})}function yt(t,n,e){let r=process.env.DUE_DATE,o=new Date(r),s=new Date,c=Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()),i=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate()),u=Math.floor((i-c)/(1e3*60*60*24));if(u>0){let a=u*200;return a<0&&(a=0),setTimeout(e,a)}}function ht(t){let n={};for(let[e,r]of Object.entries(t))r!==null&&(n[e]=r);return n}function bt(t){for(let n in t)t[n]===void 0&&delete t[n];return t}function wt(t,n){let e={};for(let r of n)e[r]=t[r];return e}function kt(t,n){let e=x({},t);for(let r of n)delete e[r];return e}function Ot(t,n,e){t.sort((r,o)=>{for(let[s,c]of n.entries()){let i=e.get(s)||"asc",u=r[c],a=o[c];if(u!==a)return i==="asc"?u>a?1:-1:u<a?1:-1}return 0})}function St(t,n){Object.fromEntries(Object.keys(n).map(e=>[t[e]||e,n[e]]))}function At(t,n){return t.map(e=>e[n])}function Dt(t,n){return t.map(e=>e[n])}function Mt(t){return Object.keys(t).map(n=>t[n]).join(",")}function It(t){let n={};return Object.assign(n,t),n}function Rt(t,n){let e={};for(let r of t){let o=r[n];e[o]||(e[o]=[]),e[o].push(r)}return e}function Et(t){let n={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[t[e]]=e);return n}function Nt(t,n){return n in t}import{Buffer as A}from"buffer";function D(t){return t!==void 0}var M=t=>typeof t=="boolean";function b(t){return typeof t=="function"}var I=t=>typeof t=="number";function l(t){return typeof t=="string"}function R(t){return f(t)==="[object Object]"}var E=t=>t===null;function N(t){return Array.isArray(t)}function j(t){return typeof t=="bigint"}function v(t){return t instanceof A}function K(t){return b(t)&&t.toString().startsWith("class ")}function C(t){return f(t)==="[object RegExp]"}var Ft={isArray:N,isBoolean:M,isDefined:D,isFunction:b,isNull:E,isNumber:I,isObject:R,isString:l,isBigint:j,isBuffer:v,isClass:K,isDate:T,isEmpty:y,isSameDate:h,isRegExp:C};function Ut(t){if(!l(t))return"";let n=/^[\W_]+|[\W_]+$/g;return t.trim().replaceAll(n,"")}function Wt(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():""}function $t(t){return t.replaceAll(/&|<|>|'|"/g,n=>({"&":"&","<":"<",">":">","'":"'",""":'"'})[n]||n)}function zt(t){return t.replaceAll(/\b[a-z]/g,n=>n.toUpperCase())}function Vt(t){return t?t.charAt(0).toLowerCase()+t.slice(1):""}function Yt(t){return Array.from({length:t}).map(()=>Math.floor(Math.random()*16).toString(16)).join("")}function qt(t,n){return t.split(n)[1]}function Jt(t,n){return t.split(n)[0]}function Gt(t){let n=/\./g,[e,r]=t.split("@"),[o]=e.split("+");o=o.replaceAll(n,"");let s=`${o.toLowerCase()}@${r.toLowerCase()}`;return Number(s),s}function Ht(t,n){return n.endsWith(t)?n:n+t}function P(t=1,n=9){let e=Math.ceil(Math.min(t,n)),r=Math.floor(Math.max(t,n));return Math.floor(e+Math.random()*(r-e+1))}function Xt(t,n){let{separator:e="-"}=n||{};return t.toString().toLowerCase().normalize("NFD").replaceAll(/[\u0300-\u036F]/g,"").replaceAll(/[^\d a-z-]/g,"").replaceAll(/\s+/g,e)}function _t(t,n){return n.startsWith(t)?n:t+n}function Qt(t={}){return new URLSearchParams(t).toString()}function Zt(t,n){let e=/{{(.*?)}}/g;return t.replaceAll(e,(r,o)=>{let c=o.trim().split("."),i=n;for(let u of c)if(i&&u in i)i=i[u];else{i=void 0;break}return i===void 0?"":String(i)})}function tn(t){let n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e="0123456789",r="!@#$%^&*_-+=",o=[n];t.numbers&&o.push(e),t.symbols&&o.push(r);let s=[];for(let c=0;c<t.length;c++){let i=Math.trunc(Math.random()*o.length),u=o[i],a=Math.trunc(Math.random()*u.length);s.push(u.charAt(a))}return s.join("")}function nn(t){return t.replaceAll("\\","/")}function en(t,n="X"){for(;t.includes(n);)t=t.replace(n,String(P()));return t}export{Q as assert,ct as autoParseValues,Wt as capitalize,zt as capitalizeEveryWord,Ut as chop,U as common,xt as composeAsync,It as copyObject,at as debounce,mt as decrypt,dt as delay,B as difference,J as drop,V as dropRight,q as dropWhile,lt as encrypt,_t as ensurePrefix,Ht as ensureSuffix,Mt as enumToString,ut as fixedDecimal,W as flattenDeep,ft as formatDuration,Rt as groupBy,Y as intersection,Et as invertObject,Ft as is,N as isArray,j as isBigint,M as isBoolean,v as isBuffer,K as isClass,T as isDate,D as isDefined,y as isEmpty,b as isFunction,Nt as isKeyOf,E as isNull,I as isNumber,R as isObject,C as isRegExp,h as isSameDate,l as isString,Vt as lowerFirst,H as move,Z as noop,Gt as normalizeEmail,Dt as objectArrayToArray,kt as omit,Ot as orderBy,en as orderedToken,wt as pick,st as pipe,At as pluck,Yt as randomHex,P as randomNumber,tn as randomString,gt as readFile,ht as removeNull,bt as removeUndefined,St as renameKeys,ot as resolverArgs,X as sample,G as shuffle,nn as slash,Xt as slugify,qt as stringAfter,Jt as stringBefore,Qt as stringifyQueryParameters,z as sumOfAnArray,Zt as template,yt as throttler,pt as timeTaken,it as timestamp,f as toString,$t as unescapeHTML,L as union,$ as unique}; |
{ | ||
"name": "helper-fns", | ||
"type": "module", | ||
"version": "2.6.15", | ||
"version": "2.6.16", | ||
"packageManager": "pnpm@8.7.1", | ||
@@ -6,0 +6,0 @@ "description": "Some common utilities functions for everyday backend usage with zero dependencies", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
39465