{"version":3,"file":"index.mjs","sources":["../src/range.ts","../src/http/status-range.ts","../src/http/method.ts","../src/http/status.ts","../src/http/status-name.ts","../src/cards.ts","../src/array/binary-search.ts","../src/array/fill.ts","../src/array/find-index-all.ts","../src/array/first-index-of-last-group.ts","../src/array/holes.ts","../src/array/index-of-all.ts","../src/array/large-to-small.ts","../src/array/map-fill.ts","../src/array/overwrite.ts","../src/iterable/all-duplicates.ts","../src/iterable/chunk.ts","../src/iterable/concat-iterables.ts","../src/iterable/count.ts","../src/iterable/cycle.ts","../src/iterable/duplicates.ts","../src/iterable/every.ts","../src/iterable/find.ts","../src/iterable/first.ts","../src/iterable/frequency-table.ts","../src/iterable/includes.ts","../src/iterable/is-empty.ts","../src/iterable/iterator-to-iterable.ts","../src/iterable/join.ts","../src/iterable/last-index-of-first-group.ts","../src/iterable/map-repeat.ts","../src/iterable/partition.ts","../src/iterable/repeat.ts","../src/iterable/skip.ts","../src/iterable/some.ts","../src/array/pad-end.ts","../src/array/pad-start.ts","../src/array/pull.ts","../src/array/pull-all.ts","../src/array/replace.ts","../src/array/replace-all.ts","../src/array/sample.ts","../src/array/shuffle.ts","../src/array/trim-end.ts","../src/array/trim-start.ts","../src/auto-percentage.ts","../src/enum/enum-has.ts","../src/format/max-column-length.ts","../src/format/format-table.ts","../src/higher-order/invert.ts","../src/higher-order/not.ts","../src/higher-order/thunkify.ts","../src/identical/identical.ts","../src/identical/same.ts","../src/map/default-map.ts","../src/map/math-map.ts","../src/math/clamp.ts","../src/reducers/product.ts","../src/math/geometric-mean.ts","../src/math/harmonic-mean.ts","../src/reducers/sum.ts","../src/math/mean.ts","../src/math/median.ts","../src/math/mode.ts","../src/math/normaldist.ts","../src/math/random.ts","../src/math/random-int.ts","../src/math/variance.ts","../src/math/stddev.ts","../src/math/relative-stddev.ts","../src/math/standard-normaldist.ts","../src/math/triangular-number.ts","../src/nullish.ts","../src/object/name.ts","../src/set/difference.ts","../src/set/jaccard-index.ts","../src/object/omit.ts","../src/object/pick.ts","../src/object/rename.ts","../src/promise/settled.ts","../src/promise/timeout.ts","../src/reducers/bitwise/and.ts","../src/reducers/bitwise/or.ts","../src/reducers/bitwise/xor.ts","../src/reducers/max.ts","../src/reducers/min.ts","../src/reg-exp.ts","../src/sort/compare/ascending.ts","../src/sort/compare/descending.ts","../src/sort/compare/combine.ts","../src/sort/is-sorted.ts","../src/sort/sort-object.ts","../src/stopwatch.ts","../src/string/capitalize.ts","../src/string/is-anagram.ts","../src/string/is-whitespace.ts","../src/string/lines.ts","../src/string/multi-replace.ts","../src/string/truncate.ts","../src/string/uncapitalize.ts","../src/to-digits.ts"],"sourcesContent":["import type {Comparable} from './types';\n\n/**\n * A range between 2 values.\n *\n * @public\n */\nexport class Range {\n\t/**\n\t * Create a new range from the first 2 values of an iterable.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const range = Range.from([100, 200]);\n\t * ```\n\t *\n\t * @param iterable - The iterable to create a range from\n\t *\n\t * @returns A new range\n\t */\n\tstatic from(iterable: Iterable<Comparable>): Range {\n\t\tconst [lower, upper] = iterable;\n\n\t\treturn new Range(lower, upper);\n\t}\n\n\t/**\n\t * Create a new range from 2 values.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @param lower - The lower bound of this range\n\t * @param upper - The upper bound of this range\n\t *\n\t * @throws If `lower` is greater than `upper`\n\t *\n\t * @example\n\t * ```js\n\t * const range = new Range(100, 200);\n\t * ```\n\t */\n\tconstructor(\n\t\t/**\n\t\t * The lower bound of this range\n\t\t */\n\t\tpublic lower: Comparable,\n\t\t/**\n\t\t * The upper bound of this range\n\t\t */\n\t\tpublic upper: Comparable,\n\t) {\n\t\tif (lower! > upper!) {\n\t\t\tthrow new RangeError('lower must be less than upper');\n\t\t}\n\t}\n\n\t/**\n\t * Returns `true` if `value` is within `this.lower` and `this.upper`, false otherwise.\n\t * The `>=` and `<=` operators are used to compare `value`.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const range = new Range(100, 200);\n\t *\n\t * console.log(range.has(150)); // true\n\t * console.log(range.has(300)); // false\n\t * ```\n\t */\n\thas(value: Comparable): boolean {\n\t\treturn value! >= this.lower! && value! <= this.upper!;\n\t}\n\n\t/**\n\t * An iterable that contains `this.lower` and `this.upper`.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const [lower, upper] = range;\n\t * ```\n\t */\n\t*[Symbol.iterator](): IterableIterator<Comparable> {\n\t\tyield this.lower;\n\t\tyield this.upper;\n\t}\n\n\t/**\n\t * Check whether a given range contains this range.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(0, 100);\n\t * const b = new Range(25, 75);\n\t *\n\t * a.isSuperrange(b); // false\n\t * b.isSuperrange(a); // true\n\t * ```\n\t *\n\t * @param range - Range to compare\n\t *\n\t * @returns Whether this range is contained within the other one\n\t */\n\tisSuperrange(range: Range): boolean {\n\t\treturn range === this || (this.lower! >= range.lower! && this.upper! <= range.upper!);\n\t}\n\n\t/**\n\t * Check whether this range contains the given range\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(0, 100);\n\t * const b = new Range(25, 75);\n\t *\n\t * a.isSubRange(b); // true\n\t * b.isSubRange(a); // false\n\t * ```\n\t *\n\t * @param range - Range to compare\n\t *\n\t * @returns Whether this range contains the given range\n\t */\n\tisSubrange(range: Range): boolean {\n\t\treturn range === this || (this.lower! <= range.lower! && this.upper! >= range.upper!);\n\t}\n\n\t/**\n\t * Check whether a given range has the same lower and upper bounds as this one.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(0, 100);\n\t * const b = new Range(0, 100);\n\t *\n\t * a.equals(a); // true\n\t * a.equals(b); // true\n\t * ```\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(0, 100);\n\t * const b = new Range(150, 150);\n\t *\n\t * a.equals(b); // true\n\t * ```\n\t *\n\t * @param range - Range to compare\n\t *\n\t * @returns Whether the other range has the same lower and upper bounds as this one\n\t */\n\tequals(range: Range): boolean {\n\t\treturn range === this || (this.lower === range.lower && this.upper === range.upper);\n\t}\n\n\t/**\n\t * Check if this range and a given range have any intersection.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(100, 200);\n\t * const b = new Range(150, 250);\n\t *\n\t * a.intersects(b); // true\n\t * ```\n\t *\n\t * @example\n\t * ```js\n\t * const a = new Range(100, 200);\n\t * const b = new Range(300, 400);\n\t *\n\t * a.intersects(b); // false\n\t * ```\n\t *\n\t * @param range - Range to compare\n\t *\n\t * @returns Whether the ranges intersect\n\t */\n\tintersects(range: Range): boolean {\n\t\treturn range === this || (this.lower! <= range.upper! && this.upper! >= range.lower!);\n\t}\n}\n","import {Range} from '../range';\n\n/**\n * A {@link Range} of 1xx HTTP response status codes.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#information_responses | MDN docs}\n *\n * @example\n * ```js\n * if (Http.StatusRange.informational.has(statusCode)) {\n *    // ...\n * }\n * ```\n *\n * @public\n * @category HTTP\n */\nexport const informational: Readonly<Range> = Object.freeze(new Range(100, 200));\n/**\n * A {@link Range} of 2xx HTTP response status codes.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses | MDN docs}\n *\n * @example\n * ```js\n * if (Http.StatusRange.success.has(statusCode)) {\n *   // ...\n * }\n * ```\n *\n * @public\n * @category HTTP\n */\nexport const success: Readonly<Range> = Object.freeze(new Range(200, 300));\n/**\n * A {@link Range} of 3xx HTTP response status codes.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages | MDN docs}\n *\n * @example\n * ```js\n * if (Http.StatusRange.redirects.has(statusCode)) {\n *   // ...\n * }\n * ```\n *\n * @public\n * @category HTTP\n */\nexport const redirects: Readonly<Range> = Object.freeze(new Range(300, 400));\n/**\n * A {@link Range} of 4xx HTTP response status codes.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses | MDN docs}\n *\n * @example\n * ```js\n * if (Http.StatusRange.clientErrors.has(statusCode)) {\n *   // ...\n * }\n * ```\n *\n * @public\n * @category HTTP\n */\nexport const clientErrors: Readonly<Range> = Object.freeze(new Range(400, 500));\n/**\n * A {@link Range} of 5xx HTTP response status codes.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses | MDN docs}\n *\n * @example\n * ```js\n * if (Http.StatusRange.serverErrors.has(statusCode)) {\n *   // ...\n * }\n * ```\n *\n * @public\n * @category HTTP\n */\nexport const serverErrors: Readonly<Range> = Object.freeze(new Range(500, 600));\n","/**\n * Set of HTTP request methods to indicate the desired action to be performed for a given resource.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods | MDN docs}\n *\n * @public\n * @category HTTP\n *\n * @public\n * @category HTTP\n */\nexport enum Method {\n\t/**\n\t * The `GET` method requests a representation of the specified resource.\n\t * Requests using GET should only retrieve data.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET | MDN docs}\n\t */\n\tGet = 'GET',\n\t/**\n\t * The `HEAD` method asks for a response identical to that of a `GET` request, but without the response body.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD | MDN docs}\n\t */\n\tHead = 'HEAD',\n\t/**\n\t * The `POST` method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST | MDN docs}\n\t */\n\tPost = 'POST',\n\t/**\n\t * The `PUT` method replaces all current representations of the target resource with the request payload.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT | MDN docs}\n\t */\n\tPut = 'PUT',\n\t/**\n\t * The `DELETE` method deletes the specified resource.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE | MDN docs}\n\t */\n\tDelete = 'DELETE',\n\t/**\n\t * The `CONNECT` method establishes a tunnel to the server identified by the target resource.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT | MDN docs}\n\t */\n\tConnect = 'CONNECT',\n\t/**\n\t * The `OPTIONS` method is used to describe the communication options for the target resource.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS | MDN docs}\n\t */\n\tOptions = 'OPTIONS',\n\t/**\n\t * The `TRACE` method performs a message loop-back test along the path to the target resource.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE | MDN docs}\n\t */\n\tTrace = 'TRACE',\n\t/**\n\t * The `PATCH` method is used to apply partial modifications to a resource.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATC | MDN docs}\n\t */\n\tPatch = 'PATCH',\n}\n","/**\n * HTTP response status codes indicate whether a specific HTTP request has been successfully completed.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status | MDN docs}\n *\n * @public\n * @category HTTP\n */\nexport enum Status {\n\t/**\n\t * 100 Continue.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100 | MDN docs}\n\t */\n\tContinue = 100,\n\t/**\n\t * 101 Switching Protocols.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101 | MDN docs}\n\t */\n\tSwitchingProtocols,\n\t/**\n\t * 103 Early Hints.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103 | MDN docs}\n\t */\n\tEarlyHints = 103,\n\t/**\n\t * 200 OK.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 | MDN docs}\n\t */\n\tOk = 200,\n\t/**\n\t * 201 Created.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 | MDN docs}\n\t */\n\tCreated,\n\t/**\n\t * 202 Accepted.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 | MDN docs}\n\t */\n\tAccepted,\n\t/**\n\t * 203 Non-Authoritative Information.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203 | MDN docs}\n\t */\n\tNonAuthoritativeInformation,\n\t/**\n\t * 204 No Content.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 | MDN docs}\n\t */\n\tNoContent,\n\t/**\n\t * 205 Reset Content.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205 | MDN docs}\n\t */\n\tResetContent,\n\t/**\n\t * 206 Partial Content.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206 | MDN docs}\n\t */\n\tPartialContent,\n\t/**\n\t * 300 Multiple Choices.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300 | MDN docs}\n\t */\n\tMultipleChoices = 300,\n\t/**\n\t * 301 Moved Permanently.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301 | MDN docs}\n\t */\n\tMovedPermanently,\n\t/**\n\t * 302 Found.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302 | MDN docs}\n\t */\n\tFound,\n\t/**\n\t * 303 See Other.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303 | MDN docs}\n\t */\n\tSeeOther,\n\t/**\n\t * 304 Not Modified.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304 | MDN docs}\n\t */\n\tNotModified,\n\t/**\n\t * 307 Temporary Redirect.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307 | MDN docs}\n\t */\n\tTemporaryRedirect = 307,\n\t/**\n\t * 308 Permanent Redirect.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308 | MDN docs}\n\t */\n\tPermanentRedirect,\n\t/**\n\t * 400 Bad Request.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 | MDN docs}\n\t */\n\tBadRequest = 400,\n\t/**\n\t * 401 Unauthorized.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 | MDN docs}\n\t */\n\tUnauthorized,\n\t/**\n\t * 402 Payment Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402 | MDN docs}\n\t */\n\tPaymentRequired,\n\t/**\n\t * 403 Forbidden.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 | MDN docs}\n\t */\n\tForbidden,\n\t/**\n\t * 404 Not Found.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 | MDN docs}\n\t */\n\tNotFound,\n\t/**\n\t * 405 Method Not Allowed.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 | MDN docs}\n\t */\n\tMethodNotAllowed,\n\t/**\n\t * 406 Not Acceptable.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406 | MDN docs}\n\t */\n\tNotAcceptable,\n\t/**\n\t * 407 Proxy Authentication Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407 | MDN docs}\n\t */\n\tProxyAuthenticationRequired,\n\t/**\n\t * 408 Request Timeout.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408 | MDN docs}\n\t */\n\tRequestTimeout,\n\t/**\n\t * 409 Conflict.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 | MDN docs}\n\t */\n\tConflict,\n\t/**\n\t * 410 Gone.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410 | MDN docs}\n\t */\n\tGone,\n\t/**\n\t * 411 Length Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411 | MDN docs}\n\t */\n\tLengthRequired,\n\t/**\n\t * 412 Precondition Failed.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 | MDN docs}\n\t */\n\tPreconditionFailed,\n\t/**\n\t * 413 Payload Too Large.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413 | MDN docs}\n\t */\n\tPayloadTooLarge,\n\t/**\n\t * 414 URI Too Long.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414 | MDN docs}\n\t */\n\tUriTooLong,\n\t/**\n\t * 415 Unsupported Media Type.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415 | MDN docs}\n\t */\n\tUnsupportedMediaType,\n\t/**\n\t * 416 Range Not Satisfiable.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416 | MDN docs}\n\t */\n\tRangeNotSatisfiable,\n\t/**\n\t * 417 Expectation Failed.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417 | MDN docs}\n\t */\n\tExpectationFailed,\n\t/**\n\t * 418 I'm a teapot.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418 | MDN docs}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tImATeapot,\n\t/**\n\t * 421 Misdirected Request.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/421 | MDN docs}\n\t */\n\tMisdirectedRequest = 421,\n\t/**\n\t * 422 Unprocessable Content.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 | MDN docs}\n\t */\n\tUnprocessableEntity = 422,\n\t/**\n\t * 425 Too Early.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425 | MDN docs}\n\t */\n\tTooEarly = 425,\n\t/**\n\t * 426 Upgrade Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426 | MDN docs}\n\t */\n\tUpgradeRequired,\n\t/**\n\t * 428 Precondition Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428 | MDN docs}\n\t */\n\tPreconditionRequired = 428,\n\t/**\n\t * 429 Too Many Requests.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 | MDN docs}\n\t */\n\tTooManyRequests,\n\t/**\n\t * 431 Request Header Fields Too Large.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431 | MDN docs}\n\t */\n\tRequestHeaderFieldsTooLarge = 431,\n\t/**\n\t * 451 Unavailable For Legal Reasons.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451 | MDN docs}\n\t */\n\tUnavailableForLegalReasons = 451,\n\t/**\n\t * 500 Internal Server Error.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 | MDN docs}\n\t */\n\tInternalServerError = 500,\n\t/**\n\t * 501 Not Implemented.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501 | MDN docs}\n\t */\n\tNotImplemented,\n\t/**\n\t * 502 Bad Gateway.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 | MDN docs}\n\t */\n\tBadGateway,\n\t/**\n\t * 503 Service Unavailable.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503 | MDN docs}\n\t */\n\tServiceUnavailable,\n\t/**\n\t * 504 Gateway Timeout.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 | MDN docs}\n\t */\n\tGatewayTimeout,\n\t/**\n\t * 505 HTTP Version Not Supported.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505 | MDN docs}\n\t */\n\tHttpVersionNotSupported,\n\t/**\n\t * 506 Variant Also Negotiates.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506 | MDN docs}\n\t */\n\tVariantAlsoNegotiates,\n\t/**\n\t * 507 Insufficient Storage.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507 | MDN docs}\n\t */\n\tInsufficientStorage,\n\t/**\n\t * 508 Loop Detected.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508 | MDN docs}\n\t * @deprecated This is a status code only used in the WebDAV protocol, which is not supported by the `Status` enum.\n\t */\n\tLoopDetected,\n\t/**\n\t * 510 Not Extended.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510 | MDN docs}\n\t */\n\tNotExtended = 510,\n\t/**\n\t * 511 Network Authentication Required.\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/51 | MDN docs}\n\t */\n\tNetworkAuthenticationRequired,\n}\n","/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/prefer-literal-enum-member */\nimport {Status} from './status';\n\n/**\n * An enum mapping HTTP status codes to their names.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Status | MDN docs}\n *\n * @public\n * @category HTTP\n */\nexport enum StatusName {\n\t'Continue' = Status.Continue,\n\t'Switching Protocols' = Status.SwitchingProtocols,\n\t'Early Hints' = Status.EarlyHints,\n\t'OK' = Status.Ok,\n\t'Created' = Status.Created,\n\t'Accepted' = Status.Accepted,\n\t'Non-Authoritative Information' = Status.NonAuthoritativeInformation,\n\t'No Content' = Status.NoContent,\n\t'Reset Content' = Status.ResetContent,\n\t'Partial Content' = Status.PartialContent,\n\t'Multiple Choices' = Status.MultipleChoices,\n\t'Moved Permanently' = Status.MovedPermanently,\n\t'Found' = Status.Found,\n\t'See Other' = Status.SeeOther,\n\t'Not Modified' = Status.NotModified,\n\t'Temporary Redirect' = Status.TemporaryRedirect,\n\t'Permanent Redirect' = Status.PermanentRedirect,\n\t'Bad Request' = Status.BadRequest,\n\t'Unauthorized' = Status.Unauthorized,\n\t'Payment Required' = Status.PaymentRequired,\n\t'Forbidden' = Status.Forbidden,\n\t'Not Found' = Status.NotFound,\n\t'Method Not Allowed' = Status.MethodNotAllowed,\n\t'Not Acceptable' = Status.NotAcceptable,\n\t'Proxy Authentication Required' = Status.ProxyAuthenticationRequired,\n\t'Request Timeout' = Status.RequestTimeout,\n\t'Conflict' = Status.Conflict,\n\t'Gone' = Status.Gone,\n\t'Length Required' = Status.LengthRequired,\n\t'Precondition Failed' = Status.PreconditionFailed,\n\t'Payload Too Large' = Status.PayloadTooLarge,\n\t'URI Too Long' = Status.UriTooLong,\n\t'Unsupported Media Type' = Status.UnsupportedMediaType,\n\t'Range Not Satisfiable' = Status.RangeNotSatisfiable,\n\t'Expectation Failed' = Status.ExpectationFailed,\n\t\"I'm a Teapot\" = Status.ImATeapot,\n\t'Misdirected Request' = Status.MisdirectedRequest,\n\t'Unprocessable Content' = Status.UnprocessableEntity,\n\t'Too Early' = Status.TooEarly,\n\t'Upgrade Required' = Status.UpgradeRequired,\n\t'Precondition Required' = Status.PreconditionRequired,\n\t'Too Many Requests' = Status.TooManyRequests,\n\t'Request Header Fields Too Large' = Status.RequestHeaderFieldsTooLarge,\n\t'Unavailable For Legal Reasons' = Status.UnavailableForLegalReasons,\n\t'Internal Server Error' = Status.InternalServerError,\n\t'Not Implemented' = Status.NotImplemented,\n\t'Bad Gateway' = Status.BadGateway,\n\t'Service Unavailable' = Status.ServiceUnavailable,\n\t'Gateway Timeout' = Status.GatewayTimeout,\n\t'HTTP Version Not Supported' = Status.HttpVersionNotSupported,\n\t'Variant Also Negotiates' = Status.VariantAlsoNegotiates,\n\t'Insufficient Storage' = Status.InsufficientStorage,\n\t/**\n\t * @deprecated This is a status code only used in the WebDAV protocol, which is not supported by the `Status` enum.\n\t */\n\t'Loop Detected' = Status.LoopDetected,\n\t'Not Extended' = Status.NotExtended,\n\t'Network Authentication Required' = Status.NetworkAuthenticationRequired,\n}\n","/**\n * The rank of a card going from ace to king, where aces are `1`.\n *\n * @public\n * @category Cards\n */\nexport enum Rank {\n\tAce = 1,\n\tTwo,\n\tThree,\n\tFour,\n\tFive,\n\tSix,\n\tSeven,\n\tEight,\n\tNine,\n\tTen,\n\tJack,\n\tQueen,\n\tKing,\n}\n\n/**\n * A suit of cards, sorted in alphabetical order.\n *\n * @public\n * @category Cards\n */\nexport enum Suit {\n\tClubs,\n\tDiamonds,\n\tHearts,\n\tSpades,\n}\n\n/**\n * A playing card.\n *\n * @public\n * @category Cards\n */\nexport type Card = {\n\trank: Rank;\n\tsuit: Suit;\n};\n\n/**\n * Get a sorted deck of cards.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * import { shuffle } from '@jonahsnider/util';\n *\n * const deck = newDeck();\n * ```\n *\n * @returns A sorted deck of cards\n *\n * @public\n * @category Cards\n */\nexport function newDeck(): Card[] {\n\treturn [\n\t\t{rank: Rank.Ace, suit: Suit.Clubs},\n\t\t{rank: Rank.Two, suit: Suit.Clubs},\n\t\t{rank: Rank.Three, suit: Suit.Clubs},\n\t\t{rank: Rank.Four, suit: Suit.Clubs},\n\t\t{rank: Rank.Five, suit: Suit.Clubs},\n\t\t{rank: Rank.Six, suit: Suit.Clubs},\n\t\t{rank: Rank.Seven, suit: Suit.Clubs},\n\t\t{rank: Rank.Eight, suit: Suit.Clubs},\n\t\t{rank: Rank.Nine, suit: Suit.Clubs},\n\t\t{rank: Rank.Ten, suit: Suit.Clubs},\n\t\t{rank: Rank.Jack, suit: Suit.Clubs},\n\t\t{rank: Rank.Queen, suit: Suit.Clubs},\n\t\t{rank: Rank.King, suit: Suit.Clubs},\n\t\t{rank: Rank.Ace, suit: Suit.Diamonds},\n\t\t{rank: Rank.Two, suit: Suit.Diamonds},\n\t\t{rank: Rank.Three, suit: Suit.Diamonds},\n\t\t{rank: Rank.Four, suit: Suit.Diamonds},\n\t\t{rank: Rank.Five, suit: Suit.Diamonds},\n\t\t{rank: Rank.Six, suit: Suit.Diamonds},\n\t\t{rank: Rank.Seven, suit: Suit.Diamonds},\n\t\t{rank: Rank.Eight, suit: Suit.Diamonds},\n\t\t{rank: Rank.Nine, suit: Suit.Diamonds},\n\t\t{rank: Rank.Ten, suit: Suit.Diamonds},\n\t\t{rank: Rank.Jack, suit: Suit.Diamonds},\n\t\t{rank: Rank.Queen, suit: Suit.Diamonds},\n\t\t{rank: Rank.King, suit: Suit.Diamonds},\n\t\t{rank: Rank.Ace, suit: Suit.Hearts},\n\t\t{rank: Rank.Two, suit: Suit.Hearts},\n\t\t{rank: Rank.Three, suit: Suit.Hearts},\n\t\t{rank: Rank.Four, suit: Suit.Hearts},\n\t\t{rank: Rank.Five, suit: Suit.Hearts},\n\t\t{rank: Rank.Six, suit: Suit.Hearts},\n\t\t{rank: Rank.Seven, suit: Suit.Hearts},\n\t\t{rank: Rank.Eight, suit: Suit.Hearts},\n\t\t{rank: Rank.Nine, suit: Suit.Hearts},\n\t\t{rank: Rank.Ten, suit: Suit.Hearts},\n\t\t{rank: Rank.Jack, suit: Suit.Hearts},\n\t\t{rank: Rank.Queen, suit: Suit.Hearts},\n\t\t{rank: Rank.King, suit: Suit.Hearts},\n\t\t{rank: Rank.Ace, suit: Suit.Spades},\n\t\t{rank: Rank.Two, suit: Suit.Spades},\n\t\t{rank: Rank.Three, suit: Suit.Spades},\n\t\t{rank: Rank.Four, suit: Suit.Spades},\n\t\t{rank: Rank.Five, suit: Suit.Spades},\n\t\t{rank: Rank.Six, suit: Suit.Spades},\n\t\t{rank: Rank.Seven, suit: Suit.Spades},\n\t\t{rank: Rank.Eight, suit: Suit.Spades},\n\t\t{rank: Rank.Nine, suit: Suit.Spades},\n\t\t{rank: Rank.Ten, suit: Suit.Spades},\n\t\t{rank: Rank.Jack, suit: Suit.Spades},\n\t\t{rank: Rank.Queen, suit: Suit.Spades},\n\t\t{rank: Rank.King, suit: Suit.Spades},\n\t];\n}\n","import type {DirectionFn} from '../types';\n\n/**\n * Perform a binary search to find an element in a sorted array.\n *\n * Time complexity: _O(log n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n *\n * function directionFn(value: number) {\n * \tconst squared = value ** 2;\n *\n * \tif (squared === 64) {\n * \t\treturn 0;\n * \t}\n *\n * \treturn squared - 64;\n * }\n *\n * binarySearch(array, directionFn);\n * ```\n *\n * @param array - Sorted array to perform binary search on\n * @param directionFn - The function used to determine what direction to continue searching\n *\n * @returns The value of the first element in the array that satisfies the provided testing function. Otherwise, `undefined` is returned.\n *\n * @public\n * @category Array\n */\nexport function binarySearch<T>(array: ArrayLike<T>, directionFn: DirectionFn<T>): ReturnType<T[]['find']> {\n\tlet left = 0;\n\tlet right = array.length - 1;\n\n\twhile (left <= right) {\n\t\tconst index = Math.trunc((left + right) / 2);\n\t\tconst direction = directionFn(array[index]);\n\n\t\tif (direction < 0) {\n\t\t\t// Desired element appears before the current one\n\t\t\tleft = index + 1;\n\t\t} else if (direction > 0) {\n\t\t\t// Desired element appears after the current one\n\t\t\tright = index - 1;\n\t\t} else {\n\t\t\t// All other cases have been exhausted\n\t\t\treturn array[index];\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","/**\n * Create a new array of a specified length and fill it with a given value.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * fill('a', 3); // ['a', 'a', 'a']\n * ```\n *\n * @param value - Value to fill the array with\n * @param length - The length of the array\n *\n * @returns The filled array\n *\n * @see {@link mapFill} to do the same thing but with a function that generates values\n * @see {@link repeat} to do the same thing but return an iterable\n *\n * @public\n * @category Array\n */\n// TODO: Swap order of parameters & update documentation example\nexport function fill<T>(value: T, length: number): T[] {\n\treturn Array.from({length}, () => value);\n}\n","/**\n * Get an array of all indexes of elements in an array that passed a given predicate.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * findIndexAll([1, 2, 1, 3, 1], (element) => element === 1); // [0, 2, 4]\n * ```\n *\n * @param array - The array to search in\n * @param predicate - The function to call for each element to decide whether it should be included in the result\n *\n * @returns An array of indexes of elements that passed `predicate` in `array`\n *\n * @see {@link indexOfAll} if you want to find all elements equal to a given value\n *\n * @public\n * @category Array\n */\nexport function findIndexAll<T>(array: ArrayLike<T>, predicate: (element: T, index: number) => boolean): number[] {\n\tconst indexes: number[] = [];\n\n\t// eslint-disable-next-line unicorn/no-for-loop\n\tfor (let index = 0; index < array.length; index++) {\n\t\tconst element = array[index];\n\n\t\tif (predicate(element, index)) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\n\treturn indexes;\n}\n","/**\n * Returns the first index of the last continuous group of a given value.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = ['a', 'a', 'b', 'b', 'c', 'c'];\n *\n * firstIndexOfLastGroup(array, 'c'); // 4\n * ```\n *\n * @param array - The array to search\n * @param value - The value to search for\n *\n * @returns The first index of the last group of a given value\n *\n * @see {@link lastIndexOfFirstGroup} to do the same thing but find the last index of the first group\n *\n * @public\n * @category Array\n */\nexport function firstIndexOfLastGroup<T>(array: ArrayLike<T>, value: T): number {\n\tlet firstIndex = -1;\n\n\tfor (let index = array.length - 1; index >= 0; index--) {\n\t\tconst element = array[index];\n\t\tif (element !== value) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfirstIndex = index;\n\t}\n\n\treturn firstIndex;\n}\n","/**\n * Get an array of indexes of holes in an array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * holes([0, , 2]); // [1]\n * ```\n *\n * @param array - The array to find holes in\n *\n * @returns An array of indexes of holes in the array\n *\n * @public\n * @category Array\n */\nexport function holes(array: ArrayLike<unknown>): number[] {\n\tconst result: number[] = [];\n\n\tfor (let index = 0; index < array.length; index++) {\n\t\tif (!(index in array)) {\n\t\t\tresult.push(index);\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Get an array of indexes of `searchElement` in an array.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * indexOfAll([1, 2, 1, 3, 1], 1); // [0, 2, 4]\n * ```\n *\n * @param array - The array to search in\n * @param searchElement - The element to search for\n *\n * @returns An array of indexes of `searchElement` in `array`\n *\n * @see {@link findIndexAll} if you want to use a predicate instead of strict equality\n *\n * @public\n * @category Array\n */\nexport function indexOfAll<T>(array: ArrayLike<T>, searchElement: T): number[] {\n\tconst indexes: number[] = [];\n\n\t// eslint-disable-next-line unicorn/no-for-loop\n\tfor (let index = 0; index < array.length; index++) {\n\t\tconst element = array[index];\n\n\t\tif (element === searchElement) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\n\treturn indexes;\n}\n","/**\n * An object with a `length` property.\n * @internal\n * @category Array\n */\ntype ObjectWithLength = {length: number};\nexport type {ObjectWithLength as _ObjectWithLength};\n\n/**\n * An object with a `size` property.\n * @internal\n * @category Array\n */\ntype ObjectWithSize = {size: number};\nexport type {ObjectWithSize as _ObjectWithSize};\n\n/**\n * A tuple of two elements arranged so the largest element is first and the smallest is last.\n *\n * @internal\n * @category Array\n */\ntype ArrangedLargestToSmallest<A, B> = [largest: A, smallest: B] | [largest: B, smallest: A];\nexport type {ArrangedLargestToSmallest as _ArrangedLargestToSmallest};\n\n/**\n * Arrange 2 objects in a tuple by their length.\n * Useful for situations where you are iterating `a` or `b` depending on which is larger.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const a = [1, 2];\n * const b = [1, 2, 3];\n *\n * const [largest, smallest] = largeToSmall(a, b);\n *\n * console.log(largest); // [1, 2, 3]\n * console.log(smallest); // [1, 2]\n * ```\n *\n * @param a - First object\n * @param b - Second object\n *\n * @throws If `a` does not have a `length` or `size` property\n *\n * @public\n * @category Array\n */\nexport function largeToSmall<A extends ObjectWithLength, B extends ObjectWithLength>(a: A, b: B): ArrangedLargestToSmallest<A, B>;\n/**\n * Arrange 2 objects in a tuple by their size.\n * Useful for situations where you are iterating `a` or `b` depending on which is larger.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const a = new Set([1, 2]);\n * const b = new Set([1, 2, 3]);\n *\n * const [largest, smallest] = largeToSmall(a, b);\n *\n * console.log(largest); // Set(3) { 1, 2, 3 }\n * console.log(smallest); // Set(2) { 1, 2 }\n * ```\n *\n * @param a - First object\n * @param b - Second object\n *\n * @throws If `a` does not have a `length` or `size` property\n *\n * @public\n * @category Array\n */\nexport function largeToSmall<A extends ObjectWithSize, B extends ObjectWithSize>(a: A, b: B): ArrangedLargestToSmallest<A, B>;\nexport function largeToSmall<A extends ObjectWithSize | ObjectWithLength, B extends ObjectWithSize | ObjectWithLength>(\n\ta: A,\n\tb: B,\n): ArrangedLargestToSmallest<A, B> {\n\tlet key: 'size' | 'length' | undefined;\n\n\tif ('size' in a) {\n\t\tkey = 'size';\n\t} else if ('length' in a) {\n\t\tkey = 'length';\n\t}\n\n\tif (!key) {\n\t\tthrow new RangeError('Expected a to have a size property or a length property');\n\t}\n\n\t// @ts-expect-error We have validated the keys at this point\n\tif (a[key] < b[key]) {\n\t\treturn [b, a];\n\t}\n\n\treturn [a, b];\n}\n","/**\n * Create a new array of a specified length and fill it using the given function.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * mapFill(i => i + 1, 3); // [1, 2, 3]\n * ```\n *\n * @param valueFn - A function that returns each value to fill the array with\n * @param length - The length of the array\n *\n * @returns The filled array\n *\n * @see {@link mapRepeat} to do the same thing but return an iterable\n * @see {@link fill} to do the same thing but with a given value\n *\n * @public\n * @category Array\n */\n// TODO: Swap the order of valueFn and length\nexport function mapFill<T>(valueFn: (index: number) => T, length: number): T[] {\n\treturn Array.from({length}, (_, i) => valueFn(i));\n}\n","/**\n * Overwrite elements in an array at a given index.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3, 4, 5];\n *\n * overwrite(array, 1, [8, 9]); // [2, 3]\n *\n * console.log(array); // [1, 8, 9, 4, 5]\n * ```\n *\n * @param array - The array to overwrite elements in\n * @param startIndex - The index to start overwriting elements from\n * @param elements - The elements used to overwrite elements at `startIndex` in `array`\n *\n * @returns The return value of `Array.prototype.splice`\n *\n * @public\n * @category Array\n */\nexport function overwrite<T>(array: T[], startIndex: number, data: ArrayLike<T> & Iterable<T>): ReturnType<(typeof array)['splice']> {\n\treturn array.splice(startIndex, startIndex + data.length - 1, ...data);\n}\n","/**\n * Get an array of all the duplicate elements in an iterable.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * allDuplicates([1, 2, 2, 2, 3]); // [2, 2]\n * ```\n *\n * @example\n * Using {@link frequencyTable} to get the number of times each element was duplicated\n * ```js\n * frequencyTable(allDuplicates([1, 2, 2, 2, 3, 3])); // Map(2) { 2 => 2, 3 => 1 }\n * ```\n *\n * @see {@link duplicates} to receive a `Set` of duplicate elements instead of an array (which can include the same element more than once)\n *\n * @param iterable - The iterable to find duplicates in\n * @returns An array of the duplicated elements\n *\n * @public\n * @category Iterable\n */\nexport function allDuplicates<T>(iterable: Iterable<T>): T[] {\n\tconst seen = new Set<T>();\n\tconst result: T[] = [];\n\n\tfor (const element of iterable) {\n\t\tif (seen.has(element)) {\n\t\t\tresult.push(element);\n\t\t} else {\n\t\t\tseen.add(element);\n\t\t}\n\t}\n\n\treturn result;\n}\n","import type {Table} from '../array';\nimport {mapFill} from '../array/map-fill';\n\nfunction chunkArray<T>(array: readonly T[], size: number): Table<T> {\n\treturn mapFill(i => array.slice(i * size, i * size + size), Math.ceil(array.length / size));\n}\n\nfunction* chunkIterable<T>(iterable: Iterable<T>, size: number): IterableIterator<T[]> {\n\tlet chunk: T[] = [];\n\n\tfor (const element of iterable) {\n\t\tchunk.push(element);\n\n\t\tif (chunk.length === size) {\n\t\t\tyield chunk;\n\t\t\tchunk = [];\n\t\t}\n\t}\n\n\tif (chunk.length > 0) {\n\t\tyield chunk;\n\t}\n}\n\n/**\n * Divides an array into several chunks of `size`.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * chunk([1, 2, 3, 4, 5, 6], 2); // [[1, 2], [3, 4], [5, 6]]\n * ```\n *\n * @example\n * ```js\n * chunk([1, 2, 3, 4, 5, 6], 5); // [[1, 2, 3, 4, 5], [6]]\n * ```\n *\n * @example\n * ```js\n * chunk([1, 2, 3, 4, 5, 6], 6); // [[1], [2], [3], [4], [5], [6]]\n * ```\n *\n * @example\n * ```js\n * chunk([1, 2, 3, 4, 5, 6], 100); // [[1, 2, 3, 4, 5, 6]]\n * ```\n *\n * @param array - The array to chunk\n * @param size - The size of each chunk\n *\n * @returns The new array containing chunks of the original `array`\n *\n * @public\n * @category Array\n */\nexport function chunk<T>(array: readonly T[], size: number): Table<T>;\n/**\n * Divides an iterable into several chunks of `size`.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...chunk(new Set([1, 2, 3, 4, 5, 6]), 2)]; // [[1, 2], [3, 4], [5, 6]]\n * ```\n *\n * @example\n * ```js\n * [...chunk(new Set([1, 2, 3, 4, 5, 6]), 5)]; // [[1, 2, 3, 4, 5], [6]]\n * ```\n *\n * @example\n * ```js\n * [...chunk(new Set([1, 2, 3, 4, 5, 6]), 6)]; // [[1], [2], [3], [4], [5], [6]]\n * ```\n *\n * @example\n * ```js\n * [...chunk(new Set([1, 2, 3, 4, 5, 6]), 100)]; // [[1, 2, 3, 4, 5, 6]]\n * ```\n *\n * @param iterable - The iterable to chunk\n * @param size - The size of each chunk\n *\n * @returns An iterator yieliding new arrays containing chunks of the original `iterable`\n *\n * @public\n * @category Iterable\n */\nexport function chunk<T>(iterable: Iterable<T>, size: number): IterableIterator<T[]>;\nexport function chunk<T>(arrayOrIterable: readonly T[] | Iterable<T>, size: number): Table<T> | IterableIterator<T[]> {\n\tif (Array.isArray(arrayOrIterable)) {\n\t\treturn chunkArray<T>(arrayOrIterable, size);\n\t}\n\n\treturn chunkIterable<T>(arrayOrIterable, size);\n}\n","/**\n * Combines multiple iterables into a single iterable.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...concatIterables([1, 2, 3], [4, 5, 6])]; // [1, 2, 3, 4, 5, 6]\n * ```\n *\n * @param iterables - The iterables to combine\n *\n * @returns A single iterable containing all the elements of all the iterables\n *\n * @public\n * @category Iterable\n */\nexport function* concatIterables<T>(...iterables: ReadonlyArray<Iterable<T>>): Iterable<T> {\n\tfor (const iterable of iterables) {\n\t\tyield* iterable;\n\t}\n}\n","/**\n * Count the number of elements in an iterable\n * You may optionally provide a predicate function to filter which elements are counted.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * count([1, 2, 3]); // 3\n * ```\n *\n * @example\n * ```js\n * count([1, 2, 3], number => number % 2 === 1); // 2\n * ```\n *\n * @param iterable - The iterable to count the elements of\n *\n * @returns The number of elements in `iterable`. If `predicate` was provided, the number of elements in `iterable` that satisfy `predicate`.\n *\n * @see {@link frequencyTable} to count the occurrences of all elements in an iterable\n *\n * @public\n * @category Iterable\n */\nexport function count<T>(iterable: Iterable<T>, filterPredicate?: undefined | ((element: T) => boolean)): number {\n\tlet count = 0;\n\n\tif (filterPredicate) {\n\t\tfor (const element of iterable) {\n\t\t\tif (filterPredicate(element)) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (const _ of iterable) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\treturn count;\n}\n","/**\n * Returns an array with the elements of the iterable repeated a provided number of times.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...cycle(['a', 'b'], 2)]; // ['a', 'b', 'a', 'b']\n * ```\n *\n * @param iterable - The iterable to cycle\n * @param times - The number of times to repeat the elements of `iterable`\n *\n * @returns An array with the elements of `iterable` repeated `times` number of times\n *\n * @public\n * @category Iterable\n */\nexport function* cycle<T>(iterable: Iterable<T>, times: number): Iterable<T> {\n\tfor (let index = 0; index < times; index++) {\n\t\tyield* iterable;\n\t}\n}\n","/**\n * Get a `Set` of the duplicate elements in an iterable.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * duplicates([1, 2, 2, 2, 3]); // Set(1) { 2 }\n * ```\n *\n * @see {@link allDuplicates} to receive a array of duplicate elements instead of a `Set` (which doesn't include the same element more than once)\n *\n * @param iterable - The iterable to find duplicates in\n * @returns A `Set` of the duplicated elements\n *\n * @public\n * @category Iterable\n */\nexport function duplicates<T>(iterable: Iterable<T>): Set<T> {\n\tconst seen = new Set<T>();\n\tconst result = new Set<T>();\n\n\tfor (const element of iterable) {\n\t\tif (seen.has(element)) {\n\t\t\tresult.add(element);\n\t\t} else {\n\t\t\tseen.add(element);\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Determines whether all the elements of an iterable pass a given predicate.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * every([false], x => x); // false\n * ```\n * @example\n * ```js\n * every([false, true], x => x); // false\n * ```\n * @example\n * ```js\n * every([true], x => x); // true\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param predicate - The function to call on each element in the iterable to determine if it passes the test\n *\n * @returns `true` if every element passed the predicate, `false` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function every<T, S extends T>(iterable: Iterable<T>, predicate: (element: T) => element is S): iterable is Iterable<S>;\n/**\n * Determines whether all the elements of an iterable pass a given predicate.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * every([false], x => x); // false\n * ```\n * @example\n * ```js\n * every([false, true], x => x); // false\n * ```\n * @example\n * ```js\n * every([true], x => x); // true\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param predicate - The function to call on each element in the iterable to determine if it passes the test\n *\n * @returns `true` if every element passed the predicate, `false` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function every<T>(iterable: Iterable<T>, predicate: (element: T) => unknown): boolean;\nexport function every<T>(iterable: Iterable<T>, predicate: (element: T) => unknown): boolean {\n\tfor (const element of iterable) {\n\t\tif (!predicate(element)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","/**\n * Returns the value of the first element in the iterable where `predicate` is truthy, and `undefined` otherwise.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * find([1, 2, 3], x => x === 2); // 2\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param predicate - The function to call on each element in the iterable to determine if it passes the test\n *\n * @returns The value of the first element in the iterable where `predicate` is truthy, and `undefined` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function find<T>(iterable: Iterable<T>, predicate: (element: T) => boolean): T | undefined {\n\tfor (const element of iterable) {\n\t\tif (predicate(element)) {\n\t\t\treturn element;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","function* firstIterable<T>(iterable: Iterable<T>, take: number): Iterable<T> {\n\tfor (const element of iterable) {\n\t\tif (take--) {\n\t\t\tyield element;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Get the first element from an iterable.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * first([1, 2, 3]); // 1\n * ```\n *\n * @param iterable - The iterable to take elements from\n *\n * @returns The first element of the iterable\n *\n * @public\n * @category Iterable\n */\nexport function first<T>(iterable: Iterable<T>, take?: undefined): T | undefined;\n/**\n * Get the first `n` elements from an iterable.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...first([1, 2, 3], 1)]; // [1]\n * ```\n *\n * @example\n * ```js\n * [...first([1, 2, 3], 2)]; // [1, 2]\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param take - The number of elements to take from the iterable\n *\n * @returns The first `take` elements of the iterable\n *\n * @public\n * @category Iterable\n */\nexport function first<T>(iterable: Iterable<T>, take: number): Iterable<T>;\nexport function first<T>(iterable: Iterable<T>, take?: number): (T | undefined) | Iterable<T> {\n\tif (take === undefined) {\n\t\t// eslint-disable-next-line no-unreachable-loop\n\t\tfor (const element of iterable) {\n\t\t\treturn element;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\treturn firstIterable(iterable, take);\n}\n","/**\n * Construct a frequency table from an iterable.\n * Similar to [Python's `Counter` class](https://docs.python.org/3/library/collections.html#collections.Counter).\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * frequencyTable([1, 2, 2, 3, 3, 3]) // Map(3) { 1 => 1, 2 => 2, 3 => 3 };\n * ```\n *\n * @param iterable - The iterable to construct a frequency table for\n *\n * @returns A frequency table represented as a `Map` where keys are the elements and values are the frequency\n *\n * @see {@link count} to count the occurrences of one value in an iterable\n *\n * @public\n * @category Iterable\n */\nexport function frequencyTable<T>(iterable: Iterable<T>): Map<T, number> {\n\tconst frequencies = new Map<T, number>();\n\n\tfor (const element of iterable) {\n\t\t// This is a perfect candidate for a DefaultMap but that means the return value wouldn't be a pure Map\n\t\tconst newOccurrences = (frequencies.get(element) ?? 0) + 1;\n\n\t\tfrequencies.set(element, newOccurrences);\n\t}\n\n\treturn frequencies;\n}\n","/**\n * Determines whether an iterable includes a certain element, returning true or false as appropriate.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * includes([1, 2, 3], 2); // true\n * ```\n *\n * @example\n * ```js\n * includes([1, 2, 3], 4); // false\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param searchElement - The element to search for\n *\n * @returns `true` if any element is truthy, `false` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function includes<T>(iterable: Iterable<T>, searchElement: T): boolean {\n\tfor (const element of iterable) {\n\t\tif (element === searchElement) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n","/**\n * Check if a readonly `Map` is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty(new Map([1, 2, 3])); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty(new Map()); // true\n * ```\n *\n * @param map - The `Map` to check\n *\n * @returns `true` if `map` is empty, `false` otherwise\n *\n * @public\n * @category Map\n */\nexport function isEmpty(map: ReadonlyMap<unknown, unknown>): map is ReadonlyMap<never, never>;\n/**\n * Check if a `Map` is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty(new Map([['a', 1], ['b', 2], ['c', 3]])); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty(new Map()); // true\n * ```\n *\n * @param map - The `Map` to check\n *\n * @returns `true` if `map` is empty, `false` otherwise\n *\n * @public\n * @category Map\n */\nexport function isEmpty(map: Map<unknown, unknown>): map is Map<never, never>;\n/**\n * Check if a readonly `Set` is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty(new Set([1, 2, 3])); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty(new Set()); // true\n * ```\n *\n * @param set - The `Set` to check\n *\n * @returns `true` if `set` is empty, `false` otherwise\n *\n * @public\n * @category Set\n */\nexport function isEmpty(set: ReadonlySet<unknown>): set is ReadonlySet<never>;\n/**\n * Check if a `Set` is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty(new Set([1, 2, 3])); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty(new Set()); // true\n * ```\n *\n * @param set - The `Set` to check\n *\n * @returns `true` if `set` is empty, `false` otherwise\n *\n * @public\n * @category Set\n */\nexport function isEmpty(set: Set<unknown>): set is Set<never>;\n/**\n * Check if a string is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty('hello'); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty(''); // true\n * ```\n *\n * @param string - The string to check\n *\n * @returns `true` if `string` is empty, `false` otherwise\n *\n * @public\n * @category String\n */\nexport function isEmpty(string: string): string is '';\n/**\n * Check if a readonly array is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty([1, 2, 3]); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty([]); // true\n * ```\n *\n * @param array - The array to check\n *\n * @returns `true` if `array` is empty, `false` otherwise\n *\n * @public\n * @category Array\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isEmpty(array: readonly unknown[]): array is readonly [];\n/**\n * Check if an array is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty([1, 2, 3]); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty([]); // true\n * ```\n *\n * @param array - The array to check\n *\n * @returns `true` if `array` is empty, `false` otherwise\n *\n * @public\n * @category Array\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isEmpty(array: unknown[]): array is [];\n/**\n * Check if an iterable is empty.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isEmpty([1, 2, 3]); // false\n * ```\n *\n * @example\n * ```js\n * isEmpty([]); // true\n * ```\n *\n * @param iterable - The iterable to check\n *\n * @returns `true` if `iterable` is empty, `false` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function isEmpty(iterable: Iterable<unknown>): iterable is Iterable<never>;\nexport function isEmpty(iterable: Iterable<unknown>): iterable is Iterable<never> {\n\t// eslint-disable-next-line no-unreachable-loop\n\tfor (const _ of iterable) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","/**\n * Returns an iterable that uses a provided iterator.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const iterable = [1, 2, 3];\n * const iterator = iterable[Symbol.iterator]();\n *\n * iteratorToIterable(iterator); // { [Symbol.iterator]: () => iterator }\n * ```\n *\n * @param iterator - The iterator to convert to an iterable\n *\n * @returns An iterable that uses `iterator`\n *\n * @public\n * @category Iterable\n */\nexport function iteratorToIterable<T>(iterator: Iterator<T>): Iterable<T> {\n\treturn {\n\t\t[Symbol.iterator]: () => iterator,\n\t};\n}\n","/**\n * Adds all the elements of an iterable into a string, separated by the specified separator string.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * join(['a', 'b', 'c']); // 'a,b,c'\n * ```\n *\n * @example\n * ```js\n * join(['a', 'b', 'c'], '-'); // 'a-b-c'\n * ```\n *\n * @param iterable - The iterable to join\n * @param separator - A string used to separate one element of the iterable from the next in the resulting string\n *\n * @returns A string containing the elements in iterable joined by separator\n *\n * @public\n * @category Iterable\n */\nexport function join(iterable: Iterable<unknown>, separator = ','): string {\n\tlet result = '';\n\n\tconst iterator = iterable[Symbol.iterator]();\n\n\tlet next = iterator.next();\n\n\tfor (;;) {\n\t\tconst previous = next;\n\t\tnext = iterator.next();\n\n\t\t// eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n\t\tresult += previous.value;\n\n\t\tif (next.done) {\n\t\t\treturn result;\n\t\t}\n\n\t\tresult += separator;\n\t}\n}\n","/**\n * Returns the last index of the first continuous group of a given value.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const iterable = ['a', 'a', 'b', 'b', 'c', 'c'];\n *\n * lastIndexOfFirstGroup(iterable, 'a'); // 1\n * ```\n *\n * @param iterable - The iterable to search\n * @param value - The value to search for\n *\n * @returns The last index of the first group of a given value\n *\n *  @see {@link firstIndexOfLastGroup} to do the same thing but find the first index of the last group\n *\n * @public\n * @category Iterable\n */\nexport function lastIndexOfFirstGroup<T>(iterable: Iterable<T>, value: T): number {\n\tlet index = -1;\n\n\tfor (const element of iterable) {\n\t\tif (element !== value) {\n\t\t\tbreak;\n\t\t}\n\n\t\tindex++;\n\t}\n\n\treturn index;\n}\n","/**\n * Returns an iterable that uses a function that generates values a given number of times.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...mapRepeat((increment) => increment ** 2, 5)]; // [0, 1, 4, 9, 16]\n * ```\n *\n * @param valueFn - A function that returns each value to fill the array with\n * @param times - The number of times to repeat the value\n *\n * @see {@link mapFill} to do the same thing but return an array\n * @see {@link repeat} to do the same thing but with a given value\n *\n * @returns An iterable that repeats `value` `times` number of times\n *\n * @public\n * @category Iterable\n */\nexport function* mapRepeat<T>(valueFn: (increment: number) => T, times: number): Iterable<T> {\n\tfor (let index = 0; index < times; index++) {\n\t\tyield valueFn(index);\n\t}\n}\n","/**\n * Split an iterable into 2 arrays of elements that passed or failed a provided type guard.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const [numbers, strings] = partition(['a', 1, 'b', 2, 'c', 3], (element): element is number => typeof element === 'number');\n *\n * console.log(numbers); // [1, 2, 3]\n * console.log(strings); // ['a', 'b', 'c']\n * ```\n *\n * @param iterable - The iterable to partition\n * @param typeGuard - The type guard to apply to each element of `iterable`. If the type guard returns a truthy value the element will be added to the `passed`\n * array in the result. Otherwise, it will be added to the `failed` array.\n *\n * @returns A tuple where the 1st element is an array of elements that passed the predicate (`passed`) and the 2nd element are the elements that failed the predicate (`failed`)\n *\n * @public\n * @category Iterable\n */\nexport function partition<S extends T, T>(iterable: Iterable<T>, typeGuard: (element: T) => element is S): [passed: S[], failed: Array<Exclude<T, S>>];\n/**\n * Split an iterable into 2 arrays of elements that passed or failed a provided predicate.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const [odd, even] = partition([1, 2, 3, 4, 5, 6], num => num % 2);\n *\n * console.log(odd); // [1, 3, 5]\n * console.log(even); // [2, 4, 6]\n * ```\n *\n * @param iterable - The iterable to partition\n * @param predicate - The predicate to apply to each element of `iterable`. If the predicate returns a truthy value the element will be added to the `passed`\n * array in the result. Otherwise, it will be added to the `failed` array.\n *\n * @returns A tuple where the 1st element is an array of elements that passed the predicate (`passed`) and the 2nd element are the elements that failed the predicate (`failed`)\n *\n * @public\n * @category Iterable\n */\nexport function partition<T>(iterable: Iterable<T>, predicate: (value: T, increment: number) => unknown): [passed: T[], failed: T[]];\nexport function partition<T>(iterable: Iterable<T>, predicate: (value: T, increment: number) => unknown): [passed: T[], failed: T[]] {\n\tconst passed: T[] = [];\n\tconst failed: T[] = [];\n\tlet increment = 0;\n\n\tfor (const element of iterable) {\n\t\tconst array = predicate(element, increment++) ? passed : failed;\n\n\t\tarray.push(element);\n\t}\n\n\treturn [passed, failed];\n}\n","/**\n * Returns an iterable that repeats a given value a given number of times.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * [...repeat('a', 3)]; // ['a', 'a', 'a']\n * ```\n *\n * @param value - The value to repeat\n * @param times - The number of times to repeat the value\n *\n * @see {@link fill} to do the same thing but return an array\n * @see {@link mapRepeat} to do the same thing but with a function that generates values\n *\n * @returns An iterable that repeats `value` `times` number of times\n *\n * @public\n * @category Iterable\n */\nexport function* repeat<T>(value: T, times: number): Iterable<T> {\n\tfor (let index = 0; index < times; index++) {\n\t\tyield value;\n\t}\n}\n","/**\n * Returns an iterator that skips the first `count` elements of an iterable.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const iterable = [1, 2, 3, 4, 5];\n *\n * const iterator = skip(iterable, 2);\n *\n * iterator.next(); // { value: 3, done: false }\n * ```\n *\n * @param iterable - The iterable to skip elements from\n * @param count - The number of elements to skip\n *\n * @returns The iterator that skips the first `count` elements of `iterable`\n *\n * @public\n * @category Iterable\n */\nexport function skip<T>(iterable: Iterable<T>, count: number): Iterator<T> {\n\tconst iterator = iterable[Symbol.iterator]();\n\n\tfor (let index = 0; index < count; index++) {\n\t\tconst isDone = iterator.next().done;\n\n\t\tif (isDone) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn iterator;\n}\n","/**\n * Determines whether any of the elements of an iterable pass a given predicate.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * some([false], x => x); // false\n * ```\n * @example\n * ```js\n * some([false, true], x => x); // true\n * ```\n * @example\n * ```js\n * some([true], x => x); // true\n * ```\n *\n * @param iterable - The iterable to take elements from\n * @param predicate - The function to call on each element in the iterable to determine if it passes the test\n *\n * @returns `true` if any element passes the predicate, `false` otherwise\n *\n * @public\n * @category Iterable\n */\nexport function some<T>(iterable: Iterable<T>, predicate: (element: T) => unknown): boolean {\n\tfor (const element of iterable) {\n\t\tif (predicate(element)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n","import {repeat} from '../iterable';\n\n/**\n * Pads an array with a given value so that the array reaches a given length.\n * The padding is applied from the end (right) of the array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [0, 1, 2];\n *\n * padEnd(array, 4, 4);\n *\n * console.log(array); // [0, 1, 2, 4]\n * ```\n *\n * @param array - The array to pad\n * @param maxLength - The length of `array` once it has been padded. If this parameter is smaller than `array`'s length, `array` will not be modified\n * @param fillValue - The value to pad the array with\n *\n * @see {@link padStart} to pad the start of an array\n *\n * @public\n * @category Array\n */\nexport function padEnd<T>(array: T[], maxLength: number, fillValue: T): void {\n\tarray.push(...repeat(fillValue, maxLength - array.length));\n}\n","import {repeat} from '../iterable';\n\n/**\n * Pads an array with a given value so that the array reaches a given length.\n * The padding is applied from the start (left) of the array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * padStart(array, 4, 0);\n *\n * console.log(array); // [0, 1, 2, 3]\n * ```\n *\n * @param array - The array to pad\n * @param maxLength - The length of `array` once it has been padded. If this parameter is smaller than the current string's length, `array` will not be modified\n * @param fillValue - The value to pad the array with\n *\n * @see {@link padEnd} to pad the end of an array\n *\n * @public\n * @category Array\n */\nexport function padStart<T>(array: T[], maxLength: number, fillValue: T): void {\n\tarray.unshift(...repeat(fillValue, maxLength - array.length));\n}\n","/**\n * Remove an element from an array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * pull(array, 2); // [2]\n * console.log(array); // [1, 3]\n *\n * pull(array, 2); // []\n * console.log(array); // [1, 3]\n * ```\n *\n * @param array - The array to remove an element from\n * @param element - The element to remove\n *\n * @returns The return value of `Array.prototype.splice`\n *\n * @public\n * @category Array\n */\nexport function pull<T>(array: T[], element: T): ReturnType<(typeof array)['splice']> {\n\tconst index = array.indexOf(element);\n\n\tif (index === -1) {\n\t\treturn [];\n\t}\n\n\treturn array.splice(index, 1);\n}\n","import {indexOfAll} from './index-of-all';\n\n/**\n * Remove all elements equal to a given element from an array.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [1, 1, 2, 2, 3, 3];\n *\n * pullAll(array, 2); // [2, 2]\n * console.log(array); // [1, 1, 3, 3]\n *\n * pullAll(array, 2); // []\n * console.log(array); // [1, 1, 3, 3]\n * ```\n *\n * @param array - The array to remove elements from\n * @param element - The element to remove\n *\n * @returns The return value of `Array.prototype.splice`\n *\n * @public\n * @category Array\n */\nexport function pullAll<T>(array: T[], element: T): ReturnType<(typeof array)['splice']> {\n\tconst indexes = indexOfAll(array, element);\n\n\t// Reversing the indexes means we modify from end to start which has 2 benefits:\n\t// - We don't have to worry about shifting indexes as we splice elements\n\t// - We can avoid re-allocating the array as often\n\tindexes.reverse();\n\n\tconst pulled: T[] = [];\n\n\tfor (const index of indexes) {\n\t\tpulled.push(array.splice(index, 1)[0]);\n\t}\n\n\treturn pulled;\n}\n","/**\n * Replace the first occurrence of `searchElement` with `replacement` in an array.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 1, 3, 1];\n *\n * replace(array, 1, 2);\n *\n * console.log(array); // [2, 2, 1, 3, 1]\n * ```\n *\n * @param array - The array to replace elements in\n * @param searchElement - The element to search for\n * @param replacement - The element to replace `searchElement` with\n *\n * @returns The index of the replaced element, or `-1` if it is not present.\n *\n * @public\n * @category Array\n */\nexport function replace<T>(array: T[], searchElement: T, replacement: T): number {\n\tconst index = array.indexOf(searchElement);\n\n\tif (index !== -1) {\n\t\tarray[index] = replacement;\n\t}\n\n\treturn index;\n}\n","/**\n * Replace all occurrences of `searchElement` with `replacement` in an array.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 1, 3, 1];\n *\n * replaceAll(array, 1, 2);\n *\n * console.log(array); // [2, 2, 2, 3, 2]\n * ```\n *\n * @param array - The array to replace elements in\n * @param searchElement - The element to search for\n * @param replacement - The element to replace `searchElement` with\n *\n * @returns The number of elements replaced\n *\n * @public\n * @category Array\n */\nexport function replaceAll<T>(array: T[], searchElement: T, replacement: T): number {\n\tlet timesReplaced = 0;\n\n\tfor (let index = 0; index < array.length; index++) {\n\t\tif (array[index] === searchElement) {\n\t\t\tarray[index] = replacement;\n\n\t\t\ttimesReplaced++;\n\t\t}\n\t}\n\n\treturn timesReplaced;\n}\n","/**\n * Samples a single element at random from an array.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * sample(array); // 1, 2, or 3\n * ```\n *\n * @param array - Array to sample element from\n *\n * @see {@link (shuffle:1)} if you want to implement a random selection without replacement\n *\n * @returns A random element from the array or `undefined` if the array was empty\n *\n * @public\n * @category Array\n */\nexport function sample<T>(array: ArrayLike<T>): T | undefined {\n\treturn array[Math.floor(Math.random() * array.length)] as T | undefined;\n}\n","/**\n * A mutating (in-place) uniformly random array shuffle.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * shuffle(array);\n * ```\n *\n * @param array - Array to shuffle\n * @param mutate - Optional, `true` if specified\n *\n * @see {@link sample} if you only want to select one element at random\n *\n * @public\n * @category Array\n */\nexport function shuffle<T>(array: T[], mutate?: true): void;\n/**\n * A non-mutating uniformly random array shuffle.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * const shuffled = shuffle(array, false);\n * ```\n *\n * @param array - Array to shuffle\n * @param mutate - `false`\n *\n * @see {@link sample} if you only want to select one element at random\n *\n * @returns The shuffled array\n *\n * @public\n * @category Array\n */\nexport function shuffle<T>(array: ArrayLike<T> & Iterable<T>, mutate: false): T[];\nexport function shuffle<T>(array: T[] | (ArrayLike<T> & Iterable<T>), mutate = true): void | T[] {\n\tconst target: typeof array = mutate ? array : [...array];\n\n\tfor (let index1 = target.length - 1; index1 > 0; index1--) {\n\t\tconst index2 = Math.floor(Math.random() * (index1 + 1));\n\t\t[(target as T[])[index1], (target as T[])[index2]] = [target[index2], target[index1]];\n\t}\n\n\tif (!mutate) {\n\t\treturn target as T[];\n\t}\n}\n","import {firstIndexOfLastGroup} from './first-index-of-last-group';\n\n/**\n * Removes the trailing `end` characters from a string.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * trimEnd('aabbcc', 'c'); // 'aabb'\n * ```\n *\n * @param string - The string to trim\n * @param end - The character to remove from the end of `string`\n *\n * @returns A string with the leading `end` characters removed\n *\n * @see {@link (trimStart:1)} to do the same thing but trim from the start of a string\n *\n * @public\n * @category String\n */\nexport function trimEnd(string: string, end: string): string;\n/**\n * Removes the trailing `end` characters from an array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * trimEnd(['a', 'a', 'b', 'b', 'c', 'c'], 'c'); // ['a', 'a', 'b', 'b']\n * ```\n *\n * @param array - The array to trim\n * @param end - The character to remove from the end of `array`\n *\n * @returns A shallow-copied array with the trailing `start` characters removed\n *\n * @see {@link (trimStart:2)} to do the same thing but trim from the start of an array\n *\n * @public\n * @category Array\n */\nexport function trimEnd<T>(array: readonly T[], end: T): T[];\nexport function trimEnd<T>(base: string | readonly T[], toTrim: string | T): string | T[] {\n\t// `firstIndexOfLastGroup()` consumes the first few elements of the iterable which means you can't use `skip()` on `base` since it's been mutated\n\tconst index = firstIndexOfLastGroup(base, toTrim);\n\n\tif (index === -1) {\n\t\tif (typeof base === 'string') {\n\t\t\treturn base;\n\t\t}\n\n\t\t// Return a shallow copy like Array.prototype.slice does\n\t\treturn [...base];\n\t}\n\n\treturn base.slice(0, index);\n}\n","import {lastIndexOfFirstGroup} from '../iterable/last-index-of-first-group';\n\n/**\n * Removes the leading `start` characters from a string.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * trimStart('aabbcc', 'a'); // 'bbcc'\n * ```\n *\n * @param string - The string to trim\n * @param start - The character to remove from the start of `string`\n *\n * @returns A string with the leading `start` characters removed\n *\n * @see {@link (trimEnd:1)} to do the same thing but trim from the end of a string\n *\n * @public\n * @category String\n */\nexport function trimStart(string: string, start: string): string;\n/**\n * Removes the leading `start` characters from an array.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * trimStart(['a', 'a', 'b', 'b', 'c', 'c'], 'a'); // ['b', 'b', 'c', 'c']\n * ```\n *\n * @param array - The array to trim\n * @param start - The character to remove from the start of `array`\n *\n * @returns A shallow-copied array with the leading `start` characters removed\n *\n * @see {@link (trimEnd:2)} to do the same thing but trim from the end of an array\n *\n * @public\n * @category Array\n */\nexport function trimStart<T>(array: readonly T[], start: T): T[];\nexport function trimStart<T>(base: string | readonly T[], toTrim: string | T): string | T[] {\n\t// `lastIndexOfFirstGroup` consumes the first few elements of the iterable which means you can't use `skip` on `base` since it's been mutated\n\tconst index = lastIndexOfFirstGroup(base, toTrim);\n\n\tif (index === -1) {\n\t\tif (typeof base === 'string') {\n\t\t\treturn base;\n\t\t}\n\n\t\t// Return a shallow copy like Array.prototype.slice does\n\t\treturn [...base];\n\t}\n\n\treturn base.slice(index + 1);\n}\n","/**\n * A class to help with specific use-cases where you are using a percentage (ex. `1 / n`) but don't know `n` until runtime.\n *\n * @example\n * ```js\n * const autoPercentage = new AutoPercentage();\n *\n * const steps = [\n * \t{ name: 'init', progress: autoPercentage.percentage() },\n * \t{ name: 'modify', progress: autoPercentage.percentage() },\n * \t{ name: 'verify', progress: autoPercentage.percentage() },\n * \t{ name: 'cleanup', progress: 0 }\n * ];\n *\n * let progress = 0;\n *\n * for (const step of steps) {\n * \tif (progress === 1) {\n * \t\treturn;\n * \t}\n *\n * \tprogress += step.progress;\n *\n * \tconsole.log(`${step.name} finished - job is ${Math.round(progress * 100)}% complete`);\n * }\n * ```\n *\n * @public\n */\nexport class AutoPercentage {\n\tprivate _count = 0;\n\n\t/**\n\t * Increment and get the percentage.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const autoPercentage = new AutoPercentage();\n\t *\n\t * const a = autoPercentage.percentage();\n\t *\n\t * Number(a); // 1\n\t *\n\t * const b = autoPercentage.percentage();\n\t *\n\t * Number(a); // 0.5\n\t * Number(b); // 0.5\n\t * ```\n\t *\n\t * @returns The percentage\n\t */\n\tpercentage(): {[Symbol.toPrimitive](): number} {\n\t\tthis._count++;\n\t\treturn {[Symbol.toPrimitive]: () => 1 / this._count};\n\t}\n\n\t/**\n\t * Increment and get the number of times the percentage has been incremented.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const autoPercentage = new AutoPercentage();\n\t *\n\t * const a = autoPercentage.count();\n\t *\n\t * Number(a); // 1\n\t *\n\t * const b = autoPercentage.count();\n\t *\n\t * Number(a); // 2\n\t * Number(b); // 2\n\t * ```\n\t *\n\t * @returns The number of times this percentage has been incremented\n\t */\n\tcount(): {[Symbol.toPrimitive](): number} {\n\t\tthis._count++;\n\t\treturn {[Symbol.toPrimitive]: () => this._count};\n\t}\n}\n","/**\n * A type for an enum value.\n *\n * @public\n * @category Enum\n */\nexport type EnumValue = number | string;\n/**\n * A type for an enum.\n *\n * @public\n * @category Enum\n */\nexport type Enum<T extends EnumValue> = Readonly<Record<string | number, T>>;\n\nconst lookup = new WeakMap<Enum<EnumValue>, ReadonlySet<EnumValue>>();\n\n/**\n * Check whether a given value is a member value of an enum.\n *\n * Time complexity: _O(1)_ if `Enum` has been seen before. Otherwise, _O(n)_ where _n_ is the number of enum values.\n *\n * Space complexity: _O(1)_ if `Enum` has been seen before. Otherwise, _O(n)_ where _n_ is the number of unique enum values.\n *\n * @example\n * ```ts\n * enum Enum {\n *   A,\n *   B,\n * }\n *\n * enumHas(Enum, 0); // true\n * enumHas(Enum, 2); // false\n * ```\n *\n * @param Enum - The enum to use as the source of member values\n * @param value - The value to check\n *\n * @returns Whether `value` is a member value of `Enum`\n *\n * @public\n * @category Enum\n */\nexport function enumHas<T extends EnumValue>(Enum: Enum<T>, value: unknown): value is T {\n\tif (!lookup.has(Enum)) {\n\t\tlookup.set(Enum, new Set(Object.values(Enum)));\n\t}\n\n\tconst values = lookup.get(Enum)!;\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\treturn values.has(value as any);\n}\n","import type {Table} from '../array';\n\n/**\n * Get the lengths of each column in a table.\n * Can include a header.\n *\n * Time complexity: _O(n)_ where _n_ is the number of rows * columns.\n *\n * Space complexity: _O(n)_\n *\n * @param table - The table of strings to use for calculations\n *\n * @returns An array of lengths\n *\n * @public\n * @category Format\n */\nexport function maxColumnLength(table: Table<string>): number[] {\n\tconst lengths = table[0].map(column => column.length);\n\n\tfor (const row of table) {\n\t\tfor (const [index, {length: columnLength}] of row.entries()) {\n\t\t\tconst length = lengths[index];\n\n\t\t\tif (length < columnLength) {\n\t\t\t\tlengths[index] = columnLength;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lengths;\n}\n","import type {Table} from '../array';\nimport {maxColumnLength} from './max-column-length';\n\n/**\n * Format a table into a string of equally sized columns.\n *\n * Time complexity: _O(n)_ where _n_ is the number of rows * columns.\n *\n * Space complexity: _O(n)_\n *\n * @param table - Table to format\n * @param delimiter - Delimiter to use in columns\n *\n * @returns A formatted string representation of the table\n *\n * @public\n * @category Format\n */\nexport function formatTable(table: Table<string>, delimiter = ' '): string {\n\tconst maxLengths = maxColumnLength(table);\n\n\treturn table.map(row => row.map((column, index) => column.padEnd(maxLengths[index])).join(delimiter)).join('\\n');\n}\n","import type {NumberLike} from '../types';\n\n/**\n * Create a new function taht calls the provided `fn` and then inverts the sign of the result.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * function sort(a, b) {\n *   return a - b;\n * }\n *\n * const inverted = invert(sort);\n *\n * inverted(10, 5); // -5\n * ```\n *\n * @param fn - Function to invert return value of\n *\n * @returns The inverted return value of `fn`\n *\n * @public\n * @category Higher order\n */\nexport function invert<T extends (...parameters: any[]) => NumberLike>(fn: T): T {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\treturn ((...parameters) => -fn(...parameters)!) as T;\n}\n","/**\n * Create a new function that calls the provided `fn` and negates the result.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * import { nullish } from '@jonahsnider/util';\n *\n * const array = [0, null, '', undefined, false];\n *\n * array.filter(not(nullish)); // [0, '', false]\n * ```\n *\n * @param fn - Function to negate the return value of\n *\n * @returns The inverted return value of `fn`\n *\n * @public\n * @category Higher order\n */\nexport function not<T extends (...parameters: any[]) => boolean>(fn: T): (...parameters: Parameters<T>) => boolean {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\treturn ((...parameters) => !fn(...parameters)) as T;\n}\n","/**\n * Create a new function that calls the provided `fn` with the given arguments.\n * After the first call the return value will be cached and returned again, meaning you technically only need to pass the arguments the first time.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * function add(a, b) {\n *  return a + b;\n * }\n *\n * const thunk = thunkify(add);\n *\n * thunk(1, 2); // 3\n * thunk(3, 4); // 3\n * ```\n *\n * @param fn - The function to thunkify\n *\n * @returns A function that returns whatever the first call of `fn` returns for the given arguments\n *\n * @public\n * @category Higher order\n */\nexport function thunkify<T extends (...args: unknown[]) => unknown>(fn: T): (...parameters: Parameters<T>) => ReturnType<T> {\n\tlet wasCalled = false;\n\tlet result: ReturnType<T>;\n\n\treturn (...parameters: Parameters<T>): ReturnType<T> => {\n\t\tif (!wasCalled) {\n\t\t\twasCalled = true;\n\n\t\t\tresult = fn(...parameters) as ReturnType<T>;\n\t\t}\n\n\t\treturn result;\n\t};\n}\n","function identicalArray<T>(a: T[], b: T[]): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\treturn a.every((element, index) => element === b[index]);\n}\n\nfunction identicalSet<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.size !== b.size) {\n\t\treturn false;\n\t}\n\n\tfor (const element of a) {\n\t\tif (!b.has(element)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction identicalMap<K, V>(a: ReadonlyMap<K, V>, b: ReadonlyMap<K, V>): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.size !== b.size) {\n\t\treturn false;\n\t}\n\n\tfor (const [key, value] of a.entries()) {\n\t\tif (!b.has(key) || b.get(key) !== value) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Check if 2 arrays have the same elements in the same order.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const a = [1, 2, 3];\n * const b = [1, 2, 3];\n *\n * identical(a, b); // true\n * ```\n *\n * @param a - First array to compare\n * @param b - Second array to compare\n *\n * @returns `true` if `a` and `b` have the same elements in the same order, `false` otherwise\n *\n * @public\n */\nexport function identical<V>(a: readonly V[], b: readonly V[]): boolean;\n/**\n * Check if 2 `Set`s have the same elements.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const a = new Set([1, 2, 3]);\n * const b = new Set([3, 2, 1]);\n *\n * identical(a, b); // true\n * ```\n *\n * @param a - First `Set` to compare\n * @param b - Second `Set` to compare\n *\n * @returns `true` if `a` and `b` have the same elements, `false` otherwise\n *\n * @public\n */\nexport function identical<V>(a: ReadonlySet<V>, b: ReadonlySet<V>): boolean;\n/**\n * Check if 2 `Map`s have the same key-value pairs.\n * Strict equality (`===`) is used to compare values.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const a = new Map([['a', 1]]);\n * const b = new Map([['a', 1]]);\n *\n * identical(a, b); // true\n * ```\n *\n * @param a - First `Map` to compare\n * @param b - Second `Map` to compare\n *\n * @returns `true` if `a` and `b` have the key-value pairs, `false` otherwise\n *\n * @public\n */\nexport function identical<K, V>(a: ReadonlyMap<K, V>, b: ReadonlyMap<K, V>): boolean;\nexport function identical<V, K = never>(a: readonly V[] | ReadonlySet<V> | ReadonlyMap<K, V>, b: readonly V[] | ReadonlySet<V> | ReadonlyMap<K, V>): boolean {\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn identicalArray(a, b);\n\t}\n\n\tif (a instanceof Set && b instanceof Set) {\n\t\treturn identicalSet(a, b);\n\t}\n\n\tif (a instanceof Map && b instanceof Map) {\n\t\treturn identicalMap(a, b);\n\t}\n\n\tthrow new RangeError('Expected both parameters to be an array, Set, or Map');\n}\n","/**\n * Check if 2 or more iterables hold the same elements.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_ where _n_ is the number of elements in the iterables\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const a = [1, 2, 3];\n * const b = [1, 2, 3];\n * const c = [1, 2, 3];\n * const d = [1, 2, 3];\n * const e = [1, 2, 3];\n *\n * same(a, b, c, d, e); // true\n * ```\n *\n * @param iterables - Elements to compare\n *\n * @returns `true` if all elements are strictly equal, `false` otherwise\n *\n * @public\n */\nexport function same<T>(...iterables: readonly [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]): boolean {\n\tconst iterators = iterables.map(item => item[Symbol.iterator]());\n\n\tfor (;;) {\n\t\tconst nexts = iterators.map(iterator => iterator.next());\n\n\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\tconst [{done, value}] = nexts;\n\n\t\tfor (const next of nexts) {\n\t\t\tif (next.done) {\n\t\t\t\treturn nexts.every(next => next.done === done);\n\t\t\t}\n\n\t\t\tif (next.value !== value) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n}\n","import type {AnyFunction} from '../types';\n\n/**\n * A `Map` that has a default value for missing keys.\n *\n *\n * @example\n * ```js\n * const map = new DefaultMap(0);\n *\n * map.get('a'); // 0\n * ```\n *\n * @example\n * ```js\n * const map = new DefaultMap(key => key.toUpperCase());\n *\n * map.get('a'); // 'A'\n * ```\n *\n * @public\n * @category Map\n */\nexport class DefaultMap<K, V, D extends V = V> extends Map<K, V> {\n\t/**\n\t * If the default value is a function.\n\t */\n\tprivate readonly defaultValueIsFunction: boolean;\n\n\t/**\n\t * Create a new `DefaultMap` with a specified default value.\n\t *\n\t * Time complexity: _O(n)_\n\t *\n\t * Space complexity: _O(n)_\n\t *\n\t * @param defaultValue - The default value to use for missing keys\n\t *\n\t * @example\n\t * ```js\n\t * const map = new DefaultMap(0);\n\t * ```\n\t */\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tconstructor(defaultValue: Exclude<D, AnyFunction>, entries?: ConstructorParameters<MapConstructor>[0] | null);\n\t/**\n\t * Create a new `DefaultMap` with a specified function to generate default values.\n\t *\n\t * Time complexity: _O(n)_\n\t *\n\t * Space complexity: _O(n)_\n\t *\n\t * @param defaultValueFn - The function to generate default values\n\t *\n\t * @example\n\t * ```js\n\t * const map = new DefaultMap(key => key.toUpperCase());\n\t * ```\n\t */\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tconstructor(defaultValueFn: (key: K) => D, entries?: ConstructorParameters<MapConstructor>[0] | null);\n\tconstructor(\n\t\tprivate readonly defaultValueOrDefaultValueFn: Exclude<D, AnyFunction> | ((key: K) => D),\n\t\tentries?: ConstructorParameters<MapConstructor>[0] | undefined,\n\t) {\n\t\t// @ts-expect-error The types to allow constructing via an Iterable don't work for some reason\n\t\tsuper(entries);\n\n\t\tthis.defaultValueIsFunction = typeof defaultValueOrDefaultValueFn === 'function';\n\t}\n\n\t/**\n\t * Get the value for a given key, or the default value if it's missing.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * map.get('a');\n\t * ```\n\t *\n\t * @param key - The key to get the value for\n\t *\n\t * @returns The value for `key`, or the default value if it's missing\n\t */\n\tget(key: K): V | D {\n\t\tif (this.has(key)) {\n\t\t\treturn super.get(key)!;\n\t\t}\n\n\t\t// Compiler limitation\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n\t\treturn this.defaultValueIsFunction ? (this.defaultValueOrDefaultValueFn as any)(key) : this.defaultValueOrDefaultValueFn;\n\t}\n}\n","import {DefaultMap} from './default-map';\n\n// TODO: Allow bigints as well\ntype V = number;\n\n/**\n * A {@link DefaultMap} with methods for performing basic math operations that mutate the data.\n *\n * @alpha\n */\nexport class MathMap<K> extends DefaultMap<K, V> {\n\t/**\n\t * Add an addend to the value for a given key.\n\t *\n\t * @example\n\t * ```js\n\t * map.add('a', 1);\n\t * ```\n\t *\n\t * @param key - The key to update the value of\n\t * @param addend - The value to add to the current value\n\t *\n\t * @returns The updated value\n\t */\n\tadd(key: K, addend: V): V {\n\t\tconst newValue = this.get(key) + addend;\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Subtract a subtrahend from the value for a given key.\n\t *\n\t * @example\n\t * ```js\n\t * map.subtract('a', 1);\n\t * ```\n\t *\n\t * @param key - The key to update the value of\n\t * @param subtrahend - The value to subtract from the current value\n\t *\n\t * @returns The updated value\n\t */\n\tsubtract(key: K, subtrahend: V): V {\n\t\tconst newValue = this.get(key) - subtrahend;\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Multiply a multiplicand by the value for a given key.\n\t *\n\t * @example\n\t * ```js\n\t * map.multiply('a', 1);\n\t * ```\n\t *\n\t * @param key - The key to update the value of\n\t * @param multiplicand - The value to multiply the current value by\n\t *\n\t * @returns The updated value\n\t */\n\tmultiply(key: K, multiplicand: V): V {\n\t\tconst newValue = this.get(key) * multiplicand;\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Divide the value for a given key by a divisor.\n\t *\n\t * @example\n\t * ```js\n\t * map.divide('a', 1);\n\t * ```\n\t *\n\t * @param key - The key to update the value of\n\t * @param divisor - The value to divide the current value by\n\t *\n\t * @returns The updated value\n\t */\n\tdivide(key: K, divisor: V): V {\n\t\tconst newValue = this.get(key) / divisor;\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Raise the value for a given key to an exponent.\n\t *\n\t * @example\n\t * ```js\n\t * map.pow('a', 2);\n\t * ```\n\t *\n\t * @param key - The key to update the value of\n\t * @param exponent - The exponent to raise the current value to\n\t *\n\t * @returns The updated value\n\t */\n\tpow(key: K, exponent: V): V {\n\t\tconst newValue = this.get(key) ** exponent;\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Square root of the value for a given key.\n\t *\n\t * @example\n\t * ```js\n\t * map.sqrt('a');\n\t * ```\n\t *\n\t * @param key - The key to get the square root of\n\t *\n\t * @returns The square root of the value for `key`\n\t */\n\tsqrt(key: K): V {\n\t\tconst newValue = Math.sqrt(this.get(key));\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n\n\t/**\n\t * Take the _n_th root of the value for a given key.\n\t *\n\t * @example\n\t * ```js\n\t * map.root('a', 2);\n\t * ```\n\t *\n\t * @param key - The key to get the _n_th root of\n\t * @param root - The root to get\n\t *\n\t * @returns The nth root of the value for `key`\n\t */\n\troot(key: K, root: V): V {\n\t\tif (root === 2) {\n\t\t\treturn this.sqrt(key);\n\t\t}\n\n\t\tconst newValue = this.get(key) ** (1 / root);\n\n\t\tthis.set(key, newValue);\n\n\t\treturn newValue;\n\t}\n}\n","/**\n * Returns the value nearest to value which is within the closed range [`min`, `max`].\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const value = clamp(Math.random() * 100, 25, 75n);\n *\n * console.log(25 <= value && value <= 75n); // true\n * ```\n *\n * @param value - The value to clamp\n * @param min - The lower bound of the range of numbers\n * @param max - The upper bound of the range of numbers\n *\n * @returns The value nearest to `value` which is within the provided range\n *\n * @public\n * @category Math\n */\nexport function clamp<T extends number | bigint, M1 extends number | bigint, M2 extends number | bigint>(value: T, min: M1, max: M2): T | M1 | M2 {\n\tif (min > max) {\n\t\tthrow new RangeError('min exceeded max');\n\t}\n\n\t// Using if statements here is in theory faster than the naive solution of Math.min(Math.max(value, min), max) since the if statements do 1-2 comparisons while the\n\t// naive solution always does 2 comparisons\n\tif (value < min) {\n\t\treturn min;\n\t}\n\n\tif (value > max) {\n\t\treturn max;\n\t}\n\n\treturn value;\n}\n","/**\n * Calculate the product of 2 `number`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * array.reduce(product); // 6\n * ```\n *\n * @param a - First factor\n * @param b - Second factor\n *\n * @returns The product of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function product(a: number, b: number): number;\n/**\n * Calculate the product of 2 `bigint`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1n, 2n, 3n];\n *\n * array.reduce(product); // 6n\n * ```\n *\n * @param a - First factor\n * @param b - Second factor\n *\n * @returns The product of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function product(a: bigint, b: bigint): bigint;\nexport function product<T extends number>(a: T, b: T): T {\n\treturn (a * b) as T;\n}\n","import {product} from '../reducers/product';\n\n/**\n * Get the geometric mean of an array of `number`s.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3, 4];\n *\n * geometricMean(array); // 24 ** (1 / 4)\n * ```\n *\n * @param array - The array to calculate the mean of\n *\n * @see {@link (mean:1)} to calculate the arithmetic mean of an array\n * @see {@link geometricMean} to calculate the harmonic mean of an array\n *\n * @returns The geometric mean of the array\n *\n * @public\n * @category Math\n */\nexport function geometricMean(array: readonly number[]): number {\n\treturn array.reduce(product) ** (1 / array.length);\n}\n","/**\n * Get the harmonic mean of an array of `number`s.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 4, 4];\n *\n * harmonicMean(array); // 2\n * ```\n *\n * @param array - The array to calculate the mean of\n *\n * @see {@link (mean:1)} to calculate the arithmetic mean of an array\n * @see {@link geometricMean} to calculate the arithmetic mean of an array\n *\n * @returns The geometric mean of the array\n *\n * @public\n * @category Math\n */\nexport function harmonicMean(array: readonly number[]): number {\n\treturn array.length / array.reduce((accumulator, x) => accumulator + 1 / x, 0);\n}\n","/**\n * Calculate the sum of 2 `number`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * array.reduce(sum); // 6\n * ```\n *\n * @param a - First summand\n * @param b - Second summand\n *\n * @returns The sum of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function sum(a: number, b: number): number;\n/**\n * Calculate the sum of 2 `bigint`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1n, 2n, 3n];\n *\n * array.reduce(sum); // 6n\n * ```\n *\n * @param a - First summand\n * @param b - Second summand\n *\n * @returns The sum of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function sum(a: bigint, b: bigint): bigint;\nexport function sum<T extends number>(a: T, b: T): T {\n\treturn (a + b) as T;\n}\n","import {sum} from '../reducers/sum';\n\n/**\n * Get the arithmetic mean of an array of `number`s.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * mean(array); // 2\n * ```\n *\n * @param array - The array to calculate the mean of\n *\n * @see {@link (median:1)} to calculate the median of an array\n * @see {@link mode} to calculate the mode of an array\n * @see {@link geometricMean} to calculate the geometric mean of an array\n * @see {@link harmonicMean} to calculate the harmonic mean of an array\n *\n * @returns The mean of the array\n *\n * @public\n * @category Math\n */\nexport function mean(array: readonly number[]): number;\n/**\n * Get the arithmetic mean of an array of `bigint`s.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1n, 2n, 3n];\n *\n * mean(array); // 2n\n * ```\n *\n * @param array - The array to calculate the mean of\n *\n * @see {@link (median:2)} to calculate the median of an array\n * @see {@link mode} to calculate the mode of an array\n *\n * @returns The mean of the array\n *\n * @public\n * @category Math\n */\nexport function mean(array: readonly bigint[]): bigint;\nexport function mean<T extends number>(array: readonly T[]): T {\n\tconst summed = (array as readonly number[]).reduce(sum) as unknown as T;\n\n\tconst length = (typeof summed === 'bigint' ? BigInt(array.length) : array.length) as T;\n\n\treturn (summed / length) as T;\n}\n","/**\n * Calculate the median of an array of numbers.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const values = [1, 2, 3];\n *\n * median(values); // 2\n * ```\n *\n * @param array - Values to use in the calculation\n *\n * @see {@link (mean:1)} to calculate the mean of an array\n * @see {@link mode} to calculate the mode of an array\n *\n * @returns The median of `values`\n *\n * @public\n * @category Math\n */\nexport function median(array: ArrayLike<number>): number;\n/**\n * Calculate the median of an array of bigints.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const values = [1n, 2n, 3n];\n *\n * median(values); // 2n\n * ```\n *\n * @param array - Values to use in the calculation\n *\n * @see {@link (mean:2)} to calculate the mean of an array\n * @see {@link mode} to calculate the mode of an array\n *\n * @returns The median of `values`\n *\n * @public\n * @category Math\n */\nexport function median(array: ArrayLike<bigint>): bigint;\nexport function median<T extends number>(array: ArrayLike<T>): T {\n\tconst isEven = array.length % 2 === 0;\n\tconst middleIndex = array.length / 2;\n\n\tif (isEven) {\n\t\tconst divisor = (typeof array[0] === 'bigint' ? 2n : 2) as T;\n\n\t\treturn ((array[middleIndex - 1] + array[middleIndex]) / divisor) as T;\n\t}\n\n\treturn array[Math.floor(middleIndex)];\n}\n","/**\n * Calculate the mode of an iterable.\n * Strict equality (`===`) is used to compare elements.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const values = [1, 2, 2, 3, 3];\n *\n * mode(values); // [2, 3]\n * ```\n *\n * @param iterable - Values to use in the calculation\n *\n * @see {@link (mean:1)} to calculate the mean of an array\n * @see {@link (median:1)} to calculate the median of an array\n *\n * @returns An array of the modes of `values`\n *\n * @public\n * @category Math\n */\nexport function mode<T>(iterable: Iterable<T>): T[] {\n\tconst frequencyTable = new Map<T, number>();\n\tlet maxOccurrences = 0;\n\tlet modes: T[] = [];\n\n\tfor (const element of iterable) {\n\t\tconst occurrences = frequencyTable.get(element);\n\t\tconst newOccurrences = occurrences === undefined ? 1 : occurrences + 1;\n\n\t\tfrequencyTable.set(element, newOccurrences);\n\n\t\tif (newOccurrences > maxOccurrences) {\n\t\t\tmaxOccurrences = newOccurrences;\n\t\t\tmodes = [element];\n\t\t} else if (newOccurrences === maxOccurrences) {\n\t\t\tmodes.push(element);\n\t\t}\n\t}\n\n\treturn modes;\n}\n","/**\n * Calculate the normal distribution.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * normaldist(0, 1, 0);\n * ```\n *\n * @param x - Sample to calculate the normal distribution of\n * @param standardDeviation - Standard deviation\n * @param mean - Mean\n *\n * @see {@link standardNormaldist} For calculating the standard normal distribution\n *\n * @returns The normal distribution\n *\n * @public\n * @category Math\n */\nexport function normaldist(x: number, standardDeviation: number, mean: number): number {\n\treturn (1 / (standardDeviation * Math.sqrt(2 * Math.PI))) * Math.E ** ((-1 / 2) * (x - mean / standardDeviation) ** 2);\n}\n","/**\n * Generate a random number within the given bounds.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const value = random(0, 10);\n *\n * 0 <= value && value < 10;\n * ```\n *\n * @param min - Lower bound (inclusive) of the output range\n * @param max - Upper bound (exclusive) of the output range\n *\n * @returns A random number within the given bounds\n *\n * @public\n * @category Math\n */\nexport function random(min: number, max: number): number {\n\tif (min > max) {\n\t\tthrow new RangeError('min exceeded max');\n\t}\n\n\treturn Math.random() * (max - min) + min;\n}\n","import {random} from './random';\n\n/**\n * Generate a random integer within the given bounds.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * randomInt(0, 3); // 0, 1, or 2\n * ```\n *\n * @param min - Lower bound (inclusive) of the output range\n * @param max - Upper bound (exclusive) of the output range\n *\n * @returns A random integer within the given bounds\n *\n * @public\n * @category Math\n */\nexport function randomInt(min: number, max: number): number {\n\tif (min > max) {\n\t\tthrow new RangeError('min exceeded max');\n\t}\n\n\treturn Math.floor(random(Math.ceil(min), Math.floor(max)));\n}\n","import {sum} from '../reducers/sum';\nimport {mean} from './mean';\n\n/**\n * Calculate the variance of a sequence of numbers.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * variance([1, 2, 3]); // 1\n * ```\n *\n * @param values - Values to use in the calculation\n * @param meanValue - The mean of `values`, will be calculated if not provided\n *\n * @returns The variance of `values`\n *\n * @public\n * @category Math\n */\nexport function variance(values: readonly number[], meanValue = mean(values)): number {\n\treturn values.map(value => (value - meanValue) ** 2).reduce(sum) / (values.length - 1);\n}\n","import {variance} from './variance';\nimport {mean} from './mean';\n\n/**\n * Calculate the standard deviation of a sequence of numbers.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * stddev([1, 2, 3]); // 1\n * ```\n *\n * @param values - Values to use in the calculation\n * @param meanValue - The mean of `values`, will be calculated if not provided\n *\n * @returns The standard deviation of `values`\n *\n * @public\n * @category Math\n */\nexport function stddev(values: readonly number[], meanValue = mean(values)): number {\n\treturn Math.sqrt(variance(values, meanValue));\n}\n","import {mean} from './mean';\nimport {stddev} from './stddev';\n\n/**\n * Calculate the relative standard deviation (coefficient of variation) of a sequence of numbers.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * relativeStddev([1, 2, 3]); // 0.5\n * ```\n *\n * @param values - Values to use in the calculation\n * @param meanValue - The mean of `values`, will be calculated if not provided\n *\n * @returns The standard deviation of `values`\n *\n * @public\n * @category Math\n */\nexport function relativeStddev(values: readonly number[], meanValue = mean(values)): number {\n\treturn stddev(values, meanValue) / meanValue;\n}\n","import {normaldist} from './normaldist';\n\n/**\n * Calculate the standard normal distribution.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * standardNormaldist(0) === normaldist(0, 1, 0); // true\n * ```\n *\n * @param x - Sample to calculate the normal distribution of\n *\n * @see {@link normaldist} For calculating the normal distribution\n *\n * @returns The standard normal distribution\n *\n * @public\n * @category Math\n */\nexport function standardNormaldist(x: number): number {\n\treturn normaldist(x, 1, 0);\n}\n","/**\n * Calculate the *n*th triangular number for a provided `number`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * triangularNumber(2); // 3\n * ```\n *\n * @param value - The number to calculate the triangular number for\n *\n * @returns The *n*th triangular number for the provided `value`\n *\n * @public\n * @category Math\n */\nexport function triangularNumber(value: number): number;\n/**\n * Calculate the *n*th triangular number for a provided `bigint`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * triangularNumber(2n); // 3n\n * ```\n *\n * @param value - The number to calculate the triangular number for\n *\n * @returns The *n*th triangular number for the provided `value`\n *\n * @public\n * @category Math\n */\nexport function triangularNumber(value: bigint): bigint;\nexport function triangularNumber(value: number | bigint): number | bigint {\n\tif (value < 0) {\n\t\tthrow new RangeError('Value must be greater than or equal to 0');\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn (value * (value + 1n)) / 2n;\n\t}\n\n\treturn (value * (value + 1)) / 2;\n}\n","/**\n * `null` or `undefined`.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Nullish = null | undefined;\n\n/**\n * Check if something is `null` or `undefined`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const value = Math.random() > 0.5 ? 'hello' : null;\n *\n * nullish(value);\n * ```\n *\n * @param value - Value to check\n *\n * @returns `true` if `value` is nullish, `false` if otherwise\n *\n * @public\n */\nexport function nullish(value: unknown): value is Nullish {\n\treturn value === null || value === undefined;\n}\n","import type {AnyFunction} from '../types';\n\n/**\n * Get a string name for a class method.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * class Class {\n * \t static staticMethod() {}\n * }\n *\n * name(Class, Class.staticMethod); // 'Class.staticMethod'\n * ```\n *\n * @example\n * ```js\n * class Class {\n * \t instanceMethod() {}\n * }\n *\n * name(Class, Class.prototype.instanceMethod); // 'Class#instanceMethod'\n * ```\n *\n * @param ctor - The class to use as the first part of the name\n * @param method - The method to use as the second part of the name\n *\n * @returns A string name for the method\n *\n * @public\n * @category Object\n */\nexport function name(ctor: new (...args: any[]) => any, method: AnyFunction): `${string}${'.' | '#'}${string}`;\n/**\n * Get the name of a function or class.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * function func() {}\n *\n * name(func); // 'func'\n * ```\n *\n * @example\n * ```js\n * class Class {}\n *\n * name(Class); // 'Class'\n * ```\n *\n * @param func - The function or class to get the name for\n *\n * @returns The name of `func`\n *\n * @public\n * @category Object\n */\nexport function name(func: (new (...args: any[]) => any) | AnyFunction): string;\nexport function name(ctorOrFunc: AnyFunction | (new (...args: any[]) => any), func?: AnyFunction): string {\n\tif (func) {\n\t\tconst className = name(ctorOrFunc);\n\n\t\tconst separator = func.name in ctorOrFunc ? '.' : '#';\n\n\t\treturn `${className}${separator}${func.name}`;\n\t}\n\n\treturn ctorOrFunc.name;\n}\n","/**\n * Get a `Set` representing the difference of `a` and `b` (`a \\ b`).\n * The order of parameters matters.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @param a - First iterable\n * @param b - Second iterable\n *\n * @returns A new `Set` which is the difference of `a` and `b`\n *\n * @deprecated Use `Set#difference()` instead.\n *\n * @public\n * @category Set\n */\nexport function difference<T>(a: Iterable<T>, b: Iterable<T>): Set<T> {\n\tif (a === b) {\n\t\treturn new Set();\n\t}\n\n\tconst result = new Set(a);\n\n\tfor (const element of b) {\n\t\tresult.delete(element);\n\t}\n\n\treturn result;\n}\n","import {clamp} from '../math/clamp';\nimport {largeToSmall} from '../array/large-to-small';\n\n/**\n * Get the Jaccard index of 2 `Set`s.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @param a - First `Set`\n * @param b - Second `Set`\n *\n * @returns The Jaccard index of `a` and `b`\n *\n * @public\n * @category Set\n */\nexport function jaccardIndex<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): number {\n\tif (a.size === 0 && b.size === 0) {\n\t\treturn 1;\n\t}\n\n\t// TODO: Consider exporting this as an intersectionSize() function and creating other functions for difference(), union(), etc\n\tlet intersectionSize = 0;\n\tconst [largest, smallest] = largeToSmall(a, b);\n\n\tfor (const element of largest) {\n\t\tif (smallest.has(element)) {\n\t\t\tintersectionSize++;\n\t\t}\n\t}\n\n\tconst unionSize = a.size + b.size - intersectionSize;\n\n\treturn clamp(intersectionSize / unionSize, 0, 1);\n}\n","import {difference} from '../set';\n\n/**\n * Create a copy of a provided object with the provided keys omitted.\n * This is an implementation of the `Omit<T, K>` type in TypeScript.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const object = { a: 1, b: 2, c: 3 };\n *\n * omit(object, ['c']); // { a: 1, b: 2 }\n * ```\n *\n * @param object - The object you are renaming a key of\n * @param keys - The keys to remove from the object\n *\n * @returns A new object containing the entries that were not omitted\n *\n * @public\n * @category Object\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function omit<T extends object, K extends keyof T>(object: T, keys: readonly K[]): Omit<T, K> {\n\tconst keptKeys = difference(\n\t\tObject.keys(object),\n\t\t// Replicates the behavior of Object.keys() casting numeric keys to strings and removing symbols\n\t\tkeys.filter(key => typeof key !== 'symbol').map(String),\n\t) as Set<keyof T>;\n\n\treturn Object.fromEntries([...keptKeys].map(key => [key, object[key]])) as Omit<T, K>;\n}\n","/**\n * From `object`, pick a set of properties whose keys are in the `keys` array.\n * This is an implementation of the `Pick<T, K>` type in TypeScript.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const object = { a: 1, b: 2, c: 3 };\n *\n * pick(object, ['a', 'b']); // { a: 1, b: 2 }\n * ```\n *\n * @param object - The object you are picking entries from\n * @param keys - The keys to keep from the object\n *\n * @returns A new object containing the picked entries\n *\n * @public\n * @category Object\n */\nexport function pick<T, K extends keyof T>(object: T, keys: readonly K[]): Pick<T, K> {\n\treturn Object.fromEntries(keys.map(key => [key, object[key]])) as Pick<T, K>;\n}\n","/**\n * @returns `T` if `T` is not a union type, `never` otherwise.\n *\n * @internal\n * @category Object\n */\ntype NonUnion<T, U extends T = T> = (T extends T ? (U extends T ? false : true) : never) extends false ? T : never;\nexport type {NonUnion as _NonUnion};\n\n/**\n * Create a copy of an object with a key renamed.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const object = { a: 1 };\n *\n * rename(object, 'a', 'b'); // { b: 1 }\n * ```\n *\n * @param object - The object you are renaming a key of\n * @param oldKey - The key to rename\n * @param newKey - The new name for the key\n *\n * @returns A shallow-copied object with the key name updated\n *\n * @public\n * @category Object\n */\nexport function rename<T, K1 extends keyof T, K2 extends PropertyKey>(\n\ttarget: T,\n\toldKey: NonUnion<K1>,\n\tnewKey: NonUnion<K2>,\n): Omit<T, K1 | K2> & Record<K2, T[K1]>;\nexport function rename<T, K1 extends keyof T, K2 extends PropertyKey>(object: T, oldKey: K1, newKey: K1 | K2): Omit<T, K1 | K2> & Record<string, T[K1]> {\n\tif (oldKey === newKey) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn {...object} as any;\n\t}\n\n\tconst {[oldKey]: _, ...result} = {...object, [newKey]: object[oldKey]};\n\n\t// This logic can be rewritten to remove the need for a type assertion, but would require 2 iterations over result instead of 1\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn result as any;\n}\n","/**\n * A result type for a `Promise` that resolved.\n *\n * @public\n * @category Promise\n */\nexport type ResolvedResult<T> = [value: T, error: undefined];\n/**\n * A result type for a `Promise` that rejected.\n *\n * @public\n * @category Promise\n */\nexport type RejectedResult<T> = [value: undefined, error: T];\n/**\n * A result type to represent a resolved or rejected `Promise`.\n * @public\n * @category Promise\n */\nexport type Result<T, E> = ResolvedResult<T> | RejectedResult<E>;\n/**\n * Settle a promise by returning a tuple of the resolved value or rejected error.\n * This function never rejects.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const [value, error] = await settled(promise);\n * ```\n *\n * @param promise - The promise to settle\n *\n * @returns A tuple of the resolved value or rejected error\n *\n * @public\n * @category Promise\n */\nexport async function settled<E, T>(promise: PromiseLike<T>): Promise<Result<T, E>> {\n\ttry {\n\t\treturn [await promise, undefined];\n\t} catch (error: unknown) {\n\t\treturn [undefined, error as E];\n\t}\n}\n","const DELAY_RESOLVED_VALUE = Symbol('delayResolvedValue');\nfunction delay(ms: number): [timer: NodeJS.Timeout, delay: PromiseLike<typeof DELAY_RESOLVED_VALUE>] {\n\tlet timer: NodeJS.Timeout;\n\n\tconst promise = new Promise<typeof DELAY_RESOLVED_VALUE>(resolve => {\n\t\ttimer = setTimeout(() => {\n\t\t\tresolve(DELAY_RESOLVED_VALUE);\n\t\t}, ms);\n\t});\n\n\treturn [timer!, promise];\n}\n\n/**\n * Reject if the given promise does not resolve within the given timeout.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @param promise - The promise to wait for\n * @param timeoutMs - The timeout in milliseconds\n *\n * @returns The resolved value of the promise\n *\n * @public\n * @category Promise\n */\nexport async function timeout<T>(promise: PromiseLike<T>, timeoutMs: number): Promise<T> {\n\tconst [timer, timeoutPromise] = delay(timeoutMs);\n\tconst resolvedValue = await Promise.race([promise, timeoutPromise]).finally(() => {\n\t\tclearTimeout(timer);\n\t});\n\n\tif (resolvedValue === DELAY_RESOLVED_VALUE) {\n\t\tthrow new Error('Timed out');\n\t}\n\n\treturn resolvedValue;\n}\n","/* eslint-disable no-bitwise */\n\n/**\n * Calculate the bitwise AND of 2 `number`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5, 3];\n *\n * array.reduce(Bitwise.and); // 1\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise AND of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function and(a: number, b: number): number;\n/**\n * Calculate the bitwise AND of 2 `bigint`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5n, 3n];\n *\n * array.reduce(Bitwise.and); // 1n\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise AND of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function and(a: bigint, b: bigint): bigint;\nexport function and<T extends number>(a: T, b: T): T {\n\treturn (a & b) as T;\n}\n","/* eslint-disable no-bitwise */\n\n/**\n * Calculate the bitwise OR of 2 `number`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5, 3];\n *\n * array.reduce(Bitwise.or); // 7\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise OR of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function or(a: number, b: number): number;\n/**\n * Calculate the bitwise OR of 2 `bigint`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5n, 3n];\n *\n * array.reduce(Bitwise.or); // 7n\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise OR of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function or(a: bigint, b: bigint): bigint;\nexport function or<T extends number>(a: T, b: T): T {\n\treturn (a | b) as T;\n}\n","/* eslint-disable no-bitwise */\n\n/**\n * Calculate the bitwise XOR of 2 `number`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5, 3];\n *\n * array.reduce(Bitwise.xor); // 6\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise XOR of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function xor(a: number, b: number): number;\n/**\n * Calculate the bitwise XOR of 2 `bigint`s.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5n, 3n];\n *\n * array.reduce(Bitwise.xor); // 6n\n * ```\n *\n * @param a - First operand\n * @param b - Second operand\n *\n * @returns The bitwise XOR of `a` and `b`\n *\n * @public\n * @category Reducers\n */\nexport function xor(a: bigint, b: bigint): bigint;\nexport function xor<T extends number>(a: T, b: T): T {\n\treturn (a ^ b) as T;\n}\n","import type {Comparable} from '../types';\n\n/**\n * Get the largest value of the 2 parameters.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * array.reduce(max); // 3\n * ```\n *\n * @param previousValue - Current largest value seen\n * @param currentValue - The next value to compare\n *\n * @returns `previousValue` or `currentValue`, whichever is larger\n *\n * @public\n * @category Reducers\n */\nexport function max<A extends Comparable, B extends Comparable>(accumulator: A, currentValue: B): A | B {\n\treturn (currentValue as unknown as A)! > accumulator! ? currentValue : accumulator;\n}\n","import type {Comparable} from '../types';\n\n/**\n * Get the lowest value of the 2 parameters.\n * Meant to be used with `Array.prototype.reduce`.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [1, 2, 3];\n *\n * array.reduce(min); // 1\n * ```\n *\n * @param previousValue - Current lowest value seen\n * @param currentValue - The next value to compare\n *\n * @returns `previousValue` or `currentValue`, whichever is lower\n *\n * @public\n * @category Reducers\n */\nexport function min<A extends Comparable, B extends Comparable>(accumulator: A, currentValue: B): A | B {\n\treturn (currentValue as unknown as A)! < accumulator! ? currentValue : accumulator;\n}\n","/**\n * Combines several regular expressions into a new one that matches any of them.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * regExpUnion(/[a-z]/, /\\d/); // /([a-z])|(\\d)/\n * ```\n *\n * @param regExps - Regular expressions to get the union of\n *\n * @returns A new regular expression\n *\n * @public\n * @category Regular expressions\n */\nexport function regExpUnion(...regExps: RegExp[]): RegExp {\n\treturn new RegExp(regExps.map(regExp => `(${regExp.source})`).join('|'));\n}\n","import type {Comparable, CompareFn} from '../../types';\n\nfunction ascendingRaw(a: Comparable, b: Comparable): number {\n\t// `null` is converted to 0 in comparisons\n\tif (a! < b!) {\n\t\treturn -1;\n\t}\n\n\tif (a! > b!) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\n/**\n * Sort an array in ascending order (least to greatest), while applying a function to each element to map the value before comparing.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [{ value: 2 }, { value: 3 }, { value: 1 }, { value: 3 }];\n *\n * array.sort(Sort.ascending(x => x.value));\n * ```\n *\n * @param predicate - A function that maps elements from type `T` to a {@link Comparable | `Comparable`}\n *\n * @returns A compare function that returns a negative value if first argument is less than second argument, zero if they're equal and a positive value otherwise\n *\n * @public\n * @category Sort\n */\nexport function ascending<T>(predicate: (element: T) => Comparable): CompareFn<T>;\n/**\n * Sort an array in ascending order (least to greatest).\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5, 3, 2, 4, 1];\n *\n * array.sort(Sort.ascending);\n * ```\n *\n * @param a - Element to compare\n * @param b - Element to compare\n *\n * @returns A negative value if first argument is less than second argument, zero if they're equal and a positive value otherwise\n *\n * @public\n * @category Sort\n */\nexport function ascending(a: Comparable, b: Comparable): number;\nexport function ascending<T>(aOrPredicate: Comparable | ((element: T) => Comparable), b: Comparable | void): number | CompareFn<T> {\n\tif (b === undefined && typeof aOrPredicate === 'function') {\n\t\treturn (a2: T, b2: T) => ascendingRaw(aOrPredicate(a2), aOrPredicate(b2));\n\t}\n\n\treturn ascendingRaw(aOrPredicate as Comparable, b as Comparable);\n}\n","import type {Comparable, CompareFn} from '../../types';\n\nfunction descendingRaw(a: Comparable, b: Comparable): number {\n\t// `null` is converted to 0 in comparisons\n\tif (a! < b!) {\n\t\treturn 1;\n\t}\n\n\tif (a! > b!) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}\n\n/**\n * Sort an array in descending order (greatest to least), while applying a function to each element to map the value before comparing.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [{ value: 2 }, { value: 3 }, { value: 1 }, { value: 3 }];\n *\n * array.sort(Sort.descending(x => x.value));\n * ```\n *\n * @param predicate - A function that maps elements from type `T` to a {@link Comparable | `Comparable`}\n *\n * @returns A compare function that returns a positive value if first argument is less than second argument, zero if they're equal and a negative value otherwise\n *\n * @public\n * @category Sort\n */\nexport function descending<T>(predicate: (element: T) => Comparable): CompareFn<T>;\n/**\n * Sort an array in descending order (greatest to least).\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const array = [5, 3, 2, 4, 1];\n *\n * array.sort(Sort.descending);\n * ```\n *\n * @param a - Element to compare\n * @param b - Element to compare\n *\n * @returns A positive value if first argument is less than second argument, zero if they're equal and a negative value otherwise\n *\n * @public\n * @category Sort\n */\nexport function descending(a: Comparable, b: Comparable): number;\nexport function descending<T>(aOrPredicate: Comparable | ((element: T) => Comparable), b: Comparable | void): number | CompareFn<T> {\n\tif (b === undefined && typeof aOrPredicate === 'function') {\n\t\treturn (a2: T, b2: T) => descendingRaw(aOrPredicate(a2), aOrPredicate(b2));\n\t}\n\n\treturn descendingRaw(aOrPredicate as Comparable, b as Comparable);\n}\n","import {type CompareFn} from '../../types';\n\n/**\n * Sort an array using multiple compare functions.\n * Elements are sorted which each compare function in the order they were provided.\n * If two elements are equal according to a compare function, the next compare function is used.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * const array = [\n *   {a: 1, b: 2},\n *   {a: 1, b: 1},\n *   {a: 2, b: 2},\n *   {a: 2, b: 1},\n * ];\n *\n * array.sort(\n *   Sort.combine(\n *     Sort.descending(x => x.b),\n *     Sort.descending(x => x.a),\n *   ),\n * );\n *\n * console.log(array);\n * [\n *   {a: 2, b: 2},\n *   {a: 1, b: 2},\n *   {a: 2, b: 1},\n *   {a: 1, b: 1},\n * ]\n * ```\n *\n * @param compareFns - Compare functions to use\n *\n * @returns A compare function that combines the provided compare functions\n *\n * @public\n * @category Sort\n */\nexport function combine<T>(...compareFns: ReadonlyArray<CompareFn<T>>): CompareFn<T> {\n\treturn (a, b) => {\n\t\tfor (const compareFn of compareFns) {\n\t\t\tconst result = compareFn(a, b);\n\n\t\t\tif (result > 0 || result < 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\treturn 0;\n\t};\n}\n","import type {CompareFn} from '../types';\n\n/**\n * Check whether an array is sorted according to a given compare function.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * import { Sort } from '@jonahsnider/util';\n *\n * const array = [1, 2, 3, 4, 5];\n *\n * isSorted(array, (a, b) => a - b);\n * ```\n *\n * @param array - Array to check\n * @param compareFn - Function to compare elements\n *\n * @returns Whether the array is sorted according to the given compare function\n *\n * @public\n * @category Sort\n */\nexport function isSorted<T>(array: ArrayLike<T>, compareFn: CompareFn<T>): boolean {\n\tfor (let index = 0; index < array.length - 1; index++) {\n\t\tconst element = array[index];\n\t\tconst next = array[index + 1];\n\n\t\tif (compareFn(element, next) > 0) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","import type {CompareFn} from '../types';\n\n/**\n * Sort an object's keys by comparing their respective values.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * import { Sort } from '@jonahsnider/util';\n *\n * const object = { a: 3, c: 1, b: 2 };\n *\n * Object.fromEntries(sortObject(object, Sort.ascending));\n * ```\n *\n * @param object - Object to sort\n * @param compareFn - Function used to compare object values\n *\n * @returns A new object with the keys in order\n *\n * @public\n * @category Sort\n */\nexport function sortObject<K extends PropertyKey, V>(object: Readonly<Record<K, V>>, compareFn: CompareFn<V>): Array<[K, V]> {\n\treturn Object.entries<V>(object).sort(([, aValue], [, bValue]) => compareFn(aValue, bValue)) as Array<[K, V]>;\n}\n","/* eslint-disable n/prefer-global/process */\n\n/**\n * Helper to record the amount of time elapsed between 2 points during execution.\n *\n * @example\n * ```js\n * const stopwatch = new Stopwatch();\n *\n * stopwatch.start();\n *\n * const elapsed = stopwatch.end();\n * ```\n *\n * @example\n * ```js\n * const stopwatch = Stopwatch.start();\n *\n * const elapsed = stopwatch.end();\n * ```\n *\n * @public\n */\nexport class Stopwatch {\n\t/**\n\t * Create a new stopwatch and start it.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const stopwatch = Stopwatch.start();\n\t * ```\n\t */\n\tstatic start(): Stopwatch {\n\t\tconst stopwatch = new this();\n\n\t\tstopwatch.start();\n\n\t\treturn stopwatch;\n\t}\n\n\tprivate startTime?: bigint;\n\n\t/**\n\t * If this stopwatch was started at any some point.\n\t * This will return `true` even if the stopwatch is stopped.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const stopwatch = new Stopwatch();\n\t * console.log(stopwatch.started); // false\n\t *\n\t * stopwatch.start();\n\t * console.log(stopwatch.started); // true\n\t * ```\n\t */\n\tget started(): boolean {\n\t\treturn this.startTime !== undefined;\n\t}\n\n\t/**\n\t * Start recording the duration of this stopwatch.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * stopwatch.start();\n\t * ```\n\t */\n\tstart(): void {\n\t\tthis.startTime = process.hrtime.bigint();\n\t}\n\n\t/**\n\t * Return the duration elapsed since the start.\n\t *\n\t * Time complexity: _O(1)_\n\t *\n\t * Space complexity: _O(1)_\n\t *\n\t * @example\n\t * ```js\n\t * const elapsed = stopwatch.end();\n\t * ```\n\t *\n\t * @returns The amount of time elapsed in milliseconds.\n\t */\n\tend(): number {\n\t\tif (this.startTime === undefined) {\n\t\t\tthrow new Error('This Stopwatch was not started');\n\t\t}\n\n\t\treturn Number(process.hrtime.bigint() - this.startTime) / 1_000_000;\n\t}\n}\n","/**\n * Capitalizes the first letter of a string.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * capitalize('hello'); // 'Hello'\n * ```\n *\n * @param text - Text to capitalize\n *\n * @see {@link uncapitalize} for the inverse operation\n *\n * @returns Capitalized string\n *\n * @public\n * @category String\n */\nexport function capitalize<T extends string>(text: T): Capitalize<T> {\n\tconst firstCharacter = text.charAt(0).toUpperCase();\n\n\treturn `${firstCharacter}${text.slice(firstCharacter.length)}` as Capitalize<T>;\n}\n","import {identical} from '../identical';\nimport {frequencyTable} from '../iterable';\n\n/**\n * Check if 2 strings are anagrams of each other.\n * Case-sensitive.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * isAnagram('abc', 'cba'); // true\n * ```\n *\n * @example\n * ```js\n * isAnagram('abc', 'Cba'); // false\n * ```\n *\n * @param a - First string to compare\n * @param b - Second string to compare\n *\n * @returns Whether the strings are anagrams of each other\n *\n * @public\n * @category String\n */\nexport function isAnagram<T>(a: ArrayLike<T> & Iterable<T>, b: ArrayLike<T> & Iterable<T>): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\tconst aFreqTable = frequencyTable(a);\n\tconst bFreqTable = frequencyTable(b);\n\n\treturn identical(aFreqTable, bFreqTable);\n}\n","const notWhitespaceRegExp = /\\S/;\n\n/**\n * Check whether a string is empty or whitespace.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * isWhitespace(' \\n '); // true\n * ```\n *\n * @example\n * ```js\n * isWhitespace(''); // true\n * ```\n *\n * @param string - String to check\n *\n * @returns Whether the string is whitespace\n *\n * @public\n * @category String\n */\nexport function isWhitespace(string: string): boolean {\n\treturn !notWhitespaceRegExp.test(string);\n}\n","const LINE_REG_EXP = /\\r\\n?|\\n/gim;\n\n/**\n * Get each line in a string.\n * Works with LF and CRLF line endings.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * lines('a\\nb\\r\\nc'); // ['a', 'b', 'c']\n * ```\n *\n * @param string - String to get the lines of\n *\n * @returns An array of lines\n *\n * @public\n * @category String\n */\nexport function lines(string: string): string[] {\n\treturn string.split(LINE_REG_EXP)!;\n}\n","/**\n * A string replacement function, but specialized for doing multiple replacements in a single pass through the input string.\n *\n * Based off [Nim's `strutils.multiReplace`](https://nim-lang.org/docs/strutils.html#multiReplace%2Cstring%2Cvarargs%5B%5D).\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * multiReplace('a b c', {a: 'c', c: 'a'}); // 'c b a'\n * ```\n *\n * @param string - The string to replace values in\n * @param replacements - An object of replacements where keys are the search values and values are the replacement values\n *\n * @returns A new string with the replacements applied\n *\n * @public\n * @category String\n */\nexport function multiReplace(string: string, replacements: Record<string, string>): string {\n\tconst replacementsIterable: Iterable<[sub: string, by: string]> = Object.entries(replacements);\n\tlet result = '';\n\tlet index = 0;\n\n\twhile (index < string.length) {\n\t\t/* eslint-disable no-labels */\n\t\tfoundReplace: {\n\t\t\tfor (const [searchValue, replaceValue] of replacementsIterable) {\n\t\t\t\tif (string.slice(index).startsWith(searchValue)) {\n\t\t\t\t\tresult += replaceValue;\n\t\t\t\t\tindex += searchValue.length;\n\t\t\t\t\tbreak foundReplace;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult += string[index++];\n\t\t}\n\t\t/* eslint-enable no-labels */\n\t}\n\n\treturn result;\n}\n","/**\n * Truncate text to a certain length, optionally appending a suffix when truncated.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * truncate('hello, world', 5, '...'); // 'hello...'\n * ```\n *\n * @param text - Text to truncate\n * @param maxLength - Maximum length before text is truncated\n * @param suffix - Suffix to append if text was truncated\n *\n * @returns Truncated text\n *\n * @public\n * @category String\n */\nexport function truncate<T extends string>(text: T, maxLength: number, suffix = ''): T | `${string}${typeof suffix}` {\n\tif (text.length > maxLength) {\n\t\treturn `${text.slice(0, maxLength)}${suffix}`;\n\t}\n\n\treturn text;\n}\n","/**\n * Uncapitalizes the first letter of a string.\n *\n * Time complexity: _O(n)_\n *\n * Space complexity: _O(n)_\n *\n * @example\n * ```js\n * uncapitalize('HELLO'); // hELLO\n * ```\n *\n * @param text - Text to uncapitalize\n *\n * @see {@link capitalize} for the inverse operation\n *\n * @returns Uncapitalized string\n *\n * @public\n * @category String\n */\nexport function uncapitalize<T extends string>(text: T): Uncapitalize<T> {\n\tconst firstCharacter = text.charAt(0).toLowerCase();\n\n\treturn `${firstCharacter}${text.slice(firstCharacter.length)}` as Uncapitalize<T>;\n}\n","/**\n * Round a number to n digits of precision after the decimal point.\n *\n * Time complexity: _O(1)_\n *\n * Space complexity: _O(1)_\n *\n * @example\n * ```js\n * const value = 12.345;\n *\n * toDigits(value, 2); // 12.35\n * ```\n *\n * @param value - Value to format\n * @param precision - Number of digits of precision after the decimal point\n *\n * @returns Number rounded to the specified number of digits\n *\n * @public\n */\nexport function toDigits(value: number, precision: number): number {\n\tconst factor = 10 ** precision;\n\n\treturn Math.round(value * factor * (1 + Number.EPSILON)) / factor;\n}\n"],"names":["Range","from","iterable","lower","upper","constructor","this","RangeError","has","value","Symbol","iterator","isSuperrange","range","isSubrange","equals","intersects","informational","Object","freeze","success","redirects","clientErrors","serverErrors","Method","Status","StatusName","Rank","Suit","binarySearch","array","directionFn","left","right","length","index","Math","trunc","direction","undefined","fill","Array","findIndexAll","predicate","indexes","push","firstIndexOfLastGroup","firstIndex","holes","result","indexOfAll","searchElement","largeToSmall","a","b","key","mapFill","valueFn","_","i","overwrite","startIndex","data","splice","allDuplicates","seen","Set","element","add","chunk","arrayOrIterable","size","isArray","slice","ceil","chunkArray","chunkIterable","concatIterables","iterables","count","filterPredicate","cycle","times","duplicates","every","find","first","take","firstIterable","frequencyTable","frequencies","Map","newOccurrences","get","set","includes","isEmpty","iteratorToIterable","join","separator","next","previous","done","lastIndexOfFirstGroup","mapRepeat","partition","passed","failed","increment","repeat","skip","some","padEnd","maxLength","fillValue","padStart","unshift","pull","indexOf","pullAll","reverse","pulled","replace","replacement","replaceAll","timesReplaced","sample","floor","random","shuffle","mutate","target","index1","index2","trimEnd","base","toTrim","trimStart","AutoPercentage","_count","percentage","toPrimitive","newDeck","rank","Ace","suit","Clubs","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King","Diamonds","Hearts","Spades","lookup","WeakMap","enumHas","Enum","values","maxColumnLength","table","lengths","map","column","row","columnLength","entries","formatTable","delimiter","maxLengths","invert","fn","parameters","not","thunkify","wasCalled","identical","identicalArray","identicalSet","identicalMap","same","iterators","item","nexts","DefaultMap","defaultValueOrDefaultValueFn","super","defaultValueIsFunction","MathMap","addend","newValue","subtract","subtrahend","multiply","multiplicand","divide","divisor","pow","exponent","sqrt","root","clamp","min","max","product","geometricMean","reduce","harmonicMean","accumulator","x","sum","mean","summed","BigInt","median","isEven","middleIndex","mode","maxOccurrences","modes","occurrences","normaldist","standardDeviation","E","randomInt","variance","meanValue","stddev","relativeStddev","standardNormaldist","triangularNumber","nullish","name","ctorOrFunc","func","difference","delete","jaccardIndex","intersectionSize","largest","smallest","omit","object","keys","keptKeys","filter","String","fromEntries","pick","rename","oldKey","newKey","async","settled","promise","error","DELAY_RESOLVED_VALUE","timeout","timeoutMs","timer","timeoutPromise","ms","Promise","resolve","setTimeout","delay","resolvedValue","race","finally","clearTimeout","Error","currentValue","regExpUnion","regExps","RegExp","regExp","source","ascendingRaw","descendingRaw","aOrPredicate","a2","b2","compareFns","compareFn","isSorted","sortObject","sort","aValue","bValue","Stopwatch","start","stopwatch","started","startTime","process","hrtime","bigint","end","Number","capitalize","text","firstCharacter","charAt","toUpperCase","isAnagram","notWhitespaceRegExp","isWhitespace","string","test","LINE_REG_EXP","lines","split","multiReplace","replacements","replacementsIterable","foundReplace","searchValue","replaceValue","startsWith","truncate","suffix","uncapitalize","toLowerCase","toDigits","precision","factor","round","EPSILON"],"mappings":"MAOaA,EAiBZ,WAAOC,CAAKC,GACX,MAAOC,EAAOC,GAASF,EAEvB,OAAO,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