UNPKG

2.47 kBJavaScriptView Raw
1const n=["string","bigint","number","boolean"];function t(n){return Object.entries(n)}function r(n){return Object.values(n)}function e(n){return Object.keys(n)}function o(n){return null!=n}function u(n){return new Promise(t=>setTimeout(t,n))}function c(){}const i=(n,t)=>{let r=null;return(...e)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>n(...e),t)}};function f(n){return!("object"!=typeof n||!n)&&n.constructor===Object}function s(t){return n.includes(typeof t)}function a(n){return"function"==typeof n}function l(n){if(null===n||s(n))return n;if(Array.isArray(n)){const t=[];for(const r of n)t.push(l(r));return t}if(f(n)){const t={};for(const[r,e]of Object.entries(n))t[r]=l(e);return t}if(n instanceof Map){const t=new n.constructor;for(const[r,e]of n.entries())t.set(r,l(e));return t}if(n instanceof Set){const t=new n.constructor;for(const r of n.values())t.add(l(r));return t}return n}function h(n,t){return 100*n/t}function m(n,t){return n*t/100}function b(n,t){return t<=0?n:n-n*(t/100)}function M(n,t){return t<=0?n:n+n*(t/100)}function p(n){return n[Math.floor(Math.random()*n.length)]}function d(n,t){if(t<1)throw new RangeError("chunkSize must be 1 or greater.");if(!Number.isInteger(t))throw new TypeError("chunkSize must be an integer.");const r=n.slice(),e=[];for(;r.length;)e.push(r.splice(0,t));return e}function g(n){return[...new Set(n)]}function w(n){return n.reduce((n,t)=>n+t,0)}function y(n){let t=[...n];for(let n=t.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1));[t[n],t[r]]=[t[r],t[n]]}return t}function j(n,t){const r=[],e=[];for(const o of n)(t(o)?r:e).push(o);return[r,e]}function O(n,t){return Math.floor(Math.random()*(t-n+1)+n)}function S(n,t){return Math.random()*(t-n)+n}function T(n){return 1===O(1,n)}function k(n){return S(0,100)<n}function v(n,t=1){const r=Math.pow(10,t||0);return Math.round(n*r)/r}function x(n,t,r){return Math.min(r,Math.max(t,n))}function z(n,t,r,e,o){return(n-t)*(o-e)/(r-t)+e}export{m as calcPercentOfNum,h as calcWhatPercent,d as chunk,x as clamp,i as debounce,l as deepClone,M as increaseNumByPercent,a as isFunction,f as isObject,s as isPrimitive,c as noOp,o as notEmpty,t as objectEntries,e as objectKeys,r as objectValues,j as partition,k as percentChance,n as primitiveTypes,p as randArrItem,S as randFloat,O as randInt,b as reduceNumByPercent,T as roll,v as round,z as scaleNumber,y as shuffleArr,u as sleep,w as sumArr,g as uniqueArr};
2//# sourceMappingURL=index.es.mjs.map