Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

helper-fns

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

helper-fns - npm Package Compare versions

Comparing version 2.5.19 to 2.5.20

316

dist/index.d.ts

@@ -10,191 +10,29 @@ declare const assert: (condition: boolean, message: string) => asserts condition;

}
/**
* It returns true if the object is empty, false if it's not
* @param {any} obj - any
* @returns A function that takes in an object and returns a boolean.
*/
declare const isEmpty: (obj: any) => boolean;
/**
* It takes an object and returns a new object with all the null values removed
* @param {Record<string, any> | ArrayLike<unknown>} obj - Record<string, any> | ArrayLike<unknown>
* @returns An object with all the keys and values that are not null.
*/
declare const removeEmpty: (obj: Record<string, any> | ArrayLike<unknown>) => {};
/**
* It takes an object and an array of keys, and returns a new object with only those keys
* @param {T} obj - T - the object to pick properties from
* @param {K[]} keys - K[]
* @returns Pick<T, K>
*/
declare const pick: <T, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
/**
* It takes any number of arguments, and returns a stringified version of those arguments
* @param {any[]} args - The arguments passed to the resolver.
* @returns A stringified version of the arguments passed in.
*/
declare const resolverArgs: (...args: any[]) => string;
/**
* It takes an array of numbers and an optional initial value, and returns the sum of the array
* @param arr - The array to be reduced.
* @param [initialValue=0] - The initial value of the accumulator.
* @returns [1, 2, 3, 4, 5]
*/
declare const sumOfAnArray: (arr: Array<number>, initialValue?: number) => number;
/**
* Return an iterable of unique values from the given iterable.
* @param values - Iterable<unknown>
* @returns [...new Set(values)]
*/
declare const unique: (values: Iterable<unknown>) => Iterable<unknown>;
/**
* It takes an object and an array of keys, and returns a new object with the keys omitted
* @param {T} obj - T - the object to omit keys from
* @param {K[]} keys - K[]
* @returns { a: 1, b: 2 }
*/
declare const omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
/**
* It sorts an array of objects by a list of properties, in the order specified
* @param {any} arr - The array to sort
* @param {any[]} props - The properties to sort by.
* @param orders - An array of strings that specifies the order of sorting.
*/
declare const orderBy: (arr: any, props: any[], orders: Record<string, string>) => void;
/**
* Pluck takes an array of objects and returns an array of the values of a certain property in each
* object
* @param {any[]} arr - any[] - the array we want to pluck from
* @param {string | number} key - string | number
* @returns [1, 2, 3]
*/
declare const pluck: (arr: any[], key: string | number) => any[];
/**
* It takes an object and a map of keys to new keys, and returns a new object with the keys renamed
* according to the map, while keeping the values intact
* @param keysMap - Record<string, any>
* @param obj - The object to be renamed
*/
declare const renameKeys: (keysMap: Record<string, any>, obj: Record<string, any>) => void;
/**
* "It takes an array of objects and returns an array of the values of a specific attribute of those
* objects."
*
* Here's an example of how to use it:
* @param objectArray - The array of objects you want to convert.
* @param {string} attr - The attribute of the object you want to extract.
* @returns An array of the values of the attribute passed in.
*/
declare const objectArrayToArray: (objectArray: Array<unknown>, attr: string) => Array<unknown>;
/**
* It takes a number and returns a number with a fixed number of decimal places
* @param {number} num - The number to be fixed.
* @param [fixed=2] - The number of decimal places to round to.
* @returns A function that takes a number and a fixed number and returns a number.
*/
declare const fixedDecimal: (num: number, fixed?: number) => number;
/**
* It takes a string and returns a string, number, or boolean
* @param {string} val - string - the value to be parsed
*/
declare const autoParseValues: (val: string) => string | number | boolean;
/**
* It takes an array of arrays and returns a new array with all the elements flattened
* @param {any[]} arr - The array to flatten.
* @returns [1, 2, 3, 4, 5, 6]
*/
declare const flattenDeep: (arr: any[]) => any[];
/**
* It returns an array of all the elements in the first array that are not in the second array
* @param {any[]} a - any[] - The first array to compare
* @param {any[]} b - any[]
* @returns The difference between two arrays.
*/
declare const difference: (a: any[], b: any[]) => any[];
/**
* It takes two arrays and returns an array of the elements that are common to both
* @param {any[]} a - any[] - The first array to compare
* @param {any[]} b - any[]
* @returns The common elements of the two arrays.
*/
declare const common: (a: any[], b: any[]) => any[];
/**
* If the string exists, return the first character capitalized and the rest of the string lowercase,
* otherwise return an empty string.
* @param {string} str - string - This is the string that we want to capitalize.
* @returns A function that takes a string and returns a string.
*/
declare const capitalize: (str: string) => string;
/**
* Returns a function, that, as long as it continues to be invoked, will not
* be triggered. The function will be called after it stops being called for
* N milliseconds. If `immediate` is passed, trigger the function on the
* leading edge, instead of the trailing.
*
* @param func a function
* @param wait time to wait
* @param immediate should it be called immediately
*/
declare const debounce: (func: Function, wait: number, immediate?: boolean) => (this: any) => void;
/**
* It takes a callback function as an argument and returns the time taken to execute that function
* @param {Function} callback - Function - The function to be executed.
* @returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
*/
declare const timeTaken: (callback: Function) => number;
/**
* It replaces all instances of &amp;, &lt;, &gt;, &#39;, and &quot; with their respective HTML
* entities
* @param {string} str - The string to unescape.
* @returns the string with the tags replaced with the corresponding characters.
*/
declare const unescapeHTML: (str: string) => string;
/**
* If the function is called again before the timeout is up, reset the timeout and use the latest
* arguments.
* @param {Function} func - The function to be executed
* @param {number} wait - The number of milliseconds to throttle invocations to.
* @returns A function that will call the function passed in after a certain amount of time has passed.
*/
declare const throttle: (func: Function, wait: number) => () => void;
declare const formatDuration: (ms: number) => string;
/**
* "Replace every word in a string with a capitalized version of that word."
*
* The first thing we do is use the replace() method to replace every word in the string with a
* capitalized version of that word
* @param {string} str - string - The string to be capitalized.
* @returns A function that takes a string as an argument and returns a string with every word
* capitalized.
*/
declare const capitalizeEveryWord: (str: string) => string;
/**
* If the string exists, return the first character of the string in lowercase, followed by the rest of
* the string. Otherwise, return an empty string.
* @param {string} str - string - the string to be converted
* @returns The first character of the string is being converted to lowercase and then concatenated
* with the rest of the string.
*/
declare const lowerFirst: (str: string) => string;
/**
* It returns an array of unique values from two arrays.
* @param a - Array<unknown>
* @param b - Array<unknown>
* @param [duplicates=true] - boolean
* @returns [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
*/
declare const union: (a: Array<unknown>, b: Array<unknown>, duplicates?: boolean) => Array<unknown>;
declare const isDate: (dateString: string) => boolean;
/**
* It returns a new array with the last n elements removed
* @param {any[]} arr - The array to query.
* @param [n=1] - The number of elements to drop from the end of the array.
* @returns [1, 2, 3, 4, 5]
*/
declare const dropRight: (arr: any[], n?: number) => any[];
/**
* It takes a string and an object with a key and iv property, and returns an encrypted string
* @param {string} text - The text to be encrypted
* @param config - {
* @returns The encrypted text
*/
declare const encrypt: (text: string, config: {

@@ -204,14 +42,3 @@ key: string;

}) => string;
/**
* It takes an enum and returns an array of strings
* @param _enum - The enum you want to convert to a string array.
* @returns An array of strings
*/
declare const enumToString: (_enum: Record<any, any>) => string[];
/**
* It decrypts a string using AES-256-CBC.
* @param {string} encrypted - The encrypted string you want to decrypt.
* @param config - {
* @returns The decrypted string.
*/
declare const decrypt: (encrypted: string, config: {

@@ -221,162 +48,29 @@ key: string;

}) => string;
/**
* It reads a file and returns a promise that resolves to the file's contents
* @param {string} path - The path to the file you want to read.
* @returns A promise that resolves to the contents of the file at the given path.
*/
declare const readFile: (path: string) => Promise<unknown>;
/**
* "Return a random number between a and b, inclusive."
*
* The function takes two optional parameters, a and b, and returns a random number between them. If a
* and b are omitted, the function returns a random number between 1 and 9
* @param [a=1] - The lower bound of the random number.
* @param [b=9] - The upper bound of the random number to be generated.
* @returns A random number between a and b.
*/
declare const randomNumber: (a?: number, b?: number) => number;
/**
* It creates an array of size 'size' and then maps each element to a random hexadecimal number and
* then joins them all together
* @param {number} size - The number of characters you want in your hex string.
*/
declare const randomHex: (size: number) => string;
/**
* It takes a string and replaces all instances of a given identifier with a random number
* @param {string} str - The string to be replaced.
* @param [identifier=X] - The string that will be replaced with a random number.
* @returns A function that takes a string and an identifier and returns a string with the identifier
* replaced with a random number.
*/
declare const orderedToken: (str: string, identifier?: string) => string;
/**
* Return the string after the first occurrence of the given substring.
* @param {string} str - The string to search in
* @param {string} substr - The substring to search for.
* @returns The string after the first occurrence of the given substring.
*/
declare const strAfter: (str: string, substr: string) => string;
/**
* Return the part of the string before the first occurrence of the given substring.
* @param {string} str - The string to search in
* @param {string} substr - The substring to search for.
* @returns The string before the first instance of the substring.
*/
declare const strBefore: (str: string, substr: string) => string;
/**
* If the value is not null, undefined, or an empty string, return true, otherwise return false.
* @param {any} value - any - The value to check.
* @returns A function that takes a value and returns a boolean
*/
declare const isNotEmpty: (value: any) => boolean;
/**
* It creates a new instance of the same type as the given instance, copies all the properties of the
* given instance to the new instance, and returns the new instance
* @param {T} instance - The instance to clone.
* @returns A new instance of the same class as the instance passed in.
*/
declare const clone: <T extends {
constructor: Function;
}>(instance: T) => T;
/**
*
*
* @export
* @param {any[]} arr
* @param {(string | number)} fn
* @returns any[]
*/
declare const groupBy: (arr: any[], prop: string) => any[];
/**
* Shuffle the elements array and return it. (mutative)
*
*/
declare const shuffle: <T>(array: T[]) => T[];
/**
*
*
* @export
* @param {string} email
* @return {*}
*/
declare const normalizeEmail: (email: string) => any;
/**
*
*
* @export
* @param {string} str
* @param {ISlugifyOptions} [options={ lowercase: true, separator: '-', trim: true }]
* @return {*} {string}
*/
declare const slugify: (str: string, options?: ISlugifyOptions) => string;
/**
*
* Clear undefined fields from an object. It mutates the object
*
* @export
* @template T
* @param {T} obj
* @return {*} {T}
*/
declare const clearUndefined: <T extends Record<string, any>>(obj: T) => T;
/**
* Replace backslash to slash
*
* @category String
*/
declare const slash: (str: string) => string;
/**
* Ensure prefix of a string
*
* @category String
*/
declare const ensurePrefix: (prefix: string, str: string) => string;
/**
*
*
* @export
* @param {Record<string, any>} obj
* @returns {Record<string, any>}
*/
declare const invertObj: (obj: Record<string, any>) => Record<string, any>;
/**
*
*
* @export
* @param {*} [params={} || '']
* @return {*} {string}
*/
declare const stringifyQueryParams: (params?: any) => string;
/**
*
*
* @export
* @param {number} [length=6]
* @return {*} {String}
*/
declare const generateRandomString: (length?: number) => String;
/**
*
*
* @export
* @param {*} str
* @param {Record<string,any>} mix
* @return {*}
*/
declare const template: (str: any, mix: Record<string, any>) => any;
/**
* It takes in a length, and two optional parameters, symbols and numbers, and returns a random
* string of the specified length
* @param {number} length - number - The length of the string you want to generate.
* @param {boolean} [symbols=false] - boolean = false
* @param {boolean} [numbers=false] - boolean = false
* @returns A random string of the length specified.
*/
declare function randomString(length: number, symbols?: boolean, numbers?: boolean): string;
/**
* ComposeAsync takes a list of functions and returns a function that takes an input and returns a
* promise that resolves to the result of applying the input to the list of functions in reverse order
* @param {any[]} fns - an array of functions
*/
declare const composeAsync: (...fns: any[]) => (input: any) => any;
declare const intersection: (a: any[], b: any[]) => any[];
declare const isSameDate: (dateA: Date, dateB: Date) => boolean;
declare const dropWhile: (arr: string | any[], func: (arg0: any) => any) => string | any[];
declare const drop: (arr: string | any[], n?: number) => string | any[];

@@ -390,2 +84,2 @@ declare const isDef: <T = any>(val?: T | undefined) => val is T;

export { assert, autoParseValues, capitalize, capitalizeEveryWord, clearUndefined, clone, common, composeAsync, debounce, decrypt, difference, dropRight, encrypt, ensurePrefix, enumToString, fixedDecimal, flattenDeep, formatDuration, generateRandomString, groupBy, invertObj, isBoolean, isDate, isDef, isEmpty, isFunction, isNotEmpty, isNumber, isObject, isString, lowerFirst, noop, normalizeEmail, objectArrayToArray, omit, orderBy, orderedToken, pick, pluck, randomHex, randomNumber, randomString, readFile, removeEmpty, renameKeys, resolverArgs, shuffle, slash, slugify, strAfter, strBefore, stringifyQueryParams, sumOfAnArray, template, throttle, timeTaken, toString, unescapeHTML, union, unique };
export { assert, autoParseValues, capitalize, capitalizeEveryWord, clearUndefined, clone, common, composeAsync, debounce, decrypt, difference, drop, dropRight, dropWhile, encrypt, ensurePrefix, enumToString, fixedDecimal, flattenDeep, formatDuration, generateRandomString, groupBy, intersection, invertObj, isBoolean, isDate, isDef, isEmpty, isFunction, isNotEmpty, isNumber, isObject, isSameDate, isString, lowerFirst, noop, normalizeEmail, objectArrayToArray, omit, orderBy, orderedToken, pick, pluck, randomHex, randomNumber, randomString, readFile, removeEmpty, renameKeys, resolverArgs, shuffle, slash, slugify, strAfter, strBefore, stringifyQueryParams, sumOfAnArray, template, throttle, timeTaken, toString, unescapeHTML, union, unique };

2

dist/index.js

@@ -1,1 +0,1 @@

var x=(t,e)=>{if(!t)throw new Error(e)};var l=t=>Object.prototype.toString.call(t);var d=()=>{};import p from"crypto";import g from"fs";var f=/\./g;var m=t=>{return[Object,Array].includes((t||{}).constructor)&&!Object.entries(t||{}).length};var T=t=>{return Object.entries(t).reduce((e,[r,n])=>n===null?e:{...e,[r]:n},{})};var S=(t,e)=>{const r={};e.forEach(n=>{r[n]=t[n]});return r};var A=(...t)=>{return JSON.stringify(t)};var O=(t,e=0)=>{return t.reduce((r,n)=>r+n,e)};var k=t=>{return[...new Set(t)]};var M=(t,e)=>{const r={...t};e.forEach(n=>delete r[n]);return r};var R=(t,e,r)=>{[...t].sort((n,o)=>e.reduce((s,i,a)=>{if(s===0){const[c,u]=r&&r[a]==="desc"?[o[i],n[i]]:[n[i],o[i]];s=c>u?1:c<u?-1:0}return s},0))};var E=(t,e)=>{return t.map(r=>r[e])};var N=(t,e)=>{Object.keys(e).reduce((r,n)=>({...r,...{[t[n]||n]:e[n]}}),{})};var F=(t,e)=>{return t.map(r=>{return r[e]})};var j=(t,e=2)=>{const r=new RegExp(`^-?\\d+(?:.\\d{0,${e||-1}})?`);return parseFloat(t.toString().match(r)[0])};var v=t=>{if(!!JSON.parse(t)===JSON.parse(t))return JSON.parse(t.toLowerCase());else if(!isNaN(Number(t)))return parseFloat(t);return t};var C=t=>{return t.flat(Infinity)};var L=(t,e)=>{return t.filter(r=>!e.includes(r))};var D=(t,e)=>{return t.filter(r=>e.includes(r))};var K=t=>{return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():""};var P=(t,e,r)=>{let n;return function(){const o=this;const s=arguments;const i=function(){n=null;if(!r)t.apply(o,s)};const a=r&&!n;clearTimeout(n);n=setTimeout(i,e);if(a)t.apply(o,s)}};var B=t=>{console.time("timeTaken");const e=t();console.timeEnd("timeTaken");return e};var I=t=>{return t.replace(/&amp;|&lt;|&gt;|&#39;|&quot;/g,e=>({"&amp;":"&","&lt;":"<","&gt;":">","&#39;":"'","&quot;":'"'})[e]||e)};var z=(t,e)=>{let r=null;let n=null;const o=void 0;const s=()=>{t.apply(o,n);r=null};return function(){if(!r){n=arguments;r=setTimeout(s,e)}}};var $=t=>{if(t<0)t=-t;const e={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(e).filter(r=>r[1]!==0).map(([r,n])=>`${n} ${r}${n!==1?"s":""}`).join(", ")};var J=t=>{return t.replace(/\b[a-z]/g,e=>e.toUpperCase())};var U=t=>{return t?t.charAt(0).toLowerCase()+t.slice(1):""};var q=(t,e,r=true)=>{if(!r)return Array.from(new Set([...t,...e]));return Array.from([...t,...e])};var V=t=>{return new Date(t)instanceof Date};var _=(t,e=1)=>{return t.slice(0,-e)};var G=(t,e)=>{const r=Buffer.from(e.key,"hex");const n=Buffer.from(e.iv,"hex");const o=p.createCipheriv("aes-256-cbc",r,n);let s=o.update(t,"utf8","base64");s+=o.final("base64");return s};var H=t=>{return Object.keys(t).map(e=>t[e]).filter(e=>typeof e==="string")};var W=(t,e)=>{const r=Buffer.from(e.key,"hex");const n=Buffer.from(e.iv,"hex");const o=p.createDecipheriv("aes-256-cbc",r,n);const s=o.update(t,"base64","utf8");return s+o.final("utf8")};var X=t=>{return new Promise((e,r)=>{g.readFile(t,{encoding:"utf-8"},(n,o)=>{if(n)r(n);else e(o)})})};var y=(t=1,e=9)=>{const r=Math.ceil(Math.min(t,e));const n=Math.floor(Math.max(t,e));return Math.floor(r+Math.random()*(n-r+1))};var Y=t=>{return[...Array(t)].map(()=>Math.floor(Math.random()*16).toString(16)).join("")};var Q=(t,e="X")=>{while(t.includes(e)){t=t.replace(e,String(y()))}return t};var Z=(t,e)=>{return t.split(e)[1]};var tt=(t,e)=>{return t.split(e)[0]};var et=t=>{return!m(t)};var rt=t=>{const e=new t.constructor;Object.assign(e,t);return e};var nt=(t,e)=>{return t.reduce((r,n)=>{if(!r[n[e]])r[n[e]]=[];r[n[e]].push(n);return r},{})};var ot=t=>{let e=t.length;while(e>0){const r=Math.floor(Math.random()*e--);const n=t[e];t[e]=t[r];t[r]=n}return t};var st=t=>{const[e,r]=t.split("@");let[n]=e.split("+");n=n.replace(f,"");const o=`${n.toLowerCase()}@${r.toLowerCase()}`;Number(o);return o};var it=(t,e={lowercase:true,separator:"-",trim:true})=>{const r=t.toString().normalize("NFD").replace(/[\u0300-\u036F]/g,"");if(e.lowercase)r.toLowerCase();if(e.trim)r.trim();return r.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,e.separator)};var at=t=>{Object.keys(t).forEach(e=>t[e]===void 0?delete t[e]:{});return t};var ct=t=>{return t.replace(/\\/g,"/")};var ut=(t,e)=>{if(!e.startsWith(t))return t+e;return e};var lt=t=>{const e={};for(const r in t){if(t.hasOwnProperty(r))e[t[r]]=r}return e};var pt=(t={})=>{return new URLSearchParams(t).toString()};var gt=(t=6)=>{return Math.random().toString(20).substr(2,t)};var ft=(t,e)=>{const r=/{{(.*?)}}/g;return t.replace(r,(n,o,s)=>{n=0;s=e;o=o.trim().split(".");while(s&&n<o.length)s=s[o[n++]];return s!=null?s:""})};function mt(t,e=false,r=false){const n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";const o="0123456789";const s="!@#$%^&*_-+=";let i=n;r?i+=o:"";e?i+=s:"";let a="";for(let c=0;c<t;c++){a+=i.charAt(Math.floor(Math.random()*i.length))}return a}var yt=(...t)=>e=>t.reduceRight((r,n)=>r.then(n),Promise.resolve(e));var ht=t=>typeof t!=="undefined";var bt=t=>typeof t==="boolean";var wt=t=>typeof t==="function";var Tt=t=>typeof t==="number";var St=t=>typeof t==="string";var At=t=>l(t)==="[object Object]";export{x as assert,v as autoParseValues,K as capitalize,J as capitalizeEveryWord,at as clearUndefined,rt as clone,D as common,yt as composeAsync,P as debounce,W as decrypt,L as difference,_ as dropRight,G as encrypt,ut as ensurePrefix,H as enumToString,j as fixedDecimal,C as flattenDeep,$ as formatDuration,gt as generateRandomString,nt as groupBy,lt as invertObj,bt as isBoolean,V as isDate,ht as isDef,m as isEmpty,wt as isFunction,et as isNotEmpty,Tt as isNumber,At as isObject,St as isString,U as lowerFirst,d as noop,st as normalizeEmail,F as objectArrayToArray,M as omit,R as orderBy,Q as orderedToken,S as pick,E as pluck,Y as randomHex,y as randomNumber,mt as randomString,X as readFile,T as removeEmpty,N as renameKeys,A as resolverArgs,ot as shuffle,ct as slash,it as slugify,Z as strAfter,tt as strBefore,pt as stringifyQueryParams,O as sumOfAnArray,ft as template,z as throttle,B as timeTaken,l as toString,I as unescapeHTML,q as union,k as unique};
var d=(t,e)=>{if(!t)throw new Error(e)},l=t=>Object.prototype.toString.call(t),h=()=>{};import p from"crypto";import g from"fs";var f=/\./g,y=t=>[Object,Array].includes((t||{}).constructor)&&!Object.entries(t||{}).length,S=t=>Object.entries(t).reduce((e,[n,r])=>r===null?e:{...e,[n]:r},{}),O=(t,e)=>{let n={};return e.forEach(r=>{n[r]=t[r]}),n},A=(...t)=>JSON.stringify(t),k=(t,e=0)=>t.reduce((n,r)=>n+r,e),M=t=>[...new Set(t)],R=(t,e)=>{let n={...t};return e.forEach(r=>delete n[r]),n},E=(t,e,n)=>{[...t].sort((r,o)=>e.reduce((s,i,a)=>{if(s===0){let[c,u]=n&&n[a]==="desc"?[o[i],r[i]]:[r[i],o[i]];s=c>u?1:c<u?-1:0}return s},0))};var N=(t,e)=>t.map(n=>n[e]),D=(t,e)=>{Object.keys(e).reduce((n,r)=>({...n,[t[r]||r]:e[r]}),{})},F=(t,e)=>t.map(n=>n[e]),j=(t,e=2)=>{let n=new RegExp(`^-?\\d+(?:.\\d{0,${e||-1}})?`);return parseFloat(t.toString().match(n)[0])},v=t=>!!JSON.parse(t)===JSON.parse(t)?JSON.parse(t.toLowerCase()):isNaN(Number(t))?t:parseFloat(t),C=t=>t.flat(1/0),m=(t,e)=>t.filter(n=>!e.includes(n)),L=(t,e)=>t.filter(n=>e.includes(n)),I=t=>t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"",K=(t,e,n)=>{let r;return function(){let o=this,s=arguments,i=function(){r=null,n||t.apply(o,s)},a=n&&!r;clearTimeout(r),r=setTimeout(i,e),a&&t.apply(o,s)}},P=t=>{console.time("timeTaken");let e=t();return console.timeEnd("timeTaken"),e},B=t=>t.replace(/&amp;|&lt;|&gt;|&#39;|&quot;/g,e=>({"&amp;":"&","&lt;":"<","&gt;":">","&#39;":"'","&quot;":'"'})[e]||e),z=(t,e)=>{let n=null,r=null,o=void 0,s=()=>{t.apply(o,r),n=null};return function(){n||(r=arguments,n=setTimeout(s,e))}},$=t=>{t<0&&(t=-t);let e={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(e).filter(n=>n[1]!==0).map(([n,r])=>`${r} ${n}${r!==1?"s":""}`).join(", ")},J=t=>t.replace(/\b[a-z]/g,e=>e.toUpperCase()),U=t=>t?t.charAt(0).toLowerCase()+t.slice(1):"",q=(t,e,n=!0)=>n?Array.from([...t,...e]):Array.from(new Set([...t,...e])),V=t=>new Date(t)instanceof Date,W=(t,e=1)=>t.slice(0,-e),_=(t,e)=>{let n=Buffer.from(e.key,"hex"),r=Buffer.from(e.iv,"hex"),o=p.createCipheriv("aes-256-cbc",n,r),s=o.update(t,"utf8","base64");return s+=o.final("base64"),s},G=t=>Object.keys(t).map(e=>t[e]).filter(e=>typeof e=="string"),H=(t,e)=>{let n=Buffer.from(e.key,"hex"),r=Buffer.from(e.iv,"hex"),o=p.createDecipheriv("aes-256-cbc",n,r);return o.update(t,"base64","utf8")+o.final("utf8")},X=t=>new Promise((e,n)=>{g.readFile(t,{encoding:"utf-8"},(r,o)=>{r?n(r):e(o)})}),x=(t=1,e=9)=>{let n=Math.ceil(Math.min(t,e)),r=Math.floor(Math.max(t,e));return Math.floor(n+Math.random()*(r-n+1))},Y=t=>[...Array(t)].map(()=>Math.floor(Math.random()*16).toString(16)).join(""),Q=(t,e="X")=>{for(;t.includes(e);)t=t.replace(e,String(x()));return t},Z=(t,e)=>t.split(e)[1],tt=(t,e)=>t.split(e)[0],et=t=>!y(t),nt=t=>{let e=new t.constructor;return Object.assign(e,t),e},rt=(t,e)=>t.reduce((n,r)=>(n[r[e]]||(n[r[e]]=[]),n[r[e]].push(r),n),{}),ot=t=>{let e=t.length;for(;e>0;){let n=Math.floor(Math.random()*e--),r=t[e];t[e]=t[n],t[n]=r}return t},st=t=>{let[e,n]=t.split("@"),[r]=e.split("+");r=r.replace(f,"");let o=`${r.toLowerCase()}@${n.toLowerCase()}`;return Number(o),o},it=(t,e={lowercase:!0,separator:"-",trim:!0})=>{let n=t.toString().normalize("NFD").replace(/[\u0300-\u036F]/g,"");return e.lowercase&&n.toLowerCase(),e.trim&&n.trim(),n.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,e.separator)},at=t=>(Object.keys(t).forEach(e=>t[e]===void 0?delete t[e]:{}),t),ct=t=>t.replace(/\\/g,"/"),ut=(t,e)=>e.startsWith(t)?e:t+e,lt=t=>{let e={};for(let n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e},pt=(t={})=>new URLSearchParams(t).toString(),gt=(t=6)=>Math.random().toString(20).substr(2,t),ft=(t,e)=>{let n=/{{(.*?)}}/g;return t.replace(n,(r,o,s)=>{for(r=0,s=e,o=o.trim().split(".");s&&r<o.length;)s=s[o[r++]];return s??""})};function yt(t,e=!1,n=!1){let r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",o="0123456789",s="!@#$%^&*_-+=",i=r;n&&(i+=o),e&&(i+=s);let a="";for(let c=0;c<t;c++)a+=i.charAt(Math.floor(Math.random()*i.length));return a}var mt=(...t)=>e=>t.reduceRight((n,r)=>n.then(r),Promise.resolve(e)),xt=(t,e)=>m(t,e),dt=(t,e)=>t.toISOString()===e.toISOString(),ht=(t,e)=>{for(;t.length>0&&!e(t[0]);)t=t.slice(1);return t},bt=(t,e=1)=>t.slice(e);var St=t=>typeof t<"u",Ot=t=>typeof t=="boolean",At=t=>typeof t=="function",kt=t=>typeof t=="number",Mt=t=>typeof t=="string",Rt=t=>l(t)==="[object Object]";export{d as assert,v as autoParseValues,I as capitalize,J as capitalizeEveryWord,at as clearUndefined,nt as clone,L as common,mt as composeAsync,K as debounce,H as decrypt,m as difference,bt as drop,W as dropRight,ht as dropWhile,_ as encrypt,ut as ensurePrefix,G as enumToString,j as fixedDecimal,C as flattenDeep,$ as formatDuration,gt as generateRandomString,rt as groupBy,xt as intersection,lt as invertObj,Ot as isBoolean,V as isDate,St as isDef,y as isEmpty,At as isFunction,et as isNotEmpty,kt as isNumber,Rt as isObject,dt as isSameDate,Mt as isString,U as lowerFirst,h as noop,st as normalizeEmail,F as objectArrayToArray,R as omit,E as orderBy,Q as orderedToken,O as pick,N as pluck,Y as randomHex,x as randomNumber,yt as randomString,X as readFile,S as removeEmpty,D as renameKeys,A as resolverArgs,ot as shuffle,ct as slash,it as slugify,Z as strAfter,tt as strBefore,pt as stringifyQueryParams,k as sumOfAnArray,ft as template,z as throttle,P as timeTaken,l as toString,B as unescapeHTML,q as union,M as unique};
{
"name": "helper-fns",
"type": "module",
"version": "2.5.19",
"version": "2.5.20",
"packageManager": "pnpm@7.2.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc