@jonahsnider/util
Advanced tools
Comparing version 2.16.1 to 3.0.0
@@ -160,18 +160,31 @@ /** A 2-dimensional table of type `T`. */ | ||
/** | ||
* Get the first `n` items from an iterable. | ||
* Get the first element from an iterable. | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3]); // [1] | ||
* first([1, 2, 3]); // 1 | ||
* ``` | ||
* | ||
* @param iterable - The iterable to take elements from | ||
* | ||
* @returns The first element of the iterable | ||
*/ | ||
export declare function first<T>(iterable: Iterable<T>, take?: undefined): T | undefined; | ||
/** | ||
* Get the first `n` elements from an iterable. | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3], 1); // [1] | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3], 2); // [1, 2] | ||
* ``` | ||
* | ||
* @param iterable - The iterable to take items from | ||
* @param take - The number of items to take from the iterable | ||
* @param iterable - The iterable to take elements from | ||
* @param take - The number of elements to take from the iterable | ||
* | ||
* @returns The first `take` items of the iterable | ||
* @returns The first `take` elements of the iterable | ||
*/ | ||
@@ -178,0 +191,0 @@ export declare function first<T>(iterable: Iterable<T>, take?: number): T[]; |
/** | ||
* Check if two arrays have the same items in the same order. | ||
* Check if two arrays have the same elements in the same order. | ||
* Strict equality (`===`) is used to compare elements. | ||
@@ -10,3 +10,3 @@ * | ||
* | ||
* identicalManual(a, b) === true; | ||
* identical(a, b) === true; | ||
* ``` | ||
@@ -17,7 +17,7 @@ * | ||
* | ||
* @returns `true` if `a` and `b` have the same items in the same order, `false` otherwise | ||
* @returns `true` if `a` and `b` have the same elements in the same order, `false` otherwise | ||
*/ | ||
export declare function identicalManual<V>(a: readonly V[], b: readonly V[]): boolean; | ||
export declare function identical<V>(a: readonly V[], b: readonly V[]): boolean; | ||
/** | ||
* Check if two `Set`s have the same items. | ||
* Check if two `Set`s have the same elements. | ||
* Strict equality (`===`) is used to compare elements. | ||
@@ -30,3 +30,3 @@ * | ||
* | ||
* identicalManual(a, b) === true; | ||
* identical(a, b) === true; | ||
* ``` | ||
@@ -37,5 +37,5 @@ * | ||
* | ||
* @returns `true` if `a` and `b` have the same items, `false` otherwise | ||
* @returns `true` if `a` and `b` have the same elements, `false` otherwise | ||
*/ | ||
export declare function identicalManual<V>(a: ReadonlySet<V>, b: ReadonlySet<V>): boolean; | ||
export declare function identical<V>(a: ReadonlySet<V>, b: ReadonlySet<V>): boolean; | ||
/** | ||
@@ -50,3 +50,3 @@ * Check if two `Map`s have the same key-value pairs. | ||
* | ||
* identicalManual(a, b) === true; | ||
* identical(a, b) === true; | ||
* ``` | ||
@@ -59,5 +59,5 @@ * | ||
*/ | ||
export declare function identicalManual<K, V>(a: ReadonlyMap<K, V>, b: ReadonlyMap<K, V>): boolean; | ||
export declare function identical<K, V>(a: ReadonlyMap<K, V>, b: ReadonlyMap<K, V>): boolean; | ||
/** | ||
* Check if 2 or more iterables are not the same object, but hold the same elements. | ||
* Check if 2 or more iterables hold the same elements. | ||
* Strict equality (`===`) is used to compare elements. | ||
@@ -73,3 +73,3 @@ * | ||
* | ||
* identical(a, b, c, d, e) === true; | ||
* same(a, b, c, d, e) === true; | ||
* ``` | ||
@@ -79,4 +79,4 @@ * | ||
* | ||
* @returns `true` if all elements are identical, `false` otherwise | ||
* @returns `true` if all elements are strictly equal, `false` otherwise | ||
*/ | ||
export declare function identical<T>(...iterables: [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]): boolean; | ||
export declare function same<T>(...iterables: [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]): boolean; |
@@ -13,3 +13,2 @@ export * from './array'; | ||
export * from './sort'; | ||
export * from './sort-compare'; | ||
export * as Sort from './sort-compare'; | ||
@@ -16,0 +15,0 @@ export * from './stopwatch'; |
@@ -9,3 +9,3 @@ import { Comparable } from './sort'; | ||
* | ||
* array.sort(ascending); | ||
* array.sort(Sort.ascending); | ||
* ``` | ||
@@ -25,3 +25,3 @@ * | ||
* | ||
* array.sort(descending); | ||
* array.sort(Sort.descending); | ||
* ``` | ||
@@ -28,0 +28,0 @@ * |
@@ -14,5 +14,7 @@ /** A value that can be compared numerically using `<`, `>`, `<=`, or `>=`. */ | ||
* ```ts | ||
* import { Sort } from '@jonahsnider/util'; | ||
* | ||
* const object = {a: 3, c: 1, b: 2}; | ||
* | ||
* sortObject(object, (a, b) => a - b); | ||
* Object.fromEntries(sortObject(object, Sort.ascending)); | ||
* ``` | ||
@@ -25,2 +27,2 @@ * | ||
*/ | ||
export declare function sortObject<K extends PropertyKey, V>(object: Record<K, V>, compareFn: CompareFn<V>): Record<K, V>; | ||
export declare function sortObject<K extends PropertyKey, V>(object: Record<K, V>, compareFn: CompareFn<V>): Array<[K, V]>; |
@@ -300,29 +300,10 @@ 'use strict'; | ||
} | ||
/** | ||
* Get the first `n` items from an iterable. | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3]); // [1] | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3], 2); // [1, 2] | ||
* ``` | ||
* | ||
* @param iterable - The iterable to take items from | ||
* @param take - The number of items to take from the iterable | ||
* | ||
* @returns The first `take` items of the iterable | ||
*/ | ||
// TODO: If take is undefined return T directly instead of T[] | ||
function first(iterable, take) { | ||
var iterator = iterable[Symbol.iterator](); | ||
function first(iterable, take) { | ||
if (take === void 0) { | ||
take = 1; | ||
if (take === undefined) { | ||
return iterator.next().value; | ||
} | ||
var result = []; | ||
var iterator = iterable[Symbol.iterator](); | ||
@@ -1157,3 +1138,3 @@ for (var i = 0; i < take; i++) { | ||
function identicalManual(a, b) { | ||
function identical(a, b) { | ||
if (a === b) { | ||
@@ -1201,3 +1182,3 @@ return true; | ||
/** | ||
* Check if 2 or more iterables are not the same object, but hold the same elements. | ||
* Check if 2 or more iterables hold the same elements. | ||
* Strict equality (`===`) is used to compare elements. | ||
@@ -1213,3 +1194,3 @@ * | ||
* | ||
* identical(a, b, c, d, e) === true; | ||
* same(a, b, c, d, e) === true; | ||
* ``` | ||
@@ -1219,7 +1200,6 @@ * | ||
* | ||
* @returns `true` if all elements are identical, `false` otherwise | ||
* @returns `true` if all elements are strictly equal, `false` otherwise | ||
*/ | ||
// TODO: Rename to same in v3 | ||
function identical() { | ||
function same() { | ||
for (var _len = arguments.length, iterables = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -1724,5 +1704,7 @@ iterables[_key] = arguments[_key]; | ||
* ```ts | ||
* import { Sort } from '@jonahsnider/util'; | ||
* | ||
* const object = {a: 3, c: 1, b: 2}; | ||
* | ||
* sortObject(object, (a, b) => a - b); | ||
* Object.fromEntries(sortObject(object, Sort.ascending)); | ||
* ``` | ||
@@ -1736,7 +1718,7 @@ * | ||
function sortObject(object, compareFn) { | ||
return Object.fromEntries(Object.entries(object).sort(function (_ref, _ref2) { | ||
return Object.entries(object).sort(function (_ref, _ref2) { | ||
var aValue = _ref[1]; | ||
var bValue = _ref2[1]; | ||
return compareFn(aValue, bValue); | ||
})); | ||
}); | ||
} | ||
@@ -1751,3 +1733,3 @@ | ||
* | ||
* array.sort(ascending); | ||
* array.sort(Sort.ascending); | ||
* ``` | ||
@@ -1778,3 +1760,3 @@ * | ||
* | ||
* array.sort(descending); | ||
* array.sort(Sort.descending); | ||
* ``` | ||
@@ -1930,3 +1912,2 @@ * | ||
exports.Stopwatch = Stopwatch; | ||
exports.ascending = ascending; | ||
exports.binarySearch = binarySearch; | ||
@@ -1936,3 +1917,2 @@ exports.capitalize = capitalize; | ||
exports.clamp = clamp; | ||
exports.descending = descending; | ||
exports.difference = difference; | ||
@@ -1944,3 +1924,2 @@ exports.duplicates = duplicates; | ||
exports.identical = identical; | ||
exports.identicalManual = identicalManual; | ||
exports.intersection = intersection; | ||
@@ -1967,2 +1946,3 @@ exports.isDisjoint = isDisjoint; | ||
exports.reverse = reverse; | ||
exports.same = same; | ||
exports.sample = sample; | ||
@@ -1969,0 +1949,0 @@ exports.shuffle = shuffle; |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(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 t(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[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=t[Symbol.iterator]()).next.bind(n)}var r,n;function o(e,t){var r=void 0;if("size"in e?r="size":"length"in e&&(r="length"),!r)throw new RangeError("Expected a to have a size property or a length property");return e[r]<t[r]?[t,e]:[e,t]}Object.defineProperty(exports,"__esModule",{value:!0}),(r=exports.Rank||(exports.Rank={}))[r.Ace=1]="Ace",r[r.Two=2]="Two",r[r.Three=3]="Three",r[r.Four=4]="Four",r[r.Five=5]="Five",r[r.Six=6]="Six",r[r.Seven=7]="Seven",r[r.Eight=8]="Eight",r[r.Nine=9]="Nine",r[r.Ten=10]="Ten",r[r.Jack=11]="Jack",r[r.Queen=12]="Queen",r[r.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 a,i,s=[{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 u(e){for(var r,n=e[0].map((function(e){return e.length})),o=t(e);!(r=o()).done;)for(var a=r.value,i=0;i<a.length;i++){var s=a[i].length;n[i]<s&&(n[i]=s)}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"}(a||(a={})),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"}(i||(i={}));var p={__proto__:null,get Status(){return a},get Method(){return i}};function d(e,t){return e+t}function c(e,t,r,n){return n.length-1===r?(e+t)/("bigint"==typeof t?BigInt(n.length):n.length):e+t}function l(e){var t=e.reduce(c);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 f(e,t){return Math.random()*(t-e)+e}function v(e,t){return e<t?-1:e>t?1:0}function h(e,t){return e<t?1:e>t?-1:0}var k={__proto__:null,ascending:v,descending:h},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=p,exports.Sort=k,exports.Stopwatch=S,exports.ascending=v,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.descending=h,exports.difference=function(e,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)o.delete(n.value);return o},exports.duplicates=function(e){for(var r,n=new Set,o=[],a=t(e);!(r=a()).done;){var i=r.value;n.has(i)&&o.push(i),n.add(i)}return o},exports.first=function(e,t){void 0===t&&(t=1);for(var r=[],n=e[Symbol.iterator](),o=0;o<t;o++){var a=n.next();if(a.done)break;r.push(a.value)}return r},exports.formatTable=function(e,t){void 0===t&&(t=" ");var r=u(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 r,n=new Map,o=t(e);!(r=o()).done;){var a=r.value,i=n.get(a);n.set(a,i?i+1:1)}return n},exports.identical=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var o=r.map((function(e){return e[Symbol.iterator]()})),a=function(){for(var e,r=o.map((function(e){return e.next()})),n=r[0],a=n.done,i=n.value,s=t(r);!(e=s()).done;){var u=e.value;if(u.done)return{v:r.every((function(e){return e.done===a}))};if(u.value!==i)return{v:!1}}};;){var i=a();if("object"==typeof i)return i.v}},exports.identicalManual=function(e,r){if(e===r)return!0;if(Array.isArray(e))return e.length===r.length&&e.every((function(e,t){return e===r[t]}));if(e.size!==r.size)return!1;if(e instanceof Set){for(var n,o=t(e);!(n=o()).done;)if(!r.has(n.value))return!1}else if(e instanceof Map)for(var a,i=t(e.entries());!(a=i()).done;){var s=a.value,u=s[0],p=s[1];if(r.get(u)!==p||!r.has(u))return!1}return!0},exports.intersection=function(e,r){for(var n,a=new Set,i=o(e,r),s=i[1],u=t(i[0]);!(n=u()).done;){var p=n.value;s.has(p)&&a.add(p)}return a},exports.isDisjoint=function(e,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)if(o.has(n.value))return!1;return!0},exports.isSubset=function(e,r){for(var n,o=t(e);!(n=o()).done;)if(!r.has(n.value))return!1;return!0},exports.isSuperset=function(e,r){for(var n,o=t(r);!(n=o()).done;)if(!e.has(n.value))return!1;return!0},exports.largeToSmall=o,exports.max=function(e,t){return Math.max(e,t)},exports.maxColumnLength=u,exports.mean=c,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 r,n=new Map,o=0,a=[],i=t(e);!(r=i()).done;){var s=r.value,u=n.get(s),p=void 0===u?1:u+1;n.set(s,p),p>o?(o=p,a=[s]):p===o&&a.push(s)}return a},exports.multiReplace=function(e,r){for(var n=Object.entries(r),o="",a=0;a<e.length;)e:do{for(var i,s=t(n);!(i=s()).done;){var u=i.value,p=u[0],d=u[1];if(e.slice(a).startsWith(p)){o+=d,a+=p.length;break e}}o+=e[a++]}while(0);return o},exports.newDeck=function(){return[].concat(s)},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,r){for(var n,o=[],a=[],i=0,s=t(e);!(n=s()).done;){var u=n.value;(r(u,i++)?o:a).push(u)}return[o,a]},exports.random=f,exports.randomInt=function(e,t){return Math.floor(f(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.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,r){return e[e.length-(r+1)]}));for(var r,n=[],o=t(e);!(r=o()).done;)n.unshift(r.value);return n},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.fromEntries(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(l(e))},exports.sum=d,exports.symmetricDifference=function(e,r){for(var n,o=new Set(e),a=t(r);!(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,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)o.add(n.value);return o},exports.variance=l; | ||
"use strict";function e(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 t(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[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=t[Symbol.iterator]()).next.bind(n)}var r,n;function o(e,t){var r=void 0;if("size"in e?r="size":"length"in e&&(r="length"),!r)throw new RangeError("Expected a to have a size property or a length property");return e[r]<t[r]?[t,e]:[e,t]}Object.defineProperty(exports,"__esModule",{value:!0}),(r=exports.Rank||(exports.Rank={}))[r.Ace=1]="Ace",r[r.Two=2]="Two",r[r.Three=3]="Three",r[r.Four=4]="Four",r[r.Five=5]="Five",r[r.Six=6]="Six",r[r.Seven=7]="Seven",r[r.Eight=8]="Eight",r[r.Nine=9]="Nine",r[r.Ten=10]="Ten",r[r.Jack=11]="Jack",r[r.Queen=12]="Queen",r[r.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 a,i,s=[{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 u(e){for(var r,n=e[0].map((function(e){return e.length})),o=t(e);!(r=o()).done;)for(var a=r.value,i=0;i<a.length;i++){var s=a[i].length;n[i]<s&&(n[i]=s)}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"}(a||(a={})),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"}(i||(i={}));var p={__proto__:null,get Status(){return a},get Method(){return i}};function l(e,t){return e+t}function d(e,t,r,n){return n.length-1===r?(e+t)/("bigint"==typeof t?BigInt(n.length):n.length):e+t}function c(e){var t=e.reduce(d);return e.map((function(e){return Math.pow(e-t,2)})).reduce(l)/(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 f(e,t){return Math.random()*(t-e)+e}var v=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=p,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=v,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,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)o.delete(n.value);return o},exports.duplicates=function(e){for(var r,n=new Set,o=[],a=t(e);!(r=a()).done;){var i=r.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=u(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 r,n=new Map,o=t(e);!(r=o()).done;){var a=r.value,i=n.get(a);n.set(a,i?i+1:1)}return n},exports.identical=function(e,r){if(e===r)return!0;if(Array.isArray(e))return e.length===r.length&&e.every((function(e,t){return e===r[t]}));if(e.size!==r.size)return!1;if(e instanceof Set){for(var n,o=t(e);!(n=o()).done;)if(!r.has(n.value))return!1}else if(e instanceof Map)for(var a,i=t(e.entries());!(a=i()).done;){var s=a.value,u=s[0],p=s[1];if(r.get(u)!==p||!r.has(u))return!1}return!0},exports.intersection=function(e,r){for(var n,a=new Set,i=o(e,r),s=i[1],u=t(i[0]);!(n=u()).done;){var p=n.value;s.has(p)&&a.add(p)}return a},exports.isDisjoint=function(e,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)if(o.has(n.value))return!1;return!0},exports.isSubset=function(e,r){for(var n,o=t(e);!(n=o()).done;)if(!r.has(n.value))return!1;return!0},exports.isSuperset=function(e,r){for(var n,o=t(r);!(n=o()).done;)if(!e.has(n.value))return!1;return!0},exports.largeToSmall=o,exports.max=function(e,t){return Math.max(e,t)},exports.maxColumnLength=u,exports.mean=d,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 r,n=new Map,o=0,a=[],i=t(e);!(r=i()).done;){var s=r.value,u=n.get(s),p=void 0===u?1:u+1;n.set(s,p),p>o?(o=p,a=[s]):p===o&&a.push(s)}return a},exports.multiReplace=function(e,r){for(var n=Object.entries(r),o="",a=0;a<e.length;)e:do{for(var i,s=t(n);!(i=s()).done;){var u=i.value,p=u[0],l=u[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(s)},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,r){for(var n,o=[],a=[],i=0,s=t(e);!(n=s()).done;){var u=n.value;(r(u,i++)?o:a).push(u)}return[o,a]},exports.random=f,exports.randomInt=function(e,t){return Math.floor(f(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.reverse=function(e){if(Array.isArray(e))return Array.from({length:e.length},(function(t,r){return e[e.length-(r+1)]}));for(var r,n=[],o=t(e);!(r=o()).done;)n.unshift(r.value);return n},exports.same=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var o=r.map((function(e){return e[Symbol.iterator]()})),a=function(){for(var e,r=o.map((function(e){return e.next()})),n=r[0],a=n.done,i=n.value,s=t(r);!(e=s()).done;){var u=e.value;if(u.done)return{v:r.every((function(e){return e.done===a}))};if(u.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(c(e))},exports.sum=l,exports.symmetricDifference=function(e,r){for(var n,o=new Set(e),a=t(r);!(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,r){for(var n,o=new Set(e),a=t(r);!(n=a()).done;)o.add(n.value);return o},exports.variance=c; | ||
//# sourceMappingURL=util.cjs.production.min.js.map |
@@ -302,29 +302,10 @@ (function (global, factory) { | ||
} | ||
/** | ||
* Get the first `n` items from an iterable. | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3]); // [1] | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* first([1, 2, 3], 2); // [1, 2] | ||
* ``` | ||
* | ||
* @param iterable - The iterable to take items from | ||
* @param take - The number of items to take from the iterable | ||
* | ||
* @returns The first `take` items of the iterable | ||
*/ | ||
// TODO: If take is undefined return T directly instead of T[] | ||
function first(iterable, take) { | ||
var iterator = iterable[Symbol.iterator](); | ||
function first(iterable, take) { | ||
if (take === void 0) { | ||
take = 1; | ||
if (take === undefined) { | ||
return iterator.next().value; | ||
} | ||
var result = []; | ||
var iterator = iterable[Symbol.iterator](); | ||
@@ -1159,3 +1140,3 @@ for (var i = 0; i < take; i++) { | ||
function identicalManual(a, b) { | ||
function identical(a, b) { | ||
if (a === b) { | ||
@@ -1203,3 +1184,3 @@ return true; | ||
/** | ||
* Check if 2 or more iterables are not the same object, but hold the same elements. | ||
* Check if 2 or more iterables hold the same elements. | ||
* Strict equality (`===`) is used to compare elements. | ||
@@ -1215,3 +1196,3 @@ * | ||
* | ||
* identical(a, b, c, d, e) === true; | ||
* same(a, b, c, d, e) === true; | ||
* ``` | ||
@@ -1221,7 +1202,6 @@ * | ||
* | ||
* @returns `true` if all elements are identical, `false` otherwise | ||
* @returns `true` if all elements are strictly equal, `false` otherwise | ||
*/ | ||
// TODO: Rename to same in v3 | ||
function identical() { | ||
function same() { | ||
for (var _len = arguments.length, iterables = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -1726,5 +1706,7 @@ iterables[_key] = arguments[_key]; | ||
* ```ts | ||
* import { Sort } from '@jonahsnider/util'; | ||
* | ||
* const object = {a: 3, c: 1, b: 2}; | ||
* | ||
* sortObject(object, (a, b) => a - b); | ||
* Object.fromEntries(sortObject(object, Sort.ascending)); | ||
* ``` | ||
@@ -1738,7 +1720,7 @@ * | ||
function sortObject(object, compareFn) { | ||
return Object.fromEntries(Object.entries(object).sort(function (_ref, _ref2) { | ||
return Object.entries(object).sort(function (_ref, _ref2) { | ||
var aValue = _ref[1]; | ||
var bValue = _ref2[1]; | ||
return compareFn(aValue, bValue); | ||
})); | ||
}); | ||
} | ||
@@ -1753,3 +1735,3 @@ | ||
* | ||
* array.sort(ascending); | ||
* array.sort(Sort.ascending); | ||
* ``` | ||
@@ -1780,3 +1762,3 @@ * | ||
* | ||
* array.sort(descending); | ||
* array.sort(Sort.descending); | ||
* ``` | ||
@@ -1932,3 +1914,2 @@ * | ||
exports.Stopwatch = Stopwatch; | ||
exports.ascending = ascending; | ||
exports.binarySearch = binarySearch; | ||
@@ -1938,3 +1919,2 @@ exports.capitalize = capitalize; | ||
exports.clamp = clamp; | ||
exports.descending = descending; | ||
exports.difference = difference; | ||
@@ -1946,3 +1926,2 @@ exports.duplicates = duplicates; | ||
exports.identical = identical; | ||
exports.identicalManual = identicalManual; | ||
exports.intersection = intersection; | ||
@@ -1969,2 +1948,3 @@ exports.isDisjoint = isDisjoint; | ||
exports.reverse = reverse; | ||
exports.same = same; | ||
exports.sample = sample; | ||
@@ -1971,0 +1951,0 @@ exports.shuffle = shuffle; |
@@ -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(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 n(e,n){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return t(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)?t(e,void 0):void 0}}(e))||n&&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)}var r,a;function i(e,t){var n=void 0;if("size"in e?n="size":"length"in e&&(n="length"),!n)throw new RangeError("Expected a to have a size property or a length property");return e[n]<t[n]?[t,e]:[e,t]}(r=e.Rank||(e.Rank={}))[r.Ace=1]="Ace",r[r.Two=2]="Two",r[r.Three=3]="Three",r[r.Four=4]="Four",r[r.Five=5]="Five",r[r.Six=6]="Six",r[r.Seven=7]="Seven",r[r.Eight=8]="Eight",r[r.Nine=9]="Nine",r[r.Ten=10]="Ten",r[r.Jack=11]="Jack",r[r.Queen=12]="Queen",r[r.King=13]="King",(a=e.Suit||(e.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var o,u,s=[{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,r=e[0].map((function(e){return e.length})),a=n(e);!(t=a()).done;)for(var i=t.value,o=0;o<i.length;o++){var u=i[o].length;r[o]<u&&(r[o]=u)}return r}!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"}(o||(o={})),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"}(u||(u={}));var c={__proto__:null,get Status(){return o},get Method(){return u}};function l(e,t){return e+t}function f(e,t,n,r){return r.length-1===n?(e+t)/("bigint"==typeof t?BigInt(r.length):r.length):e+t}function v(e){var t=e.reduce(f);return e.map((function(e){return Math.pow(e-t,2)})).reduce(l)/(e.length-1)}function h(e,t,n){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-n/t,2))}function k(e,t){return Math.random()*(t-e)+e}function S(e,t){return e<t?-1:e>t?1:0}function p(e,t){return e<t?1:e>t?-1:0}var m={__proto__:null,ascending:S,descending:p},g=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=c,e.Sort=m,e.Stopwatch=g,e.ascending=S,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.descending=p,e.difference=function(e,t){for(var r,a=new Set(e),i=n(t);!(r=i()).done;)a.delete(r.value);return a},e.duplicates=function(e){for(var t,r=new Set,a=[],i=n(e);!(t=i()).done;){var o=t.value;r.has(o)&&a.push(o),r.add(o)}return a},e.first=function(e,t){void 0===t&&(t=1);for(var n=[],r=e[Symbol.iterator](),a=0;a<t;a++){var i=r.next();if(i.done)break;n.push(i.value)}return n},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,r=new Map,a=n(e);!(t=a()).done;){var i=t.value,o=r.get(i);r.set(i,o?o+1:1)}return r},e.identical=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var a=t.map((function(e){return e[Symbol.iterator]()})),i=function(){for(var e,t=a.map((function(e){return e.next()})),r=t[0],i=r.done,o=r.value,u=n(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.identicalManual=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 r,a=n(e);!(r=a()).done;)if(!t.has(r.value))return!1}else if(e instanceof Map)for(var i,o=n(e.entries());!(i=o()).done;){var u=i.value,s=u[0],d=u[1];if(t.get(s)!==d||!t.has(s))return!1}return!0},e.intersection=function(e,t){for(var r,a=new Set,o=i(e,t),u=o[1],s=n(o[0]);!(r=s()).done;){var d=r.value;u.has(d)&&a.add(d)}return a},e.isDisjoint=function(e,t){for(var r,a=new Set(e),i=n(t);!(r=i()).done;)if(a.has(r.value))return!1;return!0},e.isSubset=function(e,t){for(var r,a=n(e);!(r=a()).done;)if(!t.has(r.value))return!1;return!0},e.isSuperset=function(e,t){for(var r,a=n(t);!(r=a()).done;)if(!e.has(r.value))return!1;return!0},e.largeToSmall=i,e.max=function(e,t){return Math.max(e,t)},e.maxColumnLength=d,e.mean=f,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,r=new Map,a=0,i=[],o=n(e);!(t=o()).done;){var u=t.value,s=r.get(u),d=void 0===s?1:s+1;r.set(u,d),d>a?(a=d,i=[u]):d===a&&i.push(u)}return i},e.multiReplace=function(e,t){for(var r=Object.entries(t),a="",i=0;i<e.length;)e:do{for(var o,u=n(r);!(o=u()).done;){var s=o.value,d=s[0],c=s[1];if(e.slice(i).startsWith(d)){a+=c,i+=d.length;break e}}a+=e[i++]}while(0);return a},e.newDeck=function(){return[].concat(s)},e.normaldist=h,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 r,a=[],i=[],o=0,u=n(e);!(r=u()).done;){var s=r.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.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,r=[],a=n(e);!(t=a()).done;)r.unshift(t.value);return r},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.fromEntries(Object.entries(e).sort((function(e,n){return t(e[1],n[1])})))},e.standardNormaldist=function(e){return h(e,1,0)},e.stddev=function(e){return Math.sqrt(v(e))},e.sum=l,e.symmetricDifference=function(e,t){for(var r,a=new Set(e),i=n(t);!(r=i()).done;){var o=r.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 r,a=new Set(e),i=n(t);!(r=i()).done;)a.add(r.value);return a},e.variance=v,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(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 n(e,n){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return t(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)?t(e,void 0):void 0}}(e))||n&&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)}var r,a;function i(e,t){var n=void 0;if("size"in e?n="size":"length"in e&&(n="length"),!n)throw new RangeError("Expected a to have a size property or a length property");return e[n]<t[n]?[t,e]:[e,t]}(r=e.Rank||(e.Rank={}))[r.Ace=1]="Ace",r[r.Two=2]="Two",r[r.Three=3]="Three",r[r.Four=4]="Four",r[r.Five=5]="Five",r[r.Six=6]="Six",r[r.Seven=7]="Seven",r[r.Eight=8]="Eight",r[r.Nine=9]="Nine",r[r.Ten=10]="Ten",r[r.Jack=11]="Jack",r[r.Queen=12]="Queen",r[r.King=13]="King",(a=e.Suit||(e.Suit={}))[a.Clubs=0]="Clubs",a[a.Diamonds=1]="Diamonds",a[a.Hearts=2]="Hearts",a[a.Spades=3]="Spades";var o,u,s=[{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,r=e[0].map((function(e){return e.length})),a=n(e);!(t=a()).done;)for(var i=t.value,o=0;o<i.length;o++){var u=i[o].length;r[o]<u&&(r[o]=u)}return r}!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"}(o||(o={})),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"}(u||(u={}));var l={__proto__:null,get Status(){return o},get Method(){return u}};function c(e,t){return e+t}function f(e,t,n,r){return r.length-1===n?(e+t)/("bigint"==typeof t?BigInt(r.length):r.length):e+t}function v(e){var t=e.reduce(f);return e.map((function(e){return Math.pow(e-t,2)})).reduce(c)/(e.length-1)}function h(e,t,n){return 1/(t*Math.sqrt(2*Math.PI))*Math.pow(Math.E,-.5*Math.pow(e-n/t,2))}function k(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,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=l,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=S,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 r,a=new Set(e),i=n(t);!(r=i()).done;)a.delete(r.value);return a},e.duplicates=function(e){for(var t,r=new Set,a=[],i=n(e);!(t=i()).done;){var o=t.value;r.has(o)&&a.push(o),r.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,r=new Map,a=n(e);!(t=a()).done;){var i=t.value,o=r.get(i);r.set(i,o?o+1:1)}return r},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 r,a=n(e);!(r=a()).done;)if(!t.has(r.value))return!1}else if(e instanceof Map)for(var i,o=n(e.entries());!(i=o()).done;){var u=i.value,s=u[0],d=u[1];if(t.get(s)!==d||!t.has(s))return!1}return!0},e.intersection=function(e,t){for(var r,a=new Set,o=i(e,t),u=o[1],s=n(o[0]);!(r=s()).done;){var d=r.value;u.has(d)&&a.add(d)}return a},e.isDisjoint=function(e,t){for(var r,a=new Set(e),i=n(t);!(r=i()).done;)if(a.has(r.value))return!1;return!0},e.isSubset=function(e,t){for(var r,a=n(e);!(r=a()).done;)if(!t.has(r.value))return!1;return!0},e.isSuperset=function(e,t){for(var r,a=n(t);!(r=a()).done;)if(!e.has(r.value))return!1;return!0},e.largeToSmall=i,e.max=function(e,t){return Math.max(e,t)},e.maxColumnLength=d,e.mean=f,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,r=new Map,a=0,i=[],o=n(e);!(t=o()).done;){var u=t.value,s=r.get(u),d=void 0===s?1:s+1;r.set(u,d),d>a?(a=d,i=[u]):d===a&&i.push(u)}return i},e.multiReplace=function(e,t){for(var r=Object.entries(t),a="",i=0;i<e.length;)e:do{for(var o,u=n(r);!(o=u()).done;){var s=o.value,d=s[0],l=s[1];if(e.slice(i).startsWith(d)){a+=l,i+=d.length;break e}}a+=e[i++]}while(0);return a},e.newDeck=function(){return[].concat(s)},e.normaldist=h,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 r,a=[],i=[],o=0,u=n(e);!(r=u()).done;){var s=r.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.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,r=[],a=n(e);!(t=a()).done;)r.unshift(t.value);return r},e.same=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var a=t.map((function(e){return e[Symbol.iterator]()})),i=function(){for(var e,t=a.map((function(e){return e.next()})),r=t[0],i=r.done,o=r.value,u=n(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 h(e,1,0)},e.stddev=function(e){return Math.sqrt(v(e))},e.sum=c,e.symmetricDifference=function(e,t){for(var r,a=new Set(e),i=n(t);!(r=i()).done;){var o=r.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 r,a=new Set(e),i=n(t);!(r=i()).done;)a.add(r.value);return a},e.variance=v,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=util.umd.production.min.js.map |
@@ -72,3 +72,3 @@ { | ||
"typings": "dist/index.d.ts", | ||
"version": "2.16.1" | ||
"version": "3.0.0" | ||
} |
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
551476
6677