@jonahsnider/util
Advanced tools
Comparing version 2.10.1 to 2.10.2
@@ -49,5 +49,3 @@ /** | ||
*/ | ||
export declare function mean(previousValue: number, currentValue: number, currentIndex: number, array: Readonly<{ | ||
length: number; | ||
}>): number; | ||
export declare function mean(previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]): number; | ||
/** | ||
@@ -71,5 +69,3 @@ * Get the mean of an array of `bigint`s. | ||
*/ | ||
export declare function mean(previousValue: bigint, currentValue: bigint, currentIndex: number, array: Readonly<{ | ||
length: number; | ||
}>): bigint; | ||
export declare function mean(previousValue: bigint, currentValue: bigint, currentIndex: number, array: readonly bigint[]): bigint; | ||
/** | ||
@@ -76,0 +72,0 @@ * Get the largest value of an array of `number`s. |
@@ -544,4 +544,8 @@ 'use strict'; | ||
function truncate(text, maxLength, suffix) { | ||
if (suffix === void 0) { | ||
suffix = ''; | ||
} | ||
if (text.length > maxLength) { | ||
return "" + text.slice(0, maxLength) + (suffix != null ? suffix : ''); | ||
return "" + text.slice(0, maxLength) + suffix; | ||
} | ||
@@ -677,3 +681,3 @@ | ||
if (b.get(key) !== value) { | ||
if (b.get(key) !== value || !b.has(key)) { | ||
return false; | ||
@@ -758,5 +762,5 @@ } | ||
return (previousValue + currentValue) / (typeof currentValue === 'bigint' ? BigInt(array.length) : array.length); | ||
} else { | ||
return previousValue + currentValue; | ||
} | ||
return previousValue + currentValue; | ||
} | ||
@@ -763,0 +767,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function r(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return t(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,void 0):void 0}}(r))||e&&r&&"number"==typeof r.length){n&&(r=n);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}var e,n;Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.Rank||(exports.Rank={}))[e.Ace=1]="Ace",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four",e[e.Five=5]="Five",e[e.Six=6]="Six",e[e.Seven=7]="Seven",e[e.Eight=8]="Eight",e[e.Nine=9]="Nine",e[e.Ten=10]="Ten",e[e.Jack=11]="Jack",e[e.Queen=12]="Queen",e[e.King=13]="King",(n=exports.Suit||(exports.Suit={}))[n.Clubs=0]="Clubs",n[n.Diamonds=1]="Diamonds",n[n.Hearts=2]="Hearts",n[n.Spades=3]="Spades";var o=[{rank:exports.Rank.Ace,suit:exports.Suit.Clubs},{rank:exports.Rank.Two,suit:exports.Suit.Clubs},{rank:exports.Rank.Three,suit:exports.Suit.Clubs},{rank:exports.Rank.Four,suit:exports.Suit.Clubs},{rank:exports.Rank.Five,suit:exports.Suit.Clubs},{rank:exports.Rank.Six,suit:exports.Suit.Clubs},{rank:exports.Rank.Seven,suit:exports.Suit.Clubs},{rank:exports.Rank.Eight,suit:exports.Suit.Clubs},{rank:exports.Rank.Nine,suit:exports.Suit.Clubs},{rank:exports.Rank.Ten,suit:exports.Suit.Clubs},{rank:exports.Rank.Jack,suit:exports.Suit.Clubs},{rank:exports.Rank.Queen,suit:exports.Suit.Clubs},{rank:exports.Rank.King,suit:exports.Suit.Clubs},{rank:exports.Rank.Ace,suit:exports.Suit.Diamonds},{rank:exports.Rank.Two,suit:exports.Suit.Diamonds},{rank:exports.Rank.Three,suit:exports.Suit.Diamonds},{rank:exports.Rank.Four,suit:exports.Suit.Diamonds},{rank:exports.Rank.Five,suit:exports.Suit.Diamonds},{rank:exports.Rank.Six,suit:exports.Suit.Diamonds},{rank:exports.Rank.Seven,suit:exports.Suit.Diamonds},{rank:exports.Rank.Eight,suit:exports.Suit.Diamonds},{rank:exports.Rank.Nine,suit:exports.Suit.Diamonds},{rank:exports.Rank.Ten,suit:exports.Suit.Diamonds},{rank:exports.Rank.Jack,suit:exports.Suit.Diamonds},{rank:exports.Rank.Queen,suit:exports.Suit.Diamonds},{rank:exports.Rank.King,suit:exports.Suit.Diamonds},{rank:exports.Rank.Ace,suit:exports.Suit.Hearts},{rank:exports.Rank.Two,suit:exports.Suit.Hearts},{rank:exports.Rank.Three,suit:exports.Suit.Hearts},{rank:exports.Rank.Four,suit:exports.Suit.Hearts},{rank:exports.Rank.Five,suit:exports.Suit.Hearts},{rank:exports.Rank.Six,suit:exports.Suit.Hearts},{rank:exports.Rank.Seven,suit:exports.Suit.Hearts},{rank:exports.Rank.Eight,suit:exports.Suit.Hearts},{rank:exports.Rank.Nine,suit:exports.Suit.Hearts},{rank:exports.Rank.Ten,suit:exports.Suit.Hearts},{rank:exports.Rank.Jack,suit:exports.Suit.Hearts},{rank:exports.Rank.Queen,suit:exports.Suit.Hearts},{rank:exports.Rank.King,suit:exports.Suit.Hearts},{rank:exports.Rank.Ace,suit:exports.Suit.Spades},{rank:exports.Rank.Two,suit:exports.Suit.Spades},{rank:exports.Rank.Three,suit:exports.Suit.Spades},{rank:exports.Rank.Four,suit:exports.Suit.Spades},{rank:exports.Rank.Five,suit:exports.Suit.Spades},{rank:exports.Rank.Six,suit:exports.Suit.Spades},{rank:exports.Rank.Seven,suit:exports.Suit.Spades},{rank:exports.Rank.Eight,suit:exports.Suit.Spades},{rank:exports.Rank.Nine,suit:exports.Suit.Spades},{rank:exports.Rank.Ten,suit:exports.Suit.Spades},{rank:exports.Rank.Jack,suit:exports.Suit.Spades},{rank:exports.Rank.Queen,suit:exports.Suit.Spades},{rank:exports.Rank.King,suit:exports.Suit.Spades}],a=/^./;function s(t){for(var e,n=t[0].map((function(t){return t.length})),o=r(t);!(e=o()).done;)for(var a=e.value,s=0;s<a.length;s++){var i=a[s].length;n[s]<i&&(n[s]=i)}return n}function i(t,r){return t+r}function u(t,r,e,n){return n.length-1===e?(t+r)/("bigint"==typeof r?BigInt(n.length):n.length):t+r}function p(t){var r=t.reduce(u);return t.map((function(t){return Math.pow(t-r,2)})).reduce(i)/(t.length-1)}function x(t,r,e){return 1/(r*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(t-e/r,2))}function c(t,r){return Math.random()*(r-t)+t}exports.Stopwatch=function(){function t(){}t.start=function(){var t=new this;return t.start(),t};var r,e=t.prototype;return e.start=function(){this.startTime=process.hrtime.bigint()},e.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(r=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,r),t}(),exports.ascending=function(t,r){return t-r},exports.binarySearch=function(t,r){for(var e=0,n=t.length-1;e<=n;){var o=Math.trunc((e+n)/2),a=r(t[o]);if(a<0)e=o+1;else{if(!(a>0))return t[o];n=o-1}}},exports.capitalize=function(t){return t.replace(a,(function(t){return t.toUpperCase()}))},exports.chunk=function(t,r){return t.length===r?t.map((function(t){return[t]})):Array.from({length:Math.ceil(t.length/r)},(function(e,n){return t.slice(n*r,n*r+r)}))},exports.clamp=function(t,r,e){return t<r?r:t>e?e:t},exports.descending=function(t,r){return r-t},exports.first=function(t,r){void 0===r&&(r=1);for(var e=[],n=t[Symbol.iterator](),o=0;o<r;o++){var a=n.next();if(a.done)break;e.push(a.value)}return e},exports.formatTable=function(t,r){void 0===r&&(r=" ");var e=s(t);return t.map((function(t){return t.map((function(t,r){return t.padEnd(e[r])})).join(r)})).join("\n")},exports.frequencyTable=function(t){for(var e,n=new Map,o=r(t);!(e=o()).done;){var a=e.value,s=n.get(a);n.set(a,s?s+1:1)}return n},exports.identical=function(t,r){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];for(var a=[t,r].concat(n).map((function(t){return t[Symbol.iterator]()})),s=function(){var t=a.map((function(t){return t.next()})),r=t[0],e=r.done,n=r.value;return t.some((function(t){return t.done}))?{v:t.every((function(t){return t.done===e}))}:t.some((function(t){return t.value!==n}))?{v:!1}:void 0};;){var i=s();if("object"==typeof i)return i.v}},exports.identicalManual=function(t,e){if(t===e)return!0;if(Array.isArray(t))return t.length===e.length&&t.every((function(t,r){return t===e[r]}));if(t.size!==e.size)return!1;if(t instanceof Set){for(var n,o=r(t);!(n=o()).done;)if(!e.has(n.value))return!1}else if(t instanceof Map)for(var a,s=r(t.entries());!(a=s()).done;){var i=a.value,u=i[1];if(e.get(i[0])!==u)return!1}return!0},exports.max=function(t,r){return Math.max(t,r)},exports.maxColumnLength=s,exports.mean=u,exports.median=function(t){var r=t.length;return r%2==0?(t[r/2-1]+t[r/2])/2:t[Math.floor(r/2)]},exports.min=function(t,r){return Math.min(t,r)},exports.mode=function(t){for(var e,n=new Map,o=0,a=[],s=r(t);!(e=s()).done;){var i=e.value,u=n.get(i),p=void 0===u?1:u+1;n.set(i,p),p>o?(o=p,a=[i]):p===o&&a.push(i)}return a},exports.multiReplace=function(t,e){for(var n=Object.entries(e),o="",a=0;a<t.length;)t:do{for(var s,i=r(n);!(s=i()).done;){var u=s.value,p=u[0],x=u[1];if(t.slice(a).startsWith(p)){o+=x,a+=p.length;break t}}o+=t[a++]}while(0);return o},exports.newDeck=function(){return[].concat(o)},exports.normaldist=x,exports.nullish=function(t){return null==t},exports.partition=function(t,e){for(var n,o=[],a=[],s=0,i=r(t);!(n=i()).done;){var u=n.value;(e(u,s++)?o:a).push(u)}return[o,a]},exports.random=c,exports.randomInt=function(t,r){return Math.floor(c(Math.ceil(t),Math.floor(r)))},exports.reverse=function(t){return Array.from({length:t.length},(function(r,e){return t[t.length-(e+1)]}))},exports.sample=function(t){return t[Math.floor(Math.random()*t.length)]},exports.shuffle=function(t,r){void 0===r&&(r=!0);for(var e=r?t:[].concat(t),n=e.length-1;n>0;n--){var o=Math.floor(Math.random()*(n+1)),a=[e[o],e[n]];e[n]=a[0],e[o]=a[1]}if(!r)return e},exports.sortObject=function(t,r){return Object.fromEntries(Object.entries(t).sort((function(t,e){return r(t[1],e[1])})))},exports.standardNormaldist=function(t){return x(t,1,0)},exports.stddev=function(t){return Math.sqrt(p(t))},exports.sum=i,exports.toDigits=function(t,r){var e=Math.pow(10,r);return Math.round(t*e*(1+Number.EPSILON))/e},exports.truncate=function(t,r,e){return t.length>r?""+t.slice(0,r)+(null!=e?e:""):t},exports.variance=p; | ||
"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function r(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return t(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,void 0):void 0}}(r))||e&&r&&"number"==typeof r.length){n&&(r=n);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}var e,n;Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.Rank||(exports.Rank={}))[e.Ace=1]="Ace",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four",e[e.Five=5]="Five",e[e.Six=6]="Six",e[e.Seven=7]="Seven",e[e.Eight=8]="Eight",e[e.Nine=9]="Nine",e[e.Ten=10]="Ten",e[e.Jack=11]="Jack",e[e.Queen=12]="Queen",e[e.King=13]="King",(n=exports.Suit||(exports.Suit={}))[n.Clubs=0]="Clubs",n[n.Diamonds=1]="Diamonds",n[n.Hearts=2]="Hearts",n[n.Spades=3]="Spades";var o=[{rank:exports.Rank.Ace,suit:exports.Suit.Clubs},{rank:exports.Rank.Two,suit:exports.Suit.Clubs},{rank:exports.Rank.Three,suit:exports.Suit.Clubs},{rank:exports.Rank.Four,suit:exports.Suit.Clubs},{rank:exports.Rank.Five,suit:exports.Suit.Clubs},{rank:exports.Rank.Six,suit:exports.Suit.Clubs},{rank:exports.Rank.Seven,suit:exports.Suit.Clubs},{rank:exports.Rank.Eight,suit:exports.Suit.Clubs},{rank:exports.Rank.Nine,suit:exports.Suit.Clubs},{rank:exports.Rank.Ten,suit:exports.Suit.Clubs},{rank:exports.Rank.Jack,suit:exports.Suit.Clubs},{rank:exports.Rank.Queen,suit:exports.Suit.Clubs},{rank:exports.Rank.King,suit:exports.Suit.Clubs},{rank:exports.Rank.Ace,suit:exports.Suit.Diamonds},{rank:exports.Rank.Two,suit:exports.Suit.Diamonds},{rank:exports.Rank.Three,suit:exports.Suit.Diamonds},{rank:exports.Rank.Four,suit:exports.Suit.Diamonds},{rank:exports.Rank.Five,suit:exports.Suit.Diamonds},{rank:exports.Rank.Six,suit:exports.Suit.Diamonds},{rank:exports.Rank.Seven,suit:exports.Suit.Diamonds},{rank:exports.Rank.Eight,suit:exports.Suit.Diamonds},{rank:exports.Rank.Nine,suit:exports.Suit.Diamonds},{rank:exports.Rank.Ten,suit:exports.Suit.Diamonds},{rank:exports.Rank.Jack,suit:exports.Suit.Diamonds},{rank:exports.Rank.Queen,suit:exports.Suit.Diamonds},{rank:exports.Rank.King,suit:exports.Suit.Diamonds},{rank:exports.Rank.Ace,suit:exports.Suit.Hearts},{rank:exports.Rank.Two,suit:exports.Suit.Hearts},{rank:exports.Rank.Three,suit:exports.Suit.Hearts},{rank:exports.Rank.Four,suit:exports.Suit.Hearts},{rank:exports.Rank.Five,suit:exports.Suit.Hearts},{rank:exports.Rank.Six,suit:exports.Suit.Hearts},{rank:exports.Rank.Seven,suit:exports.Suit.Hearts},{rank:exports.Rank.Eight,suit:exports.Suit.Hearts},{rank:exports.Rank.Nine,suit:exports.Suit.Hearts},{rank:exports.Rank.Ten,suit:exports.Suit.Hearts},{rank:exports.Rank.Jack,suit:exports.Suit.Hearts},{rank:exports.Rank.Queen,suit:exports.Suit.Hearts},{rank:exports.Rank.King,suit:exports.Suit.Hearts},{rank:exports.Rank.Ace,suit:exports.Suit.Spades},{rank:exports.Rank.Two,suit:exports.Suit.Spades},{rank:exports.Rank.Three,suit:exports.Suit.Spades},{rank:exports.Rank.Four,suit:exports.Suit.Spades},{rank:exports.Rank.Five,suit:exports.Suit.Spades},{rank:exports.Rank.Six,suit:exports.Suit.Spades},{rank:exports.Rank.Seven,suit:exports.Suit.Spades},{rank:exports.Rank.Eight,suit:exports.Suit.Spades},{rank:exports.Rank.Nine,suit:exports.Suit.Spades},{rank:exports.Rank.Ten,suit:exports.Suit.Spades},{rank:exports.Rank.Jack,suit:exports.Suit.Spades},{rank:exports.Rank.Queen,suit:exports.Suit.Spades},{rank:exports.Rank.King,suit:exports.Suit.Spades}],a=/^./;function s(t){for(var e,n=t[0].map((function(t){return t.length})),o=r(t);!(e=o()).done;)for(var a=e.value,s=0;s<a.length;s++){var i=a[s].length;n[s]<i&&(n[s]=i)}return n}function i(t,r){return t+r}function u(t,r,e,n){return n.length-1===e?(t+r)/("bigint"==typeof r?BigInt(n.length):n.length):t+r}function p(t){var r=t.reduce(u);return t.map((function(t){return Math.pow(t-r,2)})).reduce(i)/(t.length-1)}function x(t,r,e){return 1/(r*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(t-e/r,2))}function c(t,r){return Math.random()*(r-t)+t}exports.Stopwatch=function(){function t(){}t.start=function(){var t=new this;return t.start(),t};var r,e=t.prototype;return e.start=function(){this.startTime=process.hrtime.bigint()},e.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(r=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,r),t}(),exports.ascending=function(t,r){return t-r},exports.binarySearch=function(t,r){for(var e=0,n=t.length-1;e<=n;){var o=Math.trunc((e+n)/2),a=r(t[o]);if(a<0)e=o+1;else{if(!(a>0))return t[o];n=o-1}}},exports.capitalize=function(t){return t.replace(a,(function(t){return t.toUpperCase()}))},exports.chunk=function(t,r){return t.length===r?t.map((function(t){return[t]})):Array.from({length:Math.ceil(t.length/r)},(function(e,n){return t.slice(n*r,n*r+r)}))},exports.clamp=function(t,r,e){return t<r?r:t>e?e:t},exports.descending=function(t,r){return r-t},exports.first=function(t,r){void 0===r&&(r=1);for(var e=[],n=t[Symbol.iterator](),o=0;o<r;o++){var a=n.next();if(a.done)break;e.push(a.value)}return e},exports.formatTable=function(t,r){void 0===r&&(r=" ");var e=s(t);return t.map((function(t){return t.map((function(t,r){return t.padEnd(e[r])})).join(r)})).join("\n")},exports.frequencyTable=function(t){for(var e,n=new Map,o=r(t);!(e=o()).done;){var a=e.value,s=n.get(a);n.set(a,s?s+1:1)}return n},exports.identical=function(t,r){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];for(var a=[t,r].concat(n).map((function(t){return t[Symbol.iterator]()})),s=function(){var t=a.map((function(t){return t.next()})),r=t[0],e=r.done,n=r.value;return t.some((function(t){return t.done}))?{v:t.every((function(t){return t.done===e}))}:t.some((function(t){return t.value!==n}))?{v:!1}:void 0};;){var i=s();if("object"==typeof i)return i.v}},exports.identicalManual=function(t,e){if(t===e)return!0;if(Array.isArray(t))return t.length===e.length&&t.every((function(t,r){return t===e[r]}));if(t.size!==e.size)return!1;if(t instanceof Set){for(var n,o=r(t);!(n=o()).done;)if(!e.has(n.value))return!1}else if(t instanceof Map)for(var a,s=r(t.entries());!(a=s()).done;){var i=a.value,u=i[0],p=i[1];if(e.get(u)!==p||!e.has(u))return!1}return!0},exports.max=function(t,r){return Math.max(t,r)},exports.maxColumnLength=s,exports.mean=u,exports.median=function(t){var r=t.length;return r%2==0?(t[r/2-1]+t[r/2])/2:t[Math.floor(r/2)]},exports.min=function(t,r){return Math.min(t,r)},exports.mode=function(t){for(var e,n=new Map,o=0,a=[],s=r(t);!(e=s()).done;){var i=e.value,u=n.get(i),p=void 0===u?1:u+1;n.set(i,p),p>o?(o=p,a=[i]):p===o&&a.push(i)}return a},exports.multiReplace=function(t,e){for(var n=Object.entries(e),o="",a=0;a<t.length;)t:do{for(var s,i=r(n);!(s=i()).done;){var u=s.value,p=u[0],x=u[1];if(t.slice(a).startsWith(p)){o+=x,a+=p.length;break t}}o+=t[a++]}while(0);return o},exports.newDeck=function(){return[].concat(o)},exports.normaldist=x,exports.nullish=function(t){return null==t},exports.partition=function(t,e){for(var n,o=[],a=[],s=0,i=r(t);!(n=i()).done;){var u=n.value;(e(u,s++)?o:a).push(u)}return[o,a]},exports.random=c,exports.randomInt=function(t,r){return Math.floor(c(Math.ceil(t),Math.floor(r)))},exports.reverse=function(t){return Array.from({length:t.length},(function(r,e){return t[t.length-(e+1)]}))},exports.sample=function(t){return t[Math.floor(Math.random()*t.length)]},exports.shuffle=function(t,r){void 0===r&&(r=!0);for(var e=r?t:[].concat(t),n=e.length-1;n>0;n--){var o=Math.floor(Math.random()*(n+1)),a=[e[o],e[n]];e[n]=a[0],e[o]=a[1]}if(!r)return e},exports.sortObject=function(t,r){return Object.fromEntries(Object.entries(t).sort((function(t,e){return r(t[1],e[1])})))},exports.standardNormaldist=function(t){return x(t,1,0)},exports.stddev=function(t){return Math.sqrt(p(t))},exports.sum=i,exports.toDigits=function(t,r){var e=Math.pow(10,r);return Math.round(t*e*(1+Number.EPSILON))/e},exports.truncate=function(t,r,e){return void 0===e&&(e=""),t.length>r?""+t.slice(0,r)+e:t},exports.variance=p; | ||
//# sourceMappingURL=util.cjs.production.min.js.map |
@@ -546,4 +546,8 @@ (function (global, factory) { | ||
function truncate(text, maxLength, suffix) { | ||
if (suffix === void 0) { | ||
suffix = ''; | ||
} | ||
if (text.length > maxLength) { | ||
return "" + text.slice(0, maxLength) + (suffix != null ? suffix : ''); | ||
return "" + text.slice(0, maxLength) + suffix; | ||
} | ||
@@ -679,3 +683,3 @@ | ||
if (b.get(key) !== value) { | ||
if (b.get(key) !== value || !b.has(key)) { | ||
return false; | ||
@@ -760,5 +764,5 @@ } | ||
return (previousValue + currentValue) / (typeof currentValue === 'bigint' ? BigInt(array.length) : array.length); | ||
} else { | ||
return previousValue + currentValue; | ||
} | ||
return previousValue + currentValue; | ||
} | ||
@@ -765,0 +769,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self)["@jonahsnider/util"]={})}(this,(function(n){"use strict";function t(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function r(n,r){var e;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(e=function(n,r){if(n){if("string"==typeof n)return t(n,void 0);var e=Object.prototype.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?t(n,void 0):void 0}}(n))||r&&n&&"number"==typeof n.length){e&&(n=e);var a=0;return function(){return a>=n.length?{done:!0}:{done:!1,value:n[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(e=n[Symbol.iterator]()).next.bind(e)}var e,a;(e=n.Rank||(n.Rank={}))[e.Ace=1]="Ace",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four",e[e.Five=5]="Five",e[e.Six=6]="Six",e[e.Seven=7]="Seven",e[e.Eight=8]="Eight",e[e.Nine=9]="Nine",e[e.Ten=10]="Ten",e[e.Jack=11]="Jack",e[e.Queen=12]="Queen",e[e.King=13]="King",(a=n.Suit||(n.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var i=[{rank:n.Rank.Ace,suit:n.Suit.Clubs},{rank:n.Rank.Two,suit:n.Suit.Clubs},{rank:n.Rank.Three,suit:n.Suit.Clubs},{rank:n.Rank.Four,suit:n.Suit.Clubs},{rank:n.Rank.Five,suit:n.Suit.Clubs},{rank:n.Rank.Six,suit:n.Suit.Clubs},{rank:n.Rank.Seven,suit:n.Suit.Clubs},{rank:n.Rank.Eight,suit:n.Suit.Clubs},{rank:n.Rank.Nine,suit:n.Suit.Clubs},{rank:n.Rank.Ten,suit:n.Suit.Clubs},{rank:n.Rank.Jack,suit:n.Suit.Clubs},{rank:n.Rank.Queen,suit:n.Suit.Clubs},{rank:n.Rank.King,suit:n.Suit.Clubs},{rank:n.Rank.Ace,suit:n.Suit.Diamonds},{rank:n.Rank.Two,suit:n.Suit.Diamonds},{rank:n.Rank.Three,suit:n.Suit.Diamonds},{rank:n.Rank.Four,suit:n.Suit.Diamonds},{rank:n.Rank.Five,suit:n.Suit.Diamonds},{rank:n.Rank.Six,suit:n.Suit.Diamonds},{rank:n.Rank.Seven,suit:n.Suit.Diamonds},{rank:n.Rank.Eight,suit:n.Suit.Diamonds},{rank:n.Rank.Nine,suit:n.Suit.Diamonds},{rank:n.Rank.Ten,suit:n.Suit.Diamonds},{rank:n.Rank.Jack,suit:n.Suit.Diamonds},{rank:n.Rank.Queen,suit:n.Suit.Diamonds},{rank:n.Rank.King,suit:n.Suit.Diamonds},{rank:n.Rank.Ace,suit:n.Suit.Hearts},{rank:n.Rank.Two,suit:n.Suit.Hearts},{rank:n.Rank.Three,suit:n.Suit.Hearts},{rank:n.Rank.Four,suit:n.Suit.Hearts},{rank:n.Rank.Five,suit:n.Suit.Hearts},{rank:n.Rank.Six,suit:n.Suit.Hearts},{rank:n.Rank.Seven,suit:n.Suit.Hearts},{rank:n.Rank.Eight,suit:n.Suit.Hearts},{rank:n.Rank.Nine,suit:n.Suit.Hearts},{rank:n.Rank.Ten,suit:n.Suit.Hearts},{rank:n.Rank.Jack,suit:n.Suit.Hearts},{rank:n.Rank.Queen,suit:n.Suit.Hearts},{rank:n.Rank.King,suit:n.Suit.Hearts},{rank:n.Rank.Ace,suit:n.Suit.Spades},{rank:n.Rank.Two,suit:n.Suit.Spades},{rank:n.Rank.Three,suit:n.Suit.Spades},{rank:n.Rank.Four,suit:n.Suit.Spades},{rank:n.Rank.Five,suit:n.Suit.Spades},{rank:n.Rank.Six,suit:n.Suit.Spades},{rank:n.Rank.Seven,suit:n.Suit.Spades},{rank:n.Rank.Eight,suit:n.Suit.Spades},{rank:n.Rank.Nine,suit:n.Suit.Spades},{rank:n.Rank.Ten,suit:n.Suit.Spades},{rank:n.Rank.Jack,suit:n.Suit.Spades},{rank:n.Rank.Queen,suit:n.Suit.Spades},{rank:n.Rank.King,suit:n.Suit.Spades}],u=/^./;function o(n){for(var t,e=n[0].map((function(n){return n.length})),a=r(n);!(t=a()).done;)for(var i=t.value,u=0;u<i.length;u++){var o=i[u].length;e[u]<o&&(e[u]=o)}return e}function s(n,t){return n+t}function f(n,t,r,e){return e.length-1===r?(n+t)/("bigint"==typeof t?BigInt(e.length):e.length):n+t}function c(n){var t=n.reduce(f);return n.map((function(n){return Math.pow(n-t,2)})).reduce(s)/(n.length-1)}function k(n,t,r){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(n-r/t,2))}function l(n,t){return Math.random()*(t-n)+n}n.Stopwatch=function(){function n(){}n.start=function(){var n=new this;return n.start(),n};var t,r=n.prototype;return r.start=function(){this.startTime=process.hrtime.bigint()},r.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(t=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}(n.prototype,t),n}(),n.ascending=function(n,t){return n-t},n.binarySearch=function(n,t){for(var r=0,e=n.length-1;r<=e;){var a=Math.trunc((r+e)/2),i=t(n[a]);if(i<0)r=a+1;else{if(!(i>0))return n[a];e=a-1}}},n.capitalize=function(n){return n.replace(u,(function(n){return n.toUpperCase()}))},n.chunk=function(n,t){return n.length===t?n.map((function(n){return[n]})):Array.from({length:Math.ceil(n.length/t)},(function(r,e){return n.slice(e*t,e*t+t)}))},n.clamp=function(n,t,r){return n<t?t:n>r?r:n},n.descending=function(n,t){return t-n},n.first=function(n,t){void 0===t&&(t=1);for(var r=[],e=n[Symbol.iterator](),a=0;a<t;a++){var i=e.next();if(i.done)break;r.push(i.value)}return r},n.formatTable=function(n,t){void 0===t&&(t=" ");var r=o(n);return n.map((function(n){return n.map((function(n,t){return n.padEnd(r[t])})).join(t)})).join("\n")},n.frequencyTable=function(n){for(var t,e=new Map,a=r(n);!(t=a()).done;){var i=t.value,u=e.get(i);e.set(i,u?u+1:1)}return e},n.identical=function(n,t){for(var r=arguments.length,e=new Array(r>2?r-2:0),a=2;a<r;a++)e[a-2]=arguments[a];for(var i=[n,t].concat(e).map((function(n){return n[Symbol.iterator]()})),u=function(){var n=i.map((function(n){return n.next()})),t=n[0],r=t.done,e=t.value;return n.some((function(n){return n.done}))?{v:n.every((function(n){return n.done===r}))}:n.some((function(n){return n.value!==e}))?{v:!1}:void 0};;){var o=u();if("object"==typeof o)return o.v}},n.identicalManual=function(n,t){if(n===t)return!0;if(Array.isArray(n))return n.length===t.length&&n.every((function(n,r){return n===t[r]}));if(n.size!==t.size)return!1;if(n instanceof Set){for(var e,a=r(n);!(e=a()).done;)if(!t.has(e.value))return!1}else if(n instanceof Map)for(var i,u=r(n.entries());!(i=u()).done;){var o=i.value,s=o[1];if(t.get(o[0])!==s)return!1}return!0},n.max=function(n,t){return Math.max(n,t)},n.maxColumnLength=o,n.mean=f,n.median=function(n){var t=n.length;return t%2==0?(n[t/2-1]+n[t/2])/2:n[Math.floor(t/2)]},n.min=function(n,t){return Math.min(n,t)},n.mode=function(n){for(var t,e=new Map,a=0,i=[],u=r(n);!(t=u()).done;){var o=t.value,s=e.get(o),f=void 0===s?1:s+1;e.set(o,f),f>a?(a=f,i=[o]):f===a&&i.push(o)}return i},n.multiReplace=function(n,t){for(var e=Object.entries(t),a="",i=0;i<n.length;)n:do{for(var u,o=r(e);!(u=o()).done;){var s=u.value,f=s[0],c=s[1];if(n.slice(i).startsWith(f)){a+=c,i+=f.length;break n}}a+=n[i++]}while(0);return a},n.newDeck=function(){return[].concat(i)},n.normaldist=k,n.nullish=function(n){return null==n},n.partition=function(n,t){for(var e,a=[],i=[],u=0,o=r(n);!(e=o()).done;){var s=e.value;(t(s,u++)?a:i).push(s)}return[a,i]},n.random=l,n.randomInt=function(n,t){return Math.floor(l(Math.ceil(n),Math.floor(t)))},n.reverse=function(n){return Array.from({length:n.length},(function(t,r){return n[n.length-(r+1)]}))},n.sample=function(n){return n[Math.floor(Math.random()*n.length)]},n.shuffle=function(n,t){void 0===t&&(t=!0);for(var r=t?n:[].concat(n),e=r.length-1;e>0;e--){var a=Math.floor(Math.random()*(e+1)),i=[r[a],r[e]];r[e]=i[0],r[a]=i[1]}if(!t)return r},n.sortObject=function(n,t){return Object.fromEntries(Object.entries(n).sort((function(n,r){return t(n[1],r[1])})))},n.standardNormaldist=function(n){return k(n,1,0)},n.stddev=function(n){return Math.sqrt(c(n))},n.sum=s,n.toDigits=function(n,t){var r=Math.pow(10,t);return Math.round(n*r*(1+Number.EPSILON))/r},n.truncate=function(n,t,r){return n.length>t?""+n.slice(0,t)+(null!=r?r:""):n},n.variance=c,Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self)["@jonahsnider/util"]={})}(this,(function(n){"use strict";function t(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function r(n,r){var e;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(e=function(n,r){if(n){if("string"==typeof n)return t(n,void 0);var e=Object.prototype.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?t(n,void 0):void 0}}(n))||r&&n&&"number"==typeof n.length){e&&(n=e);var a=0;return function(){return a>=n.length?{done:!0}:{done:!1,value:n[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(e=n[Symbol.iterator]()).next.bind(e)}var e,a;(e=n.Rank||(n.Rank={}))[e.Ace=1]="Ace",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four",e[e.Five=5]="Five",e[e.Six=6]="Six",e[e.Seven=7]="Seven",e[e.Eight=8]="Eight",e[e.Nine=9]="Nine",e[e.Ten=10]="Ten",e[e.Jack=11]="Jack",e[e.Queen=12]="Queen",e[e.King=13]="King",(a=n.Suit||(n.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var i=[{rank:n.Rank.Ace,suit:n.Suit.Clubs},{rank:n.Rank.Two,suit:n.Suit.Clubs},{rank:n.Rank.Three,suit:n.Suit.Clubs},{rank:n.Rank.Four,suit:n.Suit.Clubs},{rank:n.Rank.Five,suit:n.Suit.Clubs},{rank:n.Rank.Six,suit:n.Suit.Clubs},{rank:n.Rank.Seven,suit:n.Suit.Clubs},{rank:n.Rank.Eight,suit:n.Suit.Clubs},{rank:n.Rank.Nine,suit:n.Suit.Clubs},{rank:n.Rank.Ten,suit:n.Suit.Clubs},{rank:n.Rank.Jack,suit:n.Suit.Clubs},{rank:n.Rank.Queen,suit:n.Suit.Clubs},{rank:n.Rank.King,suit:n.Suit.Clubs},{rank:n.Rank.Ace,suit:n.Suit.Diamonds},{rank:n.Rank.Two,suit:n.Suit.Diamonds},{rank:n.Rank.Three,suit:n.Suit.Diamonds},{rank:n.Rank.Four,suit:n.Suit.Diamonds},{rank:n.Rank.Five,suit:n.Suit.Diamonds},{rank:n.Rank.Six,suit:n.Suit.Diamonds},{rank:n.Rank.Seven,suit:n.Suit.Diamonds},{rank:n.Rank.Eight,suit:n.Suit.Diamonds},{rank:n.Rank.Nine,suit:n.Suit.Diamonds},{rank:n.Rank.Ten,suit:n.Suit.Diamonds},{rank:n.Rank.Jack,suit:n.Suit.Diamonds},{rank:n.Rank.Queen,suit:n.Suit.Diamonds},{rank:n.Rank.King,suit:n.Suit.Diamonds},{rank:n.Rank.Ace,suit:n.Suit.Hearts},{rank:n.Rank.Two,suit:n.Suit.Hearts},{rank:n.Rank.Three,suit:n.Suit.Hearts},{rank:n.Rank.Four,suit:n.Suit.Hearts},{rank:n.Rank.Five,suit:n.Suit.Hearts},{rank:n.Rank.Six,suit:n.Suit.Hearts},{rank:n.Rank.Seven,suit:n.Suit.Hearts},{rank:n.Rank.Eight,suit:n.Suit.Hearts},{rank:n.Rank.Nine,suit:n.Suit.Hearts},{rank:n.Rank.Ten,suit:n.Suit.Hearts},{rank:n.Rank.Jack,suit:n.Suit.Hearts},{rank:n.Rank.Queen,suit:n.Suit.Hearts},{rank:n.Rank.King,suit:n.Suit.Hearts},{rank:n.Rank.Ace,suit:n.Suit.Spades},{rank:n.Rank.Two,suit:n.Suit.Spades},{rank:n.Rank.Three,suit:n.Suit.Spades},{rank:n.Rank.Four,suit:n.Suit.Spades},{rank:n.Rank.Five,suit:n.Suit.Spades},{rank:n.Rank.Six,suit:n.Suit.Spades},{rank:n.Rank.Seven,suit:n.Suit.Spades},{rank:n.Rank.Eight,suit:n.Suit.Spades},{rank:n.Rank.Nine,suit:n.Suit.Spades},{rank:n.Rank.Ten,suit:n.Suit.Spades},{rank:n.Rank.Jack,suit:n.Suit.Spades},{rank:n.Rank.Queen,suit:n.Suit.Spades},{rank:n.Rank.King,suit:n.Suit.Spades}],u=/^./;function o(n){for(var t,e=n[0].map((function(n){return n.length})),a=r(n);!(t=a()).done;)for(var i=t.value,u=0;u<i.length;u++){var o=i[u].length;e[u]<o&&(e[u]=o)}return e}function s(n,t){return n+t}function f(n,t,r,e){return e.length-1===r?(n+t)/("bigint"==typeof t?BigInt(e.length):e.length):n+t}function c(n){var t=n.reduce(f);return n.map((function(n){return Math.pow(n-t,2)})).reduce(s)/(n.length-1)}function k(n,t,r){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(n-r/t,2))}function l(n,t){return Math.random()*(t-n)+n}n.Stopwatch=function(){function n(){}n.start=function(){var n=new this;return n.start(),n};var t,r=n.prototype;return r.start=function(){this.startTime=process.hrtime.bigint()},r.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(t=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}(n.prototype,t),n}(),n.ascending=function(n,t){return n-t},n.binarySearch=function(n,t){for(var r=0,e=n.length-1;r<=e;){var a=Math.trunc((r+e)/2),i=t(n[a]);if(i<0)r=a+1;else{if(!(i>0))return n[a];e=a-1}}},n.capitalize=function(n){return n.replace(u,(function(n){return n.toUpperCase()}))},n.chunk=function(n,t){return n.length===t?n.map((function(n){return[n]})):Array.from({length:Math.ceil(n.length/t)},(function(r,e){return n.slice(e*t,e*t+t)}))},n.clamp=function(n,t,r){return n<t?t:n>r?r:n},n.descending=function(n,t){return t-n},n.first=function(n,t){void 0===t&&(t=1);for(var r=[],e=n[Symbol.iterator](),a=0;a<t;a++){var i=e.next();if(i.done)break;r.push(i.value)}return r},n.formatTable=function(n,t){void 0===t&&(t=" ");var r=o(n);return n.map((function(n){return n.map((function(n,t){return n.padEnd(r[t])})).join(t)})).join("\n")},n.frequencyTable=function(n){for(var t,e=new Map,a=r(n);!(t=a()).done;){var i=t.value,u=e.get(i);e.set(i,u?u+1:1)}return e},n.identical=function(n,t){for(var r=arguments.length,e=new Array(r>2?r-2:0),a=2;a<r;a++)e[a-2]=arguments[a];for(var i=[n,t].concat(e).map((function(n){return n[Symbol.iterator]()})),u=function(){var n=i.map((function(n){return n.next()})),t=n[0],r=t.done,e=t.value;return n.some((function(n){return n.done}))?{v:n.every((function(n){return n.done===r}))}:n.some((function(n){return n.value!==e}))?{v:!1}:void 0};;){var o=u();if("object"==typeof o)return o.v}},n.identicalManual=function(n,t){if(n===t)return!0;if(Array.isArray(n))return n.length===t.length&&n.every((function(n,r){return n===t[r]}));if(n.size!==t.size)return!1;if(n instanceof Set){for(var e,a=r(n);!(e=a()).done;)if(!t.has(e.value))return!1}else if(n instanceof Map)for(var i,u=r(n.entries());!(i=u()).done;){var o=i.value,s=o[0],f=o[1];if(t.get(s)!==f||!t.has(s))return!1}return!0},n.max=function(n,t){return Math.max(n,t)},n.maxColumnLength=o,n.mean=f,n.median=function(n){var t=n.length;return t%2==0?(n[t/2-1]+n[t/2])/2:n[Math.floor(t/2)]},n.min=function(n,t){return Math.min(n,t)},n.mode=function(n){for(var t,e=new Map,a=0,i=[],u=r(n);!(t=u()).done;){var o=t.value,s=e.get(o),f=void 0===s?1:s+1;e.set(o,f),f>a?(a=f,i=[o]):f===a&&i.push(o)}return i},n.multiReplace=function(n,t){for(var e=Object.entries(t),a="",i=0;i<n.length;)n:do{for(var u,o=r(e);!(u=o()).done;){var s=u.value,f=s[0],c=s[1];if(n.slice(i).startsWith(f)){a+=c,i+=f.length;break n}}a+=n[i++]}while(0);return a},n.newDeck=function(){return[].concat(i)},n.normaldist=k,n.nullish=function(n){return null==n},n.partition=function(n,t){for(var e,a=[],i=[],u=0,o=r(n);!(e=o()).done;){var s=e.value;(t(s,u++)?a:i).push(s)}return[a,i]},n.random=l,n.randomInt=function(n,t){return Math.floor(l(Math.ceil(n),Math.floor(t)))},n.reverse=function(n){return Array.from({length:n.length},(function(t,r){return n[n.length-(r+1)]}))},n.sample=function(n){return n[Math.floor(Math.random()*n.length)]},n.shuffle=function(n,t){void 0===t&&(t=!0);for(var r=t?n:[].concat(n),e=r.length-1;e>0;e--){var a=Math.floor(Math.random()*(e+1)),i=[r[a],r[e]];r[e]=i[0],r[a]=i[1]}if(!t)return r},n.sortObject=function(n,t){return Object.fromEntries(Object.entries(n).sort((function(n,r){return t(n[1],r[1])})))},n.standardNormaldist=function(n){return k(n,1,0)},n.stddev=function(n){return Math.sqrt(c(n))},n.sum=s,n.toDigits=function(n,t){var r=Math.pow(10,t);return Math.round(n*r*(1+Number.EPSILON))/r},n.truncate=function(n,t,r){return void 0===r&&(r=""),n.length>t?""+n.slice(0,t)+r:n},n.variance=c,Object.defineProperty(n,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=util.umd.production.min.js.map |
@@ -75,3 +75,3 @@ { | ||
"typings": "dist/index.d.ts", | ||
"version": "2.10.1" | ||
"version": "2.10.2" | ||
} |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
360059
4433