Comparing version 0.2.1 to 0.2.2
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=["string","bigint","number","boolean"];function e(t){return!("object"!=typeof t||!t)&&t.constructor===Object}function r(e){return t.includes(typeof e)}function n(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function o(t,e){return Math.random()*(e-t)+t}exports.calcPercentOfNum=function(t,e){return t*e/100},exports.calcWhatPercent=function(t,e){return 100*t/e},exports.chunk=function(t,e){if(e<1)throw new RangeError("chunkSize must be 1 or greater.");if(!Number.isInteger(e))throw new TypeError("chunkSize must be an integer.");const r=t.slice(),n=[];for(;r.length;)n.push(r.splice(0,e));return n},exports.debounce=(t,e)=>{let r=null;return(...n)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},exports.deepClone=function t(n){if(null===n||r(n))return n;if(Array.isArray(n)){const e=[];for(const r of n)e.push(t(r));return e}if(e(n)){const e={};for(const[r,o]of Object.entries(n))e[r]=t(o);return e}if(n instanceof Map){const e=new n.constructor;for(const[r,o]of n.entries())e.set(r,t(o));return e}if(n instanceof Set){const e=new n.constructor;for(const r of n.values())e.add(t(r));return e}return n},exports.increaseNumByPercent=function(t,e){return e<=0?t:t+t*(e/100)},exports.isObject=e,exports.isPrimitive=r,exports.noOp=function(){},exports.notEmpty=function(t){return null!=t},exports.objectEntries=function(t){return Object.entries(t)},exports.objectKeys=function(t){return Object.keys(t)},exports.objectValues=function(t){return Object.values(t)},exports.percentChance=function(t){return o(0,100)<t},exports.primitiveTypes=t,exports.randArrItem=function(t){return t[Math.floor(Math.random()*t.length)]},exports.randFloat=o,exports.randInt=n,exports.reduceNumByPercent=function(t,e){return e<=0?t:t-t*(e/100)},exports.roll=function(t){return 1===n(1,t)},exports.round=function(t,e=1){const r=Math.pow(10,e||0);return Math.round(t*r)/r},exports.shuffleArr=function(t){let e=[...t];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e},exports.sleep=function(t){return new Promise(e=>setTimeout(e,t))},exports.sumArr=function(t){return t.reduce((t,e)=>t+e,0)},exports.uniqueArr=function(t){return[...new Set(t)]}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=["string","bigint","number","boolean"];function e(t){return!("object"!=typeof t||!t)&&t.constructor===Object}function r(e){return t.includes(typeof e)}function n(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function o(t,e){return Math.random()*(e-t)+t}exports.calcPercentOfNum=function(t,e){return t*e/100},exports.calcWhatPercent=function(t,e){return 100*t/e},exports.chunk=function(t,e){if(e<1)throw new RangeError("chunkSize must be 1 or greater.");if(!Number.isInteger(e))throw new TypeError("chunkSize must be an integer.");const r=t.slice(),n=[];for(;r.length;)n.push(r.splice(0,e));return n},exports.debounce=(t,e)=>{let r=null;return(...n)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},exports.deepClone=function t(n){if(null===n||r(n))return n;if(Array.isArray(n)){const e=[];for(const r of n)e.push(t(r));return e}if(e(n)){const e={};for(const[r,o]of Object.entries(n))e[r]=t(o);return e}if(n instanceof Map){const e=new n.constructor;for(const[r,o]of n.entries())e.set(r,t(o));return e}if(n instanceof Set){const e=new n.constructor;for(const r of n.values())e.add(t(r));return e}return n},exports.increaseNumByPercent=function(t,e){return e<=0?t:t+t*(e/100)},exports.isObject=e,exports.isPrimitive=r,exports.noOp=function(){},exports.notEmpty=function(t){return null!=t},exports.objectEntries=function(t){return Object.entries(t)},exports.objectKeys=function(t){return Object.keys(t)},exports.objectValues=function(t){return Object.values(t)},exports.partition=function(t,e){const r=[],n=[];for(const o of t)(e(o)?r:n).push(o);return[r,n]},exports.percentChance=function(t){return o(0,100)<t},exports.primitiveTypes=t,exports.randArrItem=function(t){return t[Math.floor(Math.random()*t.length)]},exports.randFloat=o,exports.randInt=n,exports.reduceNumByPercent=function(t,e){return e<=0?t:t-t*(e/100)},exports.roll=function(t){return 1===n(1,t)},exports.round=function(t,e=1){const r=Math.pow(10,e||0);return Math.round(t*r)/r},exports.shuffleArr=function(t){let e=[...t];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e},exports.sleep=function(t){return new Promise(e=>setTimeout(e,t))},exports.sumArr=function(t){return t.reduce((t,e)=>t+e,0)},exports.uniqueArr=function(t){return[...new Set(t)]}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).e={})}(this,(function(n){"use strict";const e=["string","bigint","number","boolean"];function t(n){return!("object"!=typeof n||!n)&&n.constructor===Object}function r(n){return e.includes(typeof n)}function o(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function u(n,e){return Math.random()*(e-n)+n}n.calcPercentOfNum=function(n,e){return n*e/100},n.calcWhatPercent=function(n,e){return 100*n/e},n.chunk=function(n,e){if(e<1)throw new RangeError("chunkSize must be 1 or greater.");if(!Number.isInteger(e))throw new TypeError("chunkSize must be an integer.");const t=n.slice(),r=[];for(;t.length;)r.push(t.splice(0,e));return r},n.debounce=(n,e)=>{let t=null;return(...r)=>{null!==t&&(clearTimeout(t),t=null),t=setTimeout(()=>n(...r),e)}},n.deepClone=function n(e){if(null===e||r(e))return e;if(Array.isArray(e)){const t=[];for(const r of e)t.push(n(r));return t}if(t(e)){const t={};for(const[r,o]of Object.entries(e))t[r]=n(o);return t}if(e instanceof Map){const t=new e.constructor;for(const[r,o]of e.entries())t.set(r,n(o));return t}if(e instanceof Set){const t=new e.constructor;for(const r of e.values())t.add(n(r));return t}return e},n.increaseNumByPercent=function(n,e){return e<=0?n:n+n*(e/100)},n.isObject=t,n.isPrimitive=r,n.noOp=function(){},n.notEmpty=function(n){return null!=n},n.objectEntries=function(n){return Object.entries(n)},n.objectKeys=function(n){return Object.keys(n)},n.objectValues=function(n){return Object.values(n)},n.percentChance=function(n){return u(0,100)<n},n.primitiveTypes=e,n.randArrItem=function(n){return n[Math.floor(Math.random()*n.length)]},n.randFloat=u,n.randInt=o,n.reduceNumByPercent=function(n,e){return e<=0?n:n-n*(e/100)},n.roll=function(n){return 1===o(1,n)},n.round=function(n,e=1){const t=Math.pow(10,e||0);return Math.round(n*t)/t},n.shuffleArr=function(n){let e=[...n];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},n.sleep=function(n){return new Promise(e=>setTimeout(e,n))},n.sumArr=function(n){return n.reduce((n,e)=>n+e,0)},n.uniqueArr=function(n){return[...new Set(n)]},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).e={})}(this,(function(n){"use strict";const e=["string","bigint","number","boolean"];function t(n){return!("object"!=typeof n||!n)&&n.constructor===Object}function r(n){return e.includes(typeof n)}function o(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function u(n,e){return Math.random()*(e-n)+n}n.calcPercentOfNum=function(n,e){return n*e/100},n.calcWhatPercent=function(n,e){return 100*n/e},n.chunk=function(n,e){if(e<1)throw new RangeError("chunkSize must be 1 or greater.");if(!Number.isInteger(e))throw new TypeError("chunkSize must be an integer.");const t=n.slice(),r=[];for(;t.length;)r.push(t.splice(0,e));return r},n.debounce=(n,e)=>{let t=null;return(...r)=>{null!==t&&(clearTimeout(t),t=null),t=setTimeout(()=>n(...r),e)}},n.deepClone=function n(e){if(null===e||r(e))return e;if(Array.isArray(e)){const t=[];for(const r of e)t.push(n(r));return t}if(t(e)){const t={};for(const[r,o]of Object.entries(e))t[r]=n(o);return t}if(e instanceof Map){const t=new e.constructor;for(const[r,o]of e.entries())t.set(r,n(o));return t}if(e instanceof Set){const t=new e.constructor;for(const r of e.values())t.add(n(r));return t}return e},n.increaseNumByPercent=function(n,e){return e<=0?n:n+n*(e/100)},n.isObject=t,n.isPrimitive=r,n.noOp=function(){},n.notEmpty=function(n){return null!=n},n.objectEntries=function(n){return Object.entries(n)},n.objectKeys=function(n){return Object.keys(n)},n.objectValues=function(n){return Object.values(n)},n.partition=function(n,e){const t=[],r=[];for(const o of n)(e(o)?t:r).push(o);return[t,r]},n.percentChance=function(n){return u(0,100)<n},n.primitiveTypes=e,n.randArrItem=function(n){return n[Math.floor(Math.random()*n.length)]},n.randFloat=u,n.randInt=o,n.reduceNumByPercent=function(n,e){return e<=0?n:n-n*(e/100)},n.roll=function(n){return 1===o(1,n)},n.round=function(n,e=1){const t=Math.pow(10,e||0);return Math.round(n*t)/t},n.shuffleArr=function(n){let e=[...n];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},n.sleep=function(n){return new Promise(e=>setTimeout(e,n))},n.sumArr=function(n){return n.reduce((n,e)=>n+e,0)},n.uniqueArr=function(n){return[...new Set(n)]},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -30,2 +30,8 @@ /** | ||
export declare function shuffleArr<T>(array: readonly T[]): T[]; | ||
/** | ||
* | ||
* @param arr The array to partition | ||
* @param filter The filter by which to partition the array | ||
*/ | ||
export declare function partition<T>(arr: T[], filter: (item: T) => boolean): [T[], T[]]; | ||
//# sourceMappingURL=array.d.ts.map |
{ | ||
"name": "e", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A modern universal utility library.", | ||
@@ -5,0 +5,0 @@ "author": "gc", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
56055
167