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

@jonahsnider/util

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jonahsnider/util - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

37

dist/array.d.ts

@@ -36,2 +36,4 @@ /** A 2-dimensional table of type `T`. */

*
* @see {@link shuffle} if you want to implement a random selection without replacement
*
* @returns A random element from the array or `undefined` if the array was empty

@@ -60,5 +62,8 @@ */

*
* @see {@link sample} if you only want to select one element at random
*
* @returns `void` if `mutate` was `true`, the shuffled array if `mutate` was `false`
*/
export declare const shuffle: (<T>(array: T[]) => void) & (<T_1>(array: readonly T_1[], mutate: false) => T_1[]);
declare const typedShuffle: (<T>(array: T[]) => void) & (<T_1>(array: readonly T_1[], mutate: false) => T_1[]);
export { typedShuffle as shuffle };
/**

@@ -70,3 +75,4 @@ * Perform a binary search to find an element in a sorted array.

* const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
* function directionFn(value: number) {
*
* function directionFn(value) {
* const squared = value ** 2;

@@ -199,9 +205,31 @@ *

* ```ts
* duplicates([1, 2, 2, 3]); // [2]
* allDuplicates([1, 2, 2, 2, 3]); // [2, 2]
* ```
*
* @example
* Using {@link frequencyTable} to get the number of times each element was duplicated
* ```ts
* frequencyTable(allDuplicates([1, 2, 2, 2, 3, 3])); // Map(2) { 2 => 2, 3 => 1 }
* ```
*
* @see {@link duplicates} to receive a `Set` of duplicate elements instead of an array (which can include the same element more than once)
*
* @param iterable - The iterable to find duplicates in
* @returns An array of the duplicated elements
*/
export declare function duplicates<T>(iterable: Iterable<T>): T[];
export declare function allDuplicates<T>(iterable: Iterable<T>): T[];
/**
* Get a Set of the duplicate elements in an iterable.
*
* @example
* ```ts
* duplicates([1, 2, 2, 2, 3]); // Set(1) { 2 }
* ```
*
* @see {@link allDuplicates} to receive a array of duplicate elements instead of a `Set` (which doesn't include the same element more than once)
*
* @param iterable - The iterable to find duplicates in
* @returns A `Set` of the duplicated elements
*/
export declare function duplicates<T>(iterable: Iterable<T>): Set<T>;
declare type ObjectWithLength = {

@@ -230,2 +258,1 @@ length: number;

export declare function largeToSmall<A extends ObjectWithSize, B extends ObjectWithSize>(a: A, b: B): ArrangedLargestToSmallest<A, B>;
export {};

168

dist/cards.d.ts

@@ -35,164 +35,14 @@ /**

}
declare const deck: readonly [{
readonly rank: Rank.Ace;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Two;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Three;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Four;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Five;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Six;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Seven;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Eight;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Nine;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Ten;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Jack;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Queen;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.King;
readonly suit: Suit.Clubs;
}, {
readonly rank: Rank.Ace;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Two;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Three;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Four;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Five;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Six;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Seven;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Eight;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Nine;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Ten;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Jack;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Queen;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.King;
readonly suit: Suit.Diamonds;
}, {
readonly rank: Rank.Ace;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Two;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Three;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Four;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Five;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Six;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Seven;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Eight;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Nine;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Ten;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Jack;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Queen;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.King;
readonly suit: Suit.Hearts;
}, {
readonly rank: Rank.Ace;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Two;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Three;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Four;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Five;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Six;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Seven;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Eight;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Nine;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Ten;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Jack;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.Queen;
readonly suit: Suit.Spades;
}, {
readonly rank: Rank.King;
readonly suit: Suit.Spades;
}];
/**
* Get a sorted deck of cards.
*
* @example
* ```ts
* import { shuffle } from '@jonahsnider/util';
*
* const deck = newDeck();
* ```
*
* @returns A sorted deck of cards
*/
export declare function newDeck(): typeof deck;
export {};
export declare function newDeck(): Card[];

@@ -6,3 +6,3 @@ /**

* ```ts
* import {nullish} from '@jonahsnider/util';
* import { nullish } from '@jonahsnider/util';
*

@@ -9,0 +9,0 @@ * [0, null, '', undefined, false].filter(not(nullish)); // [0, '', false]

@@ -12,2 +12,4 @@ import { Table } from './array';

*
* @see {@link uncapitalize} for the inverse operation
*
* @returns Capitalized string

@@ -26,2 +28,4 @@ */

*
* @see {@link capitalize} for the inverse operation
*
* @returns Uncapitalized string

@@ -28,0 +32,0 @@ */

@@ -39,2 +39,4 @@ /**

*
* @see {@link standardNormaldist} For calculating the standard normal distribution
*
* @returns The normal distribution

@@ -53,2 +55,4 @@ */

*
* @see {@link normaldist} For calculating the normal distribution
*
* @returns The standard normal distribution

@@ -58,6 +62,42 @@ */

/**
* Calculate the median of a sequence of numbers.
* Get the mean of an array of `number`s.
*
* @example
* ```ts
* const array = [1, 2, 3];
*
* mean(array) === 2;
* ```
*
* @param array - The array to calculate the mean of
*
* @see {@link median} to calculate the median of an array
* @see {@link mode} to calculate the mode of an array
*
* @returns The mean of the array
*/
export declare function mean(array: readonly number[]): number;
/**
* Get the mean of an array of `bigint`s.
*
* @example
* ```ts
* const array = [1n, 2n, 3n];
*
* mean(array) === 2n;
* ```
*
* @param array - The array to calculate the mean of
*
* @see {@link median} to calculate the median of an array
* @see {@link mode} to calculate the mode of an array
*
* @returns The mean of the array
*/
export declare function mean(array: readonly bigint[]): bigint;
/**
* Calculate the median of an array of numbers.
*
* @example
* ```ts
* const values = [1, 2, 3];

@@ -68,9 +108,13 @@ *

*
* @param values - Values to use in the calculation
* @param array - Values to use in the calculation
*
* @see {@link mean} to calculate the mean of an array
* @see {@link mode} to calculate the mode of an array
*
* @returns The median of `values`
*/
export declare function median(values: readonly number[]): number;
export declare function median(array: readonly number[]): number;
export declare function median(array: readonly bigint[]): bigint;
/**
* Calculate the mode of an `Iterable`.
* Calculate the mode of an iterable.
* Strict equality (`===`) is used to compare elements.

@@ -85,7 +129,10 @@ *

*
* @param values - Values to use in the calculation
* @param iterable - Values to use in the calculation
*
* @returns An array of the modes of `values`
* @see {@link mean} to calculate the mean of an array
* @see {@link median} to calculate the median of an array
*
* @returns An array of the modes of `values`
*/
export declare function mode<T>(values: Iterable<T>): T[];
export declare function mode<T>(iterable: Iterable<T>): T[];
/**

@@ -126,2 +173,9 @@ * Generate a random number within the given bounds.

*
* @example
* ```ts
* const value = clamp(Math.random() * 100, 25, 75n);
*
* 25 <= value && value <= 75n;
* ```
*
* @param value - The value to clamp

@@ -133,2 +187,2 @@ * @param min - The lower end (inclusive) of the range of numbers

*/
export declare function clamp(value: number, min: number, max: number): number;
export declare function clamp<T extends number | bigint, M1 extends number | bigint, M2 extends number | bigint>(value: T, min: M1, max: M2): T | M1 | M2;

@@ -32,40 +32,2 @@ /**

/**
* Get the mean of an array of `number`s.
* Meant to be used with `Array.prototype.reduce`.
*
* @example
* ```ts
* const array = [1, 2, 3];
*
* array.reduce(mean) === 2;
* ```
*
* @param previousValue - Rolling sum of the array
* @param currentValue - The next value to add to the sum
* @param currentIndex - The current index of `currentValue` in the array
* @param array - The source array. Only used for array length.
*
* @returns The mean of the array
*/
export declare function mean(previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]): number;
/**
* Get the mean of an array of `bigint`s.
* Meant to be used with `Array.prototype.reduce`.
*
* @example
* ```ts
* const array = [1n, 2n, 3n];
*
* array.reduce(mean) === 2n;
* ```
*
* @param previousValue - Rolling sum of the array
* @param currentValue - The next value to add to the sum
* @param currentIndex - The current index of `currentValue` in the array
* @param array - The source array. Only used for array length.
*
* @returns The mean of the array
*/
export declare function mean(previousValue: bigint, currentValue: bigint, currentIndex: number, array: readonly bigint[]): bigint;
/**
* Get the largest value of an array of `number`s.

@@ -72,0 +34,0 @@ * Meant to be used with `Array.prototype.reduce`.

@@ -7,2 +7,4 @@ /**

*
* @see {@link isSubset} for checking if one set is a subset of another
*
* @returns `true` if `a` is a superset of `b`, `false` otherwise

@@ -17,2 +19,4 @@ */

*
* @see {@link isSuperset} for checking if one set is a superset of another
*
* @returns `true` if `a` is a subset of `b`, `false` otherwise

@@ -19,0 +23,0 @@ */

@@ -127,2 +127,4 @@ 'use strict';

*
* @see {@link shuffle} if you want to implement a random selection without replacement
*
* @returns A random element from the array or `undefined` if the array was empty

@@ -135,3 +137,3 @@ */

function _shuffle(array, mutate) {
function shuffle(array, mutate) {
if (mutate === void 0) {

@@ -174,2 +176,4 @@ mutate = true;

*
* @see {@link sample} if you only want to select one element at random
*
* @returns `void` if `mutate` was `true`, the shuffled array if `mutate` was `false`

@@ -179,3 +183,3 @@ */

var shuffle = _shuffle;
var typedShuffle = shuffle;
/**

@@ -187,3 +191,4 @@ * Perform a binary search to find an element in a sorted array.

* const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
* function directionFn(value: number) {
*
* function directionFn(value) {
* const squared = value ** 2;

@@ -383,5 +388,13 @@ *

* ```ts
* duplicates([1, 2, 2, 3]); // [2]
* allDuplicates([1, 2, 2, 2, 3]); // [2, 2]
* ```
*
* @example
* Using {@link frequencyTable} to get the number of times each element was duplicated
* ```ts
* frequencyTable(allDuplicates([1, 2, 2, 2, 3, 3])); // Map(2) { 2 => 2, 3 => 1 }
* ```
*
* @see {@link duplicates} to receive a `Set` of duplicate elements instead of an array (which can include the same element more than once)
*
* @param iterable - The iterable to find duplicates in

@@ -391,3 +404,3 @@ * @returns An array of the duplicated elements

function duplicates(iterable) {
function allDuplicates(iterable) {
var seen = new Set();

@@ -408,2 +421,32 @@ var result = [];

}
/**
* Get a Set of the duplicate elements in an iterable.
*
* @example
* ```ts
* duplicates([1, 2, 2, 2, 3]); // Set(1) { 2 }
* ```
*
* @see {@link allDuplicates} to receive a array of duplicate elements instead of a `Set` (which doesn't include the same element more than once)
*
* @param iterable - The iterable to find duplicates in
* @returns A `Set` of the duplicated elements
*/
function duplicates(iterable) {
var seen = new Set();
var result = new Set();
for (var _iterator5 = _createForOfIteratorHelperLoose(iterable), _step5; !(_step5 = _iterator5()).done;) {
var element = _step5.value;
if (seen.has(element)) {
result.add(element);
}
seen.add(element);
}
return result;
}
function largeToSmall(a, b) {

@@ -618,2 +661,10 @@ var key = undefined;

* Get a sorted deck of cards.
*
* @example
* ```ts
* import { shuffle } from '@jonahsnider/util';
*
* const deck = newDeck();
* ```
*
* @returns A sorted deck of cards

@@ -631,3 +682,3 @@ */

* ```ts
* import {nullish} from '@jonahsnider/util';
* import { nullish } from '@jonahsnider/util';
*

@@ -681,2 +732,4 @@ * [0, null, '', undefined, false].filter(not(nullish)); // [0, '', false]

*
* @see {@link uncapitalize} for the inverse operation
*
* @returns Capitalized string

@@ -698,2 +751,4 @@ */

*
* @see {@link capitalize} for the inverse operation
*
* @returns Uncapitalized string

@@ -1335,10 +1390,2 @@ */

}
function mean(previousValue, currentValue, currentIndex, array) {
if (array.length - 1 === currentIndex) {
// End of the array, calculate the mean
return (previousValue + currentValue) / (typeof currentValue === 'bigint' ? BigInt(array.length) : array.length);
}
return previousValue + currentValue;
}
/**

@@ -1399,3 +1446,3 @@ * Get the largest value of an array of `number`s.

function variance(values) {
var meanValue = values.reduce(mean);
var meanValue = mean(values);
return values.map(function (value) {

@@ -1433,2 +1480,4 @@ return Math.pow(value - meanValue, 2);

*
* @see {@link standardNormaldist} For calculating the standard normal distribution
*
* @returns The normal distribution

@@ -1450,2 +1499,4 @@ */

*
* @see {@link normaldist} For calculating the normal distribution
*
* @returns The standard normal distribution

@@ -1457,29 +1508,20 @@ */

}
/**
* Calculate the median of a sequence of numbers.
*
* @example
* ```ts
* const values = [1, 2, 3];
*
* median(values) === 2;
* ```
*
* @param values - Values to use in the calculation
*
* @returns The median of `values`
*/
function mean(array) {
var summed = array.reduce(sum);
var length = typeof summed === 'bigint' ? BigInt(array.length) : array.length;
return summed / length;
}
function median(array) {
var even = array.length % 2 === 0;
var middleIndex = array.length / 2;
function median(values) {
var length = values.length;
var even = length % 2 === 0;
if (even) {
return (values[length / 2 - 1] + values[length / 2]) / 2;
var divisor = typeof array[0] === 'bigint' ? 2n : 2;
return (array[middleIndex - 1] + array[middleIndex]) / divisor;
}
return values[Math.floor(length / 2)];
return array[Math.floor(middleIndex)];
}
/**
* Calculate the mode of an `Iterable`.
* Calculate the mode of an iterable.
* Strict equality (`===`) is used to compare elements.

@@ -1494,8 +1536,11 @@ *

*
* @param values - Values to use in the calculation
* @param iterable - Values to use in the calculation
*
* @returns An array of the modes of `values`
* @see {@link mean} to calculate the mean of an array
* @see {@link median} to calculate the median of an array
*
* @returns An array of the modes of `values`
*/
function mode(values) {
function mode(iterable) {
var frequencyTable = new Map();

@@ -1505,3 +1550,3 @@ var maxOccurrences = 0;

for (var _iterator = _createForOfIteratorHelperLoose(values), _step; !(_step = _iterator()).done;) {
for (var _iterator = _createForOfIteratorHelperLoose(iterable), _step; !(_step = _iterator()).done;) {
var element = _step.value;

@@ -1571,2 +1616,9 @@ var occurrences = frequencyTable.get(element);

*
* @example
* ```ts
* const value = clamp(Math.random() * 100, 25, 75n);
*
* 25 <= value && value <= 75n;
* ```
*
* @param value - The value to clamp

@@ -1657,2 +1709,4 @@ * @param min - The lower end (inclusive) of the range of numbers

*
* @see {@link isSubset} for checking if one set is a subset of another
*
* @returns `true` if `a` is a superset of `b`, `false` otherwise

@@ -1678,2 +1732,4 @@ */

*
* @see {@link isSuperset} for checking if one set is a superset of another
*
* @returns `true` if `a` is a subset of `b`, `false` otherwise

@@ -2017,2 +2073,3 @@ */

exports.Stopwatch = Stopwatch;
exports.allDuplicates = allDuplicates;
exports.binarySearch = binarySearch;

@@ -2053,3 +2110,3 @@ exports.capitalize = capitalize;

exports.sample = sample;
exports.shuffle = shuffle;
exports.shuffle = typedShuffle;
exports.sortObject = sortObject;

@@ -2056,0 +2113,0 @@ exports.standardNormaldist = standardNormaldist;

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

"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[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=e[Symbol.iterator]()).next.bind(n)}function n(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var o,a;function i(e,t){var r=void 0;if("size"in e?r="size":"length"in e&&(r="length"),!r)throw new RangeError;return e[r]<t[r]?[t,e]:[e,t]}Object.defineProperty(exports,"__esModule",{value:!0}),(o=exports.Rank||(exports.Rank={}))[o.Ace=1]="Ace",o[o.Two=2]="Two",o[o.Three=3]="Three",o[o.Four=4]="Four",o[o.Five=5]="Five",o[o.Six=6]="Six",o[o.Seven=7]="Seven",o[o.Eight=8]="Eight",o[o.Nine=9]="Nine",o[o.Ten=10]="Ten",o[o.Jack=11]="Jack",o[o.Queen=12]="Queen",o[o.King=13]="King",(a=exports.Suit||(exports.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var u,s,p=[{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}];function l(e){for(var t,n=e[0].map((function(e){return e.length})),o=r(e);!(t=o()).done;)for(var a=t.value,i=0;i<a.length;i++){var u=a[i].length;n[i]<u&&(n[i]=u)}return n}!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired"}(u||(u={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(s||(s={}));var c={__proto__:null,get Status(){return u},get Method(){return s}};function d(e,t){return e+t}function f(e,t,r,n){return n.length-1===r?(e+t)/("bigint"==typeof t?BigInt(n.length):n.length):e+t}function x(e){var t=e.reduce(f);return e.map((function(e){return Math.pow(e-t,2)})).reduce(d)/(e.length-1)}function v(e,t,r){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-r/t,2))}function h(e,t){return Math.random()*(t-e)+e}var k=function(){function e(){}e.start=function(){var e=new this;return e.start(),e};var t,r=e.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(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}();exports.Http=c,exports.Sort={__proto__:null,ascending:function(e,t){return e<t?-1:e>t?1:0},descending:function(e,t){return e<t?1:e>t?-1:0}},exports.Stopwatch=k,exports.binarySearch=function(e,t){for(var r=0,n=e.length-1;r<=n;){var o=Math.trunc((r+n)/2),a=t(e[o]);if(a<0)r=o+1;else{if(!(a>0))return e[o];n=o-1}}},exports.capitalize=function(e){var t=e.charAt(0).toUpperCase();return""+t+e.slice(t.length)},exports.chunk=function(e,t){return e.length===t?e.map((function(e){return[e]})):Array.from({length:Math.ceil(e.length/t)},(function(r,n){return e.slice(n*t,n*t+t)}))},exports.clamp=function(e,t,r){return e<t?t:e>r?r:e},exports.difference=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)o.delete(n.value);return o},exports.duplicates=function(e){for(var t,n=new Set,o=[],a=r(e);!(t=a()).done;){var i=t.value;n.has(i)&&o.push(i),n.add(i)}return o},exports.first=function(e,t){var r=e[Symbol.iterator]();if(void 0===t)return r.next().value;for(var n=[],o=0;o<t;o++){var a=r.next();if(a.done)break;n.push(a.value)}return n},exports.formatTable=function(e,t){void 0===t&&(t=" ");var r=l(e);return e.map((function(e){return e.map((function(e,t){return e.padEnd(r[t])})).join(t)})).join("\n")},exports.frequencyTable=function(e){for(var t,n=new Map,o=r(e);!(t=o()).done;){var a=t.value,i=n.get(a);n.set(a,i?i+1:1)}return n},exports.identical=function(e,t){if(e===t)return!0;if(Array.isArray(e))return e.length===t.length&&e.every((function(e,r){return e===t[r]}));if(e.size!==t.size)return!1;if(e instanceof Set){for(var n,o=r(e);!(n=o()).done;)if(!t.has(n.value))return!1}else if(e instanceof Map)for(var a,i=r(e.entries());!(a=i()).done;){var u=a.value,s=u[0],p=u[1];if(t.get(s)!==p||!t.has(s))return!1}return!0},exports.intersection=function(e,t){for(var n,o=new Set,a=i(e,t),u=a[1],s=r(a[0]);!(n=s()).done;){var p=n.value;u.has(p)&&o.add(p)}return o},exports.invert=function(e){return function(){return-e.apply(void 0,arguments)}},exports.isDisjoint=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)if(o.has(n.value))return!1;return!0},exports.isSubset=function(e,t){for(var n,o=r(e);!(n=o()).done;)if(!t.has(n.value))return!1;return!0},exports.isSuperset=function(e,t){for(var n,o=r(t);!(n=o()).done;)if(!e.has(n.value))return!1;return!0},exports.largeToSmall=i,exports.max=function(e,t){return Math.max(e,t)},exports.maxColumnLength=l,exports.mean=f,exports.median=function(e){var t=e.length;return t%2==0?(e[t/2-1]+e[t/2])/2:e[Math.floor(t/2)]},exports.min=function(e,t){return Math.min(e,t)},exports.mode=function(e){for(var t,n=new Map,o=0,a=[],i=r(e);!(t=i()).done;){var u=t.value,s=n.get(u),p=void 0===s?1:s+1;n.set(u,p),p>o?(o=p,a=[u]):p===o&&a.push(u)}return a},exports.multiReplace=function(e,t){for(var n=Object.entries(t),o="",a=0;a<e.length;)e:do{for(var i,u=r(n);!(i=u()).done;){var s=i.value,p=s[0],l=s[1];if(e.slice(a).startsWith(p)){o+=l,a+=p.length;break e}}o+=e[a++]}while(0);return o},exports.newDeck=function(){return[].concat(p)},exports.normaldist=v,exports.not=function(e){return function(){return!e.apply(void 0,arguments)}},exports.nullish=function(e){return null==e},exports.partition=function(e,t){for(var n,o=[],a=[],i=0,u=r(e);!(n=u()).done;){var s=n.value;(t(s,i++)?o:a).push(s)}return[o,a]},exports.random=h,exports.randomInt=function(e,t){return Math.floor(h(Math.ceil(e),Math.floor(t)))},exports.regExpUnion=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return new RegExp(t.map((function(e){return"("+e.source+")"})).join("|"))},exports.rename=function(t,r,o){var a;return r===o?e({},t):function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}(e({},t,((a={})[o]=t[r],a)),[r].map(n))},exports.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,r){return e[e.length-(r+1)]}));for(var t,n=[],o=r(e);!(t=o()).done;)n.unshift(t.value);return n},exports.same=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var o=t.map((function(e){return e[Symbol.iterator]()})),a=function(){for(var e,t=o.map((function(e){return e.next()})),n=t[0],a=n.done,i=n.value,u=r(t);!(e=u()).done;){var s=e.value;if(s.done)return{v:t.every((function(e){return e.done===a}))};if(s.value!==i)return{v:!1}}};;){var i=a();if("object"==typeof i)return i.v}},exports.sample=function(e){return e[Math.floor(Math.random()*e.length)]},exports.shuffle=function(e,t){void 0===t&&(t=!0);for(var r=t?e:[].concat(e),n=r.length-1;n>0;n--){var o=Math.floor(Math.random()*(n+1)),a=[r[o],r[n]];r[n]=a[0],r[o]=a[1]}if(!t)return r},exports.sortObject=function(e,t){return Object.entries(e).sort((function(e,r){return t(e[1],r[1])}))},exports.standardNormaldist=function(e){return v(e,1,0)},exports.stddev=function(e){return Math.sqrt(x(e))},exports.sum=d,exports.symmetricDifference=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;){var i=n.value;o.has(i)?o.delete(i):o.add(i)}return o},exports.toDigits=function(e,t){var r=Math.pow(10,t);return Math.round(e*r*(1+Number.EPSILON))/r},exports.truncate=function(e,t,r){return void 0===r&&(r=""),e.length>t?""+e.slice(0,t)+r:e},exports.uncapitalize=function(e){var t=e.charAt(0).toLowerCase();return""+t+e.slice(t.length)},exports.union=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)o.add(n.value);return o},exports.variance=x;
"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[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=e[Symbol.iterator]()).next.bind(n)}function n(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var o,a;function i(e,t){var r=void 0;if("size"in e?r="size":"length"in e&&(r="length"),!r)throw new RangeError;return e[r]<t[r]?[t,e]:[e,t]}Object.defineProperty(exports,"__esModule",{value:!0}),(o=exports.Rank||(exports.Rank={}))[o.Ace=1]="Ace",o[o.Two=2]="Two",o[o.Three=3]="Three",o[o.Four=4]="Four",o[o.Five=5]="Five",o[o.Six=6]="Six",o[o.Seven=7]="Seven",o[o.Eight=8]="Eight",o[o.Nine=9]="Nine",o[o.Ten=10]="Ten",o[o.Jack=11]="Jack",o[o.Queen=12]="Queen",o[o.King=13]="King",(a=exports.Suit||(exports.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var u,s,p=[{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}];function l(e){for(var t,n=e[0].map((function(e){return e.length})),o=r(e);!(t=o()).done;)for(var a=t.value,i=0;i<a.length;i++){var u=a[i].length;n[i]<u&&(n[i]=u)}return n}!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired"}(u||(u={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(s||(s={}));var c={__proto__:null,get Status(){return u},get Method(){return s}};function d(e,t){return e+t}function f(e){var t=v(e);return e.map((function(e){return Math.pow(e-t,2)})).reduce(d)/(e.length-1)}function x(e,t,r){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-r/t,2))}function v(e){var t=e.reduce(d);return t/("bigint"==typeof t?BigInt(e.length):e.length)}function h(e,t){return Math.random()*(t-e)+e}var S=function(){function e(){}e.start=function(){var e=new this;return e.start(),e};var t,r=e.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(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}();exports.Http=c,exports.Sort={__proto__:null,ascending:function(e,t){return e<t?-1:e>t?1:0},descending:function(e,t){return e<t?1:e>t?-1:0}},exports.Stopwatch=S,exports.allDuplicates=function(e){for(var t,n=new Set,o=[],a=r(e);!(t=a()).done;){var i=t.value;n.has(i)&&o.push(i),n.add(i)}return o},exports.binarySearch=function(e,t){for(var r=0,n=e.length-1;r<=n;){var o=Math.trunc((r+n)/2),a=t(e[o]);if(a<0)r=o+1;else{if(!(a>0))return e[o];n=o-1}}},exports.capitalize=function(e){var t=e.charAt(0).toUpperCase();return""+t+e.slice(t.length)},exports.chunk=function(e,t){return e.length===t?e.map((function(e){return[e]})):Array.from({length:Math.ceil(e.length/t)},(function(r,n){return e.slice(n*t,n*t+t)}))},exports.clamp=function(e,t,r){return e<t?t:e>r?r:e},exports.difference=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)o.delete(n.value);return o},exports.duplicates=function(e){for(var t,n=new Set,o=new Set,a=r(e);!(t=a()).done;){var i=t.value;n.has(i)&&o.add(i),n.add(i)}return o},exports.first=function(e,t){var r=e[Symbol.iterator]();if(void 0===t)return r.next().value;for(var n=[],o=0;o<t;o++){var a=r.next();if(a.done)break;n.push(a.value)}return n},exports.formatTable=function(e,t){void 0===t&&(t=" ");var r=l(e);return e.map((function(e){return e.map((function(e,t){return e.padEnd(r[t])})).join(t)})).join("\n")},exports.frequencyTable=function(e){for(var t,n=new Map,o=r(e);!(t=o()).done;){var a=t.value,i=n.get(a);n.set(a,i?i+1:1)}return n},exports.identical=function(e,t){if(e===t)return!0;if(Array.isArray(e))return e.length===t.length&&e.every((function(e,r){return e===t[r]}));if(e.size!==t.size)return!1;if(e instanceof Set){for(var n,o=r(e);!(n=o()).done;)if(!t.has(n.value))return!1}else if(e instanceof Map)for(var a,i=r(e.entries());!(a=i()).done;){var u=a.value,s=u[0],p=u[1];if(t.get(s)!==p||!t.has(s))return!1}return!0},exports.intersection=function(e,t){for(var n,o=new Set,a=i(e,t),u=a[1],s=r(a[0]);!(n=s()).done;){var p=n.value;u.has(p)&&o.add(p)}return o},exports.invert=function(e){return function(){return-e.apply(void 0,arguments)}},exports.isDisjoint=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)if(o.has(n.value))return!1;return!0},exports.isSubset=function(e,t){for(var n,o=r(e);!(n=o()).done;)if(!t.has(n.value))return!1;return!0},exports.isSuperset=function(e,t){for(var n,o=r(t);!(n=o()).done;)if(!e.has(n.value))return!1;return!0},exports.largeToSmall=i,exports.max=function(e,t){return Math.max(e,t)},exports.maxColumnLength=l,exports.mean=v,exports.median=function(e){var t=e.length/2;return e.length%2==0?(e[t-1]+e[t])/("bigint"==typeof e[0]?2n:2):e[Math.floor(t)]},exports.min=function(e,t){return Math.min(e,t)},exports.mode=function(e){for(var t,n=new Map,o=0,a=[],i=r(e);!(t=i()).done;){var u=t.value,s=n.get(u),p=void 0===s?1:s+1;n.set(u,p),p>o?(o=p,a=[u]):p===o&&a.push(u)}return a},exports.multiReplace=function(e,t){for(var n=Object.entries(t),o="",a=0;a<e.length;)e:do{for(var i,u=r(n);!(i=u()).done;){var s=i.value,p=s[0],l=s[1];if(e.slice(a).startsWith(p)){o+=l,a+=p.length;break e}}o+=e[a++]}while(0);return o},exports.newDeck=function(){return[].concat(p)},exports.normaldist=x,exports.not=function(e){return function(){return!e.apply(void 0,arguments)}},exports.nullish=function(e){return null==e},exports.partition=function(e,t){for(var n,o=[],a=[],i=0,u=r(e);!(n=u()).done;){var s=n.value;(t(s,i++)?o:a).push(s)}return[o,a]},exports.random=h,exports.randomInt=function(e,t){return Math.floor(h(Math.ceil(e),Math.floor(t)))},exports.regExpUnion=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return new RegExp(t.map((function(e){return"("+e.source+")"})).join("|"))},exports.rename=function(t,r,o){var a;return r===o?e({},t):function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}(e({},t,((a={})[o]=t[r],a)),[r].map(n))},exports.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,r){return e[e.length-(r+1)]}));for(var t,n=[],o=r(e);!(t=o()).done;)n.unshift(t.value);return n},exports.same=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var o=t.map((function(e){return e[Symbol.iterator]()})),a=function(){for(var e,t=o.map((function(e){return e.next()})),n=t[0],a=n.done,i=n.value,u=r(t);!(e=u()).done;){var s=e.value;if(s.done)return{v:t.every((function(e){return e.done===a}))};if(s.value!==i)return{v:!1}}};;){var i=a();if("object"==typeof i)return i.v}},exports.sample=function(e){return e[Math.floor(Math.random()*e.length)]},exports.shuffle=function(e,t){void 0===t&&(t=!0);for(var r=t?e:[].concat(e),n=r.length-1;n>0;n--){var o=Math.floor(Math.random()*(n+1)),a=[r[o],r[n]];r[n]=a[0],r[o]=a[1]}if(!t)return r},exports.sortObject=function(e,t){return Object.entries(e).sort((function(e,r){return t(e[1],r[1])}))},exports.standardNormaldist=function(e){return x(e,1,0)},exports.stddev=function(e){return Math.sqrt(f(e))},exports.sum=d,exports.symmetricDifference=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;){var i=n.value;o.has(i)?o.delete(i):o.add(i)}return o},exports.toDigits=function(e,t){var r=Math.pow(10,t);return Math.round(e*r*(1+Number.EPSILON))/r},exports.truncate=function(e,t,r){return void 0===r&&(r=""),e.length>t?""+e.slice(0,t)+r:e},exports.uncapitalize=function(e){var t=e.charAt(0).toLowerCase();return""+t+e.slice(t.length)},exports.union=function(e,t){for(var n,o=new Set(e),a=r(t);!(n=a()).done;)o.add(n.value);return o},exports.variance=f;
//# sourceMappingURL=util.cjs.production.min.js.map

@@ -129,2 +129,4 @@ (function (global, factory) {

*
* @see {@link shuffle} if you want to implement a random selection without replacement
*
* @returns A random element from the array or `undefined` if the array was empty

@@ -137,3 +139,3 @@ */

function _shuffle(array, mutate) {
function shuffle(array, mutate) {
if (mutate === void 0) {

@@ -176,2 +178,4 @@ mutate = true;

*
* @see {@link sample} if you only want to select one element at random
*
* @returns `void` if `mutate` was `true`, the shuffled array if `mutate` was `false`

@@ -181,3 +185,3 @@ */

var shuffle = _shuffle;
var typedShuffle = shuffle;
/**

@@ -189,3 +193,4 @@ * Perform a binary search to find an element in a sorted array.

* const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
* function directionFn(value: number) {
*
* function directionFn(value) {
* const squared = value ** 2;

@@ -385,5 +390,13 @@ *

* ```ts
* duplicates([1, 2, 2, 3]); // [2]
* allDuplicates([1, 2, 2, 2, 3]); // [2, 2]
* ```
*
* @example
* Using {@link frequencyTable} to get the number of times each element was duplicated
* ```ts
* frequencyTable(allDuplicates([1, 2, 2, 2, 3, 3])); // Map(2) { 2 => 2, 3 => 1 }
* ```
*
* @see {@link duplicates} to receive a `Set` of duplicate elements instead of an array (which can include the same element more than once)
*
* @param iterable - The iterable to find duplicates in

@@ -393,3 +406,3 @@ * @returns An array of the duplicated elements

function duplicates(iterable) {
function allDuplicates(iterable) {
var seen = new Set();

@@ -410,2 +423,32 @@ var result = [];

}
/**
* Get a Set of the duplicate elements in an iterable.
*
* @example
* ```ts
* duplicates([1, 2, 2, 2, 3]); // Set(1) { 2 }
* ```
*
* @see {@link allDuplicates} to receive a array of duplicate elements instead of a `Set` (which doesn't include the same element more than once)
*
* @param iterable - The iterable to find duplicates in
* @returns A `Set` of the duplicated elements
*/
function duplicates(iterable) {
var seen = new Set();
var result = new Set();
for (var _iterator5 = _createForOfIteratorHelperLoose(iterable), _step5; !(_step5 = _iterator5()).done;) {
var element = _step5.value;
if (seen.has(element)) {
result.add(element);
}
seen.add(element);
}
return result;
}
function largeToSmall(a, b) {

@@ -620,2 +663,10 @@ var key = undefined;

* Get a sorted deck of cards.
*
* @example
* ```ts
* import { shuffle } from '@jonahsnider/util';
*
* const deck = newDeck();
* ```
*
* @returns A sorted deck of cards

@@ -633,3 +684,3 @@ */

* ```ts
* import {nullish} from '@jonahsnider/util';
* import { nullish } from '@jonahsnider/util';
*

@@ -683,2 +734,4 @@ * [0, null, '', undefined, false].filter(not(nullish)); // [0, '', false]

*
* @see {@link uncapitalize} for the inverse operation
*
* @returns Capitalized string

@@ -700,2 +753,4 @@ */

*
* @see {@link capitalize} for the inverse operation
*
* @returns Uncapitalized string

@@ -1337,10 +1392,2 @@ */

}
function mean(previousValue, currentValue, currentIndex, array) {
if (array.length - 1 === currentIndex) {
// End of the array, calculate the mean
return (previousValue + currentValue) / (typeof currentValue === 'bigint' ? BigInt(array.length) : array.length);
}
return previousValue + currentValue;
}
/**

@@ -1401,3 +1448,3 @@ * Get the largest value of an array of `number`s.

function variance(values) {
var meanValue = values.reduce(mean);
var meanValue = mean(values);
return values.map(function (value) {

@@ -1435,2 +1482,4 @@ return Math.pow(value - meanValue, 2);

*
* @see {@link standardNormaldist} For calculating the standard normal distribution
*
* @returns The normal distribution

@@ -1452,2 +1501,4 @@ */

*
* @see {@link normaldist} For calculating the normal distribution
*
* @returns The standard normal distribution

@@ -1459,29 +1510,20 @@ */

}
/**
* Calculate the median of a sequence of numbers.
*
* @example
* ```ts
* const values = [1, 2, 3];
*
* median(values) === 2;
* ```
*
* @param values - Values to use in the calculation
*
* @returns The median of `values`
*/
function mean(array) {
var summed = array.reduce(sum);
var length = typeof summed === 'bigint' ? BigInt(array.length) : array.length;
return summed / length;
}
function median(array) {
var even = array.length % 2 === 0;
var middleIndex = array.length / 2;
function median(values) {
var length = values.length;
var even = length % 2 === 0;
if (even) {
return (values[length / 2 - 1] + values[length / 2]) / 2;
var divisor = typeof array[0] === 'bigint' ? 2n : 2;
return (array[middleIndex - 1] + array[middleIndex]) / divisor;
}
return values[Math.floor(length / 2)];
return array[Math.floor(middleIndex)];
}
/**
* Calculate the mode of an `Iterable`.
* Calculate the mode of an iterable.
* Strict equality (`===`) is used to compare elements.

@@ -1496,8 +1538,11 @@ *

*
* @param values - Values to use in the calculation
* @param iterable - Values to use in the calculation
*
* @returns An array of the modes of `values`
* @see {@link mean} to calculate the mean of an array
* @see {@link median} to calculate the median of an array
*
* @returns An array of the modes of `values`
*/
function mode(values) {
function mode(iterable) {
var frequencyTable = new Map();

@@ -1507,3 +1552,3 @@ var maxOccurrences = 0;

for (var _iterator = _createForOfIteratorHelperLoose(values), _step; !(_step = _iterator()).done;) {
for (var _iterator = _createForOfIteratorHelperLoose(iterable), _step; !(_step = _iterator()).done;) {
var element = _step.value;

@@ -1573,2 +1618,9 @@ var occurrences = frequencyTable.get(element);

*
* @example
* ```ts
* const value = clamp(Math.random() * 100, 25, 75n);
*
* 25 <= value && value <= 75n;
* ```
*
* @param value - The value to clamp

@@ -1659,2 +1711,4 @@ * @param min - The lower end (inclusive) of the range of numbers

*
* @see {@link isSubset} for checking if one set is a subset of another
*
* @returns `true` if `a` is a superset of `b`, `false` otherwise

@@ -1680,2 +1734,4 @@ */

*
* @see {@link isSuperset} for checking if one set is a superset of another
*
* @returns `true` if `a` is a subset of `b`, `false` otherwise

@@ -2019,2 +2075,3 @@ */

exports.Stopwatch = Stopwatch;
exports.allDuplicates = allDuplicates;
exports.binarySearch = binarySearch;

@@ -2055,3 +2112,3 @@ exports.capitalize = capitalize;

exports.sample = sample;
exports.shuffle = shuffle;
exports.shuffle = typedShuffle;
exports.sortObject = sortObject;

@@ -2058,0 +2115,0 @@ exports.standardNormaldist = standardNormaldist;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@jonahsnider/util"]={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return n(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[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(r=e[Symbol.iterator]()).next.bind(r)}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var i,o;function u(e,t){var n=void 0;if("size"in e?n="size":"length"in e&&(n="length"),!n)throw new RangeError;return e[n]<t[n]?[t,e]:[e,t]}(i=e.Rank||(e.Rank={}))[i.Ace=1]="Ace",i[i.Two=2]="Two",i[i.Three=3]="Three",i[i.Four=4]="Four",i[i.Five=5]="Five",i[i.Six=6]="Six",i[i.Seven=7]="Seven",i[i.Eight=8]="Eight",i[i.Nine=9]="Nine",i[i.Ten=10]="Ten",i[i.Jack=11]="Jack",i[i.Queen=12]="Queen",i[i.King=13]="King",(o=e.Suit||(e.Suit={}))[o.Clubs=0]="Clubs",o[o.Diamonds=1]="Diamonds",o[o.Hearts=2]="Hearts",o[o.Spades=3]="Spades";var s,l,c=[{rank:e.Rank.Ace,suit:e.Suit.Clubs},{rank:e.Rank.Two,suit:e.Suit.Clubs},{rank:e.Rank.Three,suit:e.Suit.Clubs},{rank:e.Rank.Four,suit:e.Suit.Clubs},{rank:e.Rank.Five,suit:e.Suit.Clubs},{rank:e.Rank.Six,suit:e.Suit.Clubs},{rank:e.Rank.Seven,suit:e.Suit.Clubs},{rank:e.Rank.Eight,suit:e.Suit.Clubs},{rank:e.Rank.Nine,suit:e.Suit.Clubs},{rank:e.Rank.Ten,suit:e.Suit.Clubs},{rank:e.Rank.Jack,suit:e.Suit.Clubs},{rank:e.Rank.Queen,suit:e.Suit.Clubs},{rank:e.Rank.King,suit:e.Suit.Clubs},{rank:e.Rank.Ace,suit:e.Suit.Diamonds},{rank:e.Rank.Two,suit:e.Suit.Diamonds},{rank:e.Rank.Three,suit:e.Suit.Diamonds},{rank:e.Rank.Four,suit:e.Suit.Diamonds},{rank:e.Rank.Five,suit:e.Suit.Diamonds},{rank:e.Rank.Six,suit:e.Suit.Diamonds},{rank:e.Rank.Seven,suit:e.Suit.Diamonds},{rank:e.Rank.Eight,suit:e.Suit.Diamonds},{rank:e.Rank.Nine,suit:e.Suit.Diamonds},{rank:e.Rank.Ten,suit:e.Suit.Diamonds},{rank:e.Rank.Jack,suit:e.Suit.Diamonds},{rank:e.Rank.Queen,suit:e.Suit.Diamonds},{rank:e.Rank.King,suit:e.Suit.Diamonds},{rank:e.Rank.Ace,suit:e.Suit.Hearts},{rank:e.Rank.Two,suit:e.Suit.Hearts},{rank:e.Rank.Three,suit:e.Suit.Hearts},{rank:e.Rank.Four,suit:e.Suit.Hearts},{rank:e.Rank.Five,suit:e.Suit.Hearts},{rank:e.Rank.Six,suit:e.Suit.Hearts},{rank:e.Rank.Seven,suit:e.Suit.Hearts},{rank:e.Rank.Eight,suit:e.Suit.Hearts},{rank:e.Rank.Nine,suit:e.Suit.Hearts},{rank:e.Rank.Ten,suit:e.Suit.Hearts},{rank:e.Rank.Jack,suit:e.Suit.Hearts},{rank:e.Rank.Queen,suit:e.Suit.Hearts},{rank:e.Rank.King,suit:e.Suit.Hearts},{rank:e.Rank.Ace,suit:e.Suit.Spades},{rank:e.Rank.Two,suit:e.Suit.Spades},{rank:e.Rank.Three,suit:e.Suit.Spades},{rank:e.Rank.Four,suit:e.Suit.Spades},{rank:e.Rank.Five,suit:e.Suit.Spades},{rank:e.Rank.Six,suit:e.Suit.Spades},{rank:e.Rank.Seven,suit:e.Suit.Spades},{rank:e.Rank.Eight,suit:e.Suit.Spades},{rank:e.Rank.Nine,suit:e.Suit.Spades},{rank:e.Rank.Ten,suit:e.Suit.Spades},{rank:e.Rank.Jack,suit:e.Suit.Spades},{rank:e.Rank.Queen,suit:e.Suit.Spades},{rank:e.Rank.King,suit:e.Suit.Spades}];function d(e){for(var t,n=e[0].map((function(e){return e.length})),a=r(e);!(t=a()).done;)for(var i=t.value,o=0;o<i.length;o++){var u=i[o].length;n[o]<u&&(n[o]=u)}return n}!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired"}(s||(s={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(l||(l={}));var f={__proto__:null,get Status(){return s},get Method(){return l}};function v(e,t){return e+t}function h(e,t,n,r){return r.length-1===n?(e+t)/("bigint"==typeof t?BigInt(r.length):r.length):e+t}function p(e){var t=e.reduce(h);return e.map((function(e){return Math.pow(e-t,2)})).reduce(v)/(e.length-1)}function k(e,t,n){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-n/t,2))}function S(e,t){return Math.random()*(t-e)+e}var m=function(){function e(){}e.start=function(){var e=new this;return e.start(),e};var t,n=e.prototype;return n.start=function(){this.startTime=process.hrtime.bigint()},n.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(t=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}();e.Http=f,e.Sort={__proto__:null,ascending:function(e,t){return e<t?-1:e>t?1:0},descending:function(e,t){return e<t?1:e>t?-1:0}},e.Stopwatch=m,e.binarySearch=function(e,t){for(var n=0,r=e.length-1;n<=r;){var a=Math.trunc((n+r)/2),i=t(e[a]);if(i<0)n=a+1;else{if(!(i>0))return e[a];r=a-1}}},e.capitalize=function(e){var t=e.charAt(0).toUpperCase();return""+t+e.slice(t.length)},e.chunk=function(e,t){return e.length===t?e.map((function(e){return[e]})):Array.from({length:Math.ceil(e.length/t)},(function(n,r){return e.slice(r*t,r*t+t)}))},e.clamp=function(e,t,n){return e<t?t:e>n?n:e},e.difference=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)a.delete(n.value);return a},e.duplicates=function(e){for(var t,n=new Set,a=[],i=r(e);!(t=i()).done;){var o=t.value;n.has(o)&&a.push(o),n.add(o)}return a},e.first=function(e,t){var n=e[Symbol.iterator]();if(void 0===t)return n.next().value;for(var r=[],a=0;a<t;a++){var i=n.next();if(i.done)break;r.push(i.value)}return r},e.formatTable=function(e,t){void 0===t&&(t=" ");var n=d(e);return e.map((function(e){return e.map((function(e,t){return e.padEnd(n[t])})).join(t)})).join("\n")},e.frequencyTable=function(e){for(var t,n=new Map,a=r(e);!(t=a()).done;){var i=t.value,o=n.get(i);n.set(i,o?o+1:1)}return n},e.identical=function(e,t){if(e===t)return!0;if(Array.isArray(e))return e.length===t.length&&e.every((function(e,n){return e===t[n]}));if(e.size!==t.size)return!1;if(e instanceof Set){for(var n,a=r(e);!(n=a()).done;)if(!t.has(n.value))return!1}else if(e instanceof Map)for(var i,o=r(e.entries());!(i=o()).done;){var u=i.value,s=u[0],l=u[1];if(t.get(s)!==l||!t.has(s))return!1}return!0},e.intersection=function(e,t){for(var n,a=new Set,i=u(e,t),o=i[1],s=r(i[0]);!(n=s()).done;){var l=n.value;o.has(l)&&a.add(l)}return a},e.invert=function(e){return function(){return-e.apply(void 0,arguments)}},e.isDisjoint=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)if(a.has(n.value))return!1;return!0},e.isSubset=function(e,t){for(var n,a=r(e);!(n=a()).done;)if(!t.has(n.value))return!1;return!0},e.isSuperset=function(e,t){for(var n,a=r(t);!(n=a()).done;)if(!e.has(n.value))return!1;return!0},e.largeToSmall=u,e.max=function(e,t){return Math.max(e,t)},e.maxColumnLength=d,e.mean=h,e.median=function(e){var t=e.length;return t%2==0?(e[t/2-1]+e[t/2])/2:e[Math.floor(t/2)]},e.min=function(e,t){return Math.min(e,t)},e.mode=function(e){for(var t,n=new Map,a=0,i=[],o=r(e);!(t=o()).done;){var u=t.value,s=n.get(u),l=void 0===s?1:s+1;n.set(u,l),l>a?(a=l,i=[u]):l===a&&i.push(u)}return i},e.multiReplace=function(e,t){for(var n=Object.entries(t),a="",i=0;i<e.length;)e:do{for(var o,u=r(n);!(o=u()).done;){var s=o.value,l=s[0],c=s[1];if(e.slice(i).startsWith(l)){a+=c,i+=l.length;break e}}a+=e[i++]}while(0);return a},e.newDeck=function(){return[].concat(c)},e.normaldist=k,e.not=function(e){return function(){return!e.apply(void 0,arguments)}},e.nullish=function(e){return null==e},e.partition=function(e,t){for(var n,a=[],i=[],o=0,u=r(e);!(n=u()).done;){var s=n.value;(t(s,o++)?a:i).push(s)}return[a,i]},e.random=S,e.randomInt=function(e,t){return Math.floor(S(Math.ceil(e),Math.floor(t)))},e.regExpUnion=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return new RegExp(t.map((function(e){return"("+e.source+")"})).join("|"))},e.rename=function(e,n,r){var i;return n===r?t({},e):function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(a[n]=e[n]);return a}(t({},e,((i={})[r]=e[n],i)),[n].map(a))},e.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,n){return e[e.length-(n+1)]}));for(var t,n=[],a=r(e);!(t=a()).done;)n.unshift(t.value);return n},e.same=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var a=t.map((function(e){return e[Symbol.iterator]()})),i=function(){for(var e,t=a.map((function(e){return e.next()})),n=t[0],i=n.done,o=n.value,u=r(t);!(e=u()).done;){var s=e.value;if(s.done)return{v:t.every((function(e){return e.done===i}))};if(s.value!==o)return{v:!1}}};;){var o=i();if("object"==typeof o)return o.v}},e.sample=function(e){return e[Math.floor(Math.random()*e.length)]},e.shuffle=function(e,t){void 0===t&&(t=!0);for(var n=t?e:[].concat(e),r=n.length-1;r>0;r--){var a=Math.floor(Math.random()*(r+1)),i=[n[a],n[r]];n[r]=i[0],n[a]=i[1]}if(!t)return n},e.sortObject=function(e,t){return Object.entries(e).sort((function(e,n){return t(e[1],n[1])}))},e.standardNormaldist=function(e){return k(e,1,0)},e.stddev=function(e){return Math.sqrt(p(e))},e.sum=v,e.symmetricDifference=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;){var o=n.value;a.has(o)?a.delete(o):a.add(o)}return a},e.toDigits=function(e,t){var n=Math.pow(10,t);return Math.round(e*n*(1+Number.EPSILON))/n},e.truncate=function(e,t,n){return void 0===n&&(n=""),e.length>t?""+e.slice(0,t)+n:e},e.uncapitalize=function(e){var t=e.charAt(0).toLowerCase();return""+t+e.slice(t.length)},e.union=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)a.add(n.value);return a},e.variance=p,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@jonahsnider/util"]={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return n(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[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(r=e[Symbol.iterator]()).next.bind(r)}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var i,o;function u(e,t){var n=void 0;if("size"in e?n="size":"length"in e&&(n="length"),!n)throw new RangeError;return e[n]<t[n]?[t,e]:[e,t]}(i=e.Rank||(e.Rank={}))[i.Ace=1]="Ace",i[i.Two=2]="Two",i[i.Three=3]="Three",i[i.Four=4]="Four",i[i.Five=5]="Five",i[i.Six=6]="Six",i[i.Seven=7]="Seven",i[i.Eight=8]="Eight",i[i.Nine=9]="Nine",i[i.Ten=10]="Ten",i[i.Jack=11]="Jack",i[i.Queen=12]="Queen",i[i.King=13]="King",(o=e.Suit||(e.Suit={}))[o.Clubs=0]="Clubs",o[o.Diamonds=1]="Diamonds",o[o.Hearts=2]="Hearts",o[o.Spades=3]="Spades";var s,l,c=[{rank:e.Rank.Ace,suit:e.Suit.Clubs},{rank:e.Rank.Two,suit:e.Suit.Clubs},{rank:e.Rank.Three,suit:e.Suit.Clubs},{rank:e.Rank.Four,suit:e.Suit.Clubs},{rank:e.Rank.Five,suit:e.Suit.Clubs},{rank:e.Rank.Six,suit:e.Suit.Clubs},{rank:e.Rank.Seven,suit:e.Suit.Clubs},{rank:e.Rank.Eight,suit:e.Suit.Clubs},{rank:e.Rank.Nine,suit:e.Suit.Clubs},{rank:e.Rank.Ten,suit:e.Suit.Clubs},{rank:e.Rank.Jack,suit:e.Suit.Clubs},{rank:e.Rank.Queen,suit:e.Suit.Clubs},{rank:e.Rank.King,suit:e.Suit.Clubs},{rank:e.Rank.Ace,suit:e.Suit.Diamonds},{rank:e.Rank.Two,suit:e.Suit.Diamonds},{rank:e.Rank.Three,suit:e.Suit.Diamonds},{rank:e.Rank.Four,suit:e.Suit.Diamonds},{rank:e.Rank.Five,suit:e.Suit.Diamonds},{rank:e.Rank.Six,suit:e.Suit.Diamonds},{rank:e.Rank.Seven,suit:e.Suit.Diamonds},{rank:e.Rank.Eight,suit:e.Suit.Diamonds},{rank:e.Rank.Nine,suit:e.Suit.Diamonds},{rank:e.Rank.Ten,suit:e.Suit.Diamonds},{rank:e.Rank.Jack,suit:e.Suit.Diamonds},{rank:e.Rank.Queen,suit:e.Suit.Diamonds},{rank:e.Rank.King,suit:e.Suit.Diamonds},{rank:e.Rank.Ace,suit:e.Suit.Hearts},{rank:e.Rank.Two,suit:e.Suit.Hearts},{rank:e.Rank.Three,suit:e.Suit.Hearts},{rank:e.Rank.Four,suit:e.Suit.Hearts},{rank:e.Rank.Five,suit:e.Suit.Hearts},{rank:e.Rank.Six,suit:e.Suit.Hearts},{rank:e.Rank.Seven,suit:e.Suit.Hearts},{rank:e.Rank.Eight,suit:e.Suit.Hearts},{rank:e.Rank.Nine,suit:e.Suit.Hearts},{rank:e.Rank.Ten,suit:e.Suit.Hearts},{rank:e.Rank.Jack,suit:e.Suit.Hearts},{rank:e.Rank.Queen,suit:e.Suit.Hearts},{rank:e.Rank.King,suit:e.Suit.Hearts},{rank:e.Rank.Ace,suit:e.Suit.Spades},{rank:e.Rank.Two,suit:e.Suit.Spades},{rank:e.Rank.Three,suit:e.Suit.Spades},{rank:e.Rank.Four,suit:e.Suit.Spades},{rank:e.Rank.Five,suit:e.Suit.Spades},{rank:e.Rank.Six,suit:e.Suit.Spades},{rank:e.Rank.Seven,suit:e.Suit.Spades},{rank:e.Rank.Eight,suit:e.Suit.Spades},{rank:e.Rank.Nine,suit:e.Suit.Spades},{rank:e.Rank.Ten,suit:e.Suit.Spades},{rank:e.Rank.Jack,suit:e.Suit.Spades},{rank:e.Rank.Queen,suit:e.Suit.Spades},{rank:e.Rank.King,suit:e.Suit.Spades}];function d(e){for(var t,n=e[0].map((function(e){return e.length})),a=r(e);!(t=a()).done;)for(var i=t.value,o=0;o<i.length;o++){var u=i[o].length;n[o]<u&&(n[o]=u)}return n}!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired"}(s||(s={})),function(e){e.Get="GET",e.Head="HEAD",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(l||(l={}));var f={__proto__:null,get Status(){return s},get Method(){return l}};function v(e,t){return e+t}function h(e){var t=S(e);return e.map((function(e){return Math.pow(e-t,2)})).reduce(v)/(e.length-1)}function p(e,t,n){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-n/t,2))}function S(e){var t=e.reduce(v);return t/("bigint"==typeof t?BigInt(e.length):e.length)}function k(e,t){return Math.random()*(t-e)+e}var m=function(){function e(){}e.start=function(){var e=new this;return e.start(),e};var t,n=e.prototype;return n.start=function(){this.startTime=process.hrtime.bigint()},n.end=function(){return Number(process.hrtime.bigint()-this.startTime)/1e6},(t=[{key:"started",get:function(){return void 0!==this.startTime}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}();e.Http=f,e.Sort={__proto__:null,ascending:function(e,t){return e<t?-1:e>t?1:0},descending:function(e,t){return e<t?1:e>t?-1:0}},e.Stopwatch=m,e.allDuplicates=function(e){for(var t,n=new Set,a=[],i=r(e);!(t=i()).done;){var o=t.value;n.has(o)&&a.push(o),n.add(o)}return a},e.binarySearch=function(e,t){for(var n=0,r=e.length-1;n<=r;){var a=Math.trunc((n+r)/2),i=t(e[a]);if(i<0)n=a+1;else{if(!(i>0))return e[a];r=a-1}}},e.capitalize=function(e){var t=e.charAt(0).toUpperCase();return""+t+e.slice(t.length)},e.chunk=function(e,t){return e.length===t?e.map((function(e){return[e]})):Array.from({length:Math.ceil(e.length/t)},(function(n,r){return e.slice(r*t,r*t+t)}))},e.clamp=function(e,t,n){return e<t?t:e>n?n:e},e.difference=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)a.delete(n.value);return a},e.duplicates=function(e){for(var t,n=new Set,a=new Set,i=r(e);!(t=i()).done;){var o=t.value;n.has(o)&&a.add(o),n.add(o)}return a},e.first=function(e,t){var n=e[Symbol.iterator]();if(void 0===t)return n.next().value;for(var r=[],a=0;a<t;a++){var i=n.next();if(i.done)break;r.push(i.value)}return r},e.formatTable=function(e,t){void 0===t&&(t=" ");var n=d(e);return e.map((function(e){return e.map((function(e,t){return e.padEnd(n[t])})).join(t)})).join("\n")},e.frequencyTable=function(e){for(var t,n=new Map,a=r(e);!(t=a()).done;){var i=t.value,o=n.get(i);n.set(i,o?o+1:1)}return n},e.identical=function(e,t){if(e===t)return!0;if(Array.isArray(e))return e.length===t.length&&e.every((function(e,n){return e===t[n]}));if(e.size!==t.size)return!1;if(e instanceof Set){for(var n,a=r(e);!(n=a()).done;)if(!t.has(n.value))return!1}else if(e instanceof Map)for(var i,o=r(e.entries());!(i=o()).done;){var u=i.value,s=u[0],l=u[1];if(t.get(s)!==l||!t.has(s))return!1}return!0},e.intersection=function(e,t){for(var n,a=new Set,i=u(e,t),o=i[1],s=r(i[0]);!(n=s()).done;){var l=n.value;o.has(l)&&a.add(l)}return a},e.invert=function(e){return function(){return-e.apply(void 0,arguments)}},e.isDisjoint=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)if(a.has(n.value))return!1;return!0},e.isSubset=function(e,t){for(var n,a=r(e);!(n=a()).done;)if(!t.has(n.value))return!1;return!0},e.isSuperset=function(e,t){for(var n,a=r(t);!(n=a()).done;)if(!e.has(n.value))return!1;return!0},e.largeToSmall=u,e.max=function(e,t){return Math.max(e,t)},e.maxColumnLength=d,e.mean=S,e.median=function(e){var t=e.length/2;return e.length%2==0?(e[t-1]+e[t])/("bigint"==typeof e[0]?2n:2):e[Math.floor(t)]},e.min=function(e,t){return Math.min(e,t)},e.mode=function(e){for(var t,n=new Map,a=0,i=[],o=r(e);!(t=o()).done;){var u=t.value,s=n.get(u),l=void 0===s?1:s+1;n.set(u,l),l>a?(a=l,i=[u]):l===a&&i.push(u)}return i},e.multiReplace=function(e,t){for(var n=Object.entries(t),a="",i=0;i<e.length;)e:do{for(var o,u=r(n);!(o=u()).done;){var s=o.value,l=s[0],c=s[1];if(e.slice(i).startsWith(l)){a+=c,i+=l.length;break e}}a+=e[i++]}while(0);return a},e.newDeck=function(){return[].concat(c)},e.normaldist=p,e.not=function(e){return function(){return!e.apply(void 0,arguments)}},e.nullish=function(e){return null==e},e.partition=function(e,t){for(var n,a=[],i=[],o=0,u=r(e);!(n=u()).done;){var s=n.value;(t(s,o++)?a:i).push(s)}return[a,i]},e.random=k,e.randomInt=function(e,t){return Math.floor(k(Math.ceil(e),Math.floor(t)))},e.regExpUnion=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return new RegExp(t.map((function(e){return"("+e.source+")"})).join("|"))},e.rename=function(e,n,r){var i;return n===r?t({},e):function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(a[n]=e[n]);return a}(t({},e,((i={})[r]=e[n],i)),[n].map(a))},e.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,n){return e[e.length-(n+1)]}));for(var t,n=[],a=r(e);!(t=a()).done;)n.unshift(t.value);return n},e.same=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var a=t.map((function(e){return e[Symbol.iterator]()})),i=function(){for(var e,t=a.map((function(e){return e.next()})),n=t[0],i=n.done,o=n.value,u=r(t);!(e=u()).done;){var s=e.value;if(s.done)return{v:t.every((function(e){return e.done===i}))};if(s.value!==o)return{v:!1}}};;){var o=i();if("object"==typeof o)return o.v}},e.sample=function(e){return e[Math.floor(Math.random()*e.length)]},e.shuffle=function(e,t){void 0===t&&(t=!0);for(var n=t?e:[].concat(e),r=n.length-1;r>0;r--){var a=Math.floor(Math.random()*(r+1)),i=[n[a],n[r]];n[r]=i[0],n[a]=i[1]}if(!t)return n},e.sortObject=function(e,t){return Object.entries(e).sort((function(e,n){return t(e[1],n[1])}))},e.standardNormaldist=function(e){return p(e,1,0)},e.stddev=function(e){return Math.sqrt(h(e))},e.sum=v,e.symmetricDifference=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;){var o=n.value;a.has(o)?a.delete(o):a.add(o)}return a},e.toDigits=function(e,t){var n=Math.pow(10,t);return Math.round(e*n*(1+Number.EPSILON))/n},e.truncate=function(e,t,n){return void 0===n&&(n=""),e.length>t?""+e.slice(0,t)+n:e},e.uncapitalize=function(e){var t=e.charAt(0).toLowerCase();return""+t+e.slice(t.length)},e.union=function(e,t){for(var n,a=new Set(e),i=r(t);!(n=i()).done;)a.add(n.value);return a},e.variance=h,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=util.umd.production.min.js.map

@@ -72,3 +72,3 @@ {

"typings": "dist/index.d.ts",
"version": "3.2.0"
"version": "4.0.0"
}
# [@jonahsnider/util](https://util.jonah.pw/)
A useful collection of optimized utility functions.
Written in TypeScript and designed to have very safe types.
A collection of simple, optimized utility functions that help you spend more time implementing real features instead of writing the same snippets over and over.
Written in TypeScript with strong typesafety in mind (more on that below).
Works in Node.js, mostly works in browsers.
**[Read docs here](https://util.jonah.pw/)**.
**[View the docs here](https://util.jonah.pw/)**.
If you're considering using the library I recommend taking a glance at the docs to see if anything seems helpful to you.
[![Build Status](https://github.com/jonahsnider/util/workflows/CI/badge.svg)](https://github.com/jonahsnider/util/actions)

@@ -13,2 +17,4 @@ [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)

## Get started
```sh

@@ -25,3 +31,66 @@ yarn add @jonahsnider/util

// or
import * as util from '@jonahsnider/util';
const {shuffle} = require('@jonahsnider/util');
// or
const util = require('@jonahsnider/util');
```
## Why you should use this library
There's 3 main benefits this library offers:
1. **Readability**
Because JavaScript lacks a proper standard library, you will find yourself writing the same snippets again and again.
Let's look at sorting an array in ascending order (low to high) as an example:
```js
// Sort ascending
array.sort((a, b) => a - b);
```
As an experienced dev you've probably seen this snippet in some form hundreds of times before.
If you're a beginner you might not even be able to tell if this is an ascending or descending sort without the comment.
The alternative:
```js
import {Sort} from '@jonahsnider/util';
array.sort(Sort.ascending);
```
If you were skimming through a file and saw this you can immediately understand what this code does.
This library works perfectly with existing idiomatic JavaScript and doesn't force you to change the way you write code.
(also - fun fact: the first snippet doesn't work with `bigint`s, [the second snippet does](https://util.jonah.pw/modules#comparable))
2. **Safety**
Writing your own snippets doesn't just slow you down, it can introduce bugs.
Every function is tested with 100% coverage, ensuring bug-free code.
3. **Features**
This library isn't just 1-liners you could copy-paste yourself.
Want to do a binary search on an array? [We've got you covered](https://util.jonah.pw/modules#binarysearch).
Combine a bunch of regular expressions into one? [No problem](https://util.jonah.pw/modules#regexpunion).
Need a deck of cards? [Only one import away](https://util.jonah.pw/modules#newdeck).
### TypeScript
In addition to all the useful functions this library provides, a major effort has been made to ensure the best possible experience for TypeScript users.
- Functions accept many types of arguments, either as a generic `T` or a union of related types like `number | bigint` (mostly useful in the math functions)
- `Iterable`s are used instead of `Array`s whenever possible, broader types ensure compatibility with your projects
- When an array is needed, it's always `readonly T[]` unless mutation is required
There's also a few types exported that can be handy in certain situations (ex. [`NonEmptyArray`](https://util.jonah.pw/modules#nonemptyarray) or [`Nullish`](https://util.jonah.pw/modules#nullish)).
My personal favorite is the [`TypedEventEmitter`](https://util.jonah.pw/interfaces/typedeventemitter) which lets you ensure typesafety in event listeners.

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

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