@koine/utils 2.0.0-beta.132 → 2.0.0-beta.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/Defer.d.ts +14 -0
  2. package/Emitter.d.ts +20 -0
  3. package/accentsSets.d.ts +14 -0
  4. package/addOrReplaceAtIdx.d.ts +7 -0
  5. package/areEqual.d.ts +15 -0
  6. package/arrayFilterFalsy.d.ts +6 -0
  7. package/arrayFindLastIndex.d.ts +13 -0
  8. package/arrayOfAll.d.ts +22 -0
  9. package/arraySum.d.ts +6 -0
  10. package/arrayToLookup.d.ts +5 -0
  11. package/arrayUniqueByProperties.d.ts +8 -0
  12. package/buildUrlQueryString.d.ts +9 -0
  13. package/capitalize.d.ts +7 -0
  14. package/changeCaseCamel.d.ts +7 -0
  15. package/changeCaseCapital.d.ts +7 -0
  16. package/changeCaseConstant.d.ts +7 -0
  17. package/changeCaseDot.d.ts +7 -0
  18. package/changeCaseHelpers.d.ts +22 -0
  19. package/changeCaseKebab.d.ts +7 -0
  20. package/changeCaseNone.d.ts +7 -0
  21. package/changeCasePascal.d.ts +7 -0
  22. package/changeCasePascalSnake.d.ts +7 -0
  23. package/changeCasePath.d.ts +7 -0
  24. package/changeCaseSentence.d.ts +7 -0
  25. package/changeCaseSnake.d.ts +7 -0
  26. package/changeCaseTrain.d.ts +7 -0
  27. package/chunkByChunks.d.ts +5 -0
  28. package/chunkBySize.d.ts +4 -0
  29. package/clamp.d.ts +6 -0
  30. package/clsx.d.ts +6 -0
  31. package/convertRange.d.ts +14 -0
  32. package/cookie.d.ts +45 -0
  33. package/createPalette.d.ts +12 -0
  34. package/debounce.d.ts +6 -0
  35. package/debouncePromise.d.ts +17 -0
  36. package/debounceRaf.d.ts +6 -0
  37. package/decode.d.ts +4 -0
  38. package/encode.d.ts +4 -0
  39. package/ensureInt.d.ts +5 -0
  40. package/errorToString.d.ts +6 -0
  41. package/escapeRegExp.d.ts +7 -0
  42. package/findDuplicatedIndexes.d.ts +3 -0
  43. package/forin.d.ts +6 -0
  44. package/gbToBytes.d.ts +5 -0
  45. package/getEmptyArray.d.ts +6 -0
  46. package/getKeys.d.ts +8 -0
  47. package/getMediaQueryWidthResolvers.d.ts +6 -0
  48. package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
  49. package/getNonce.d.ts +4 -0
  50. package/getParamAmong.d.ts +11 -0
  51. package/getParamAsInt.d.ts +10 -0
  52. package/getParamAsString.d.ts +9 -0
  53. package/getType.d.ts +15 -0
  54. package/getUrlHashParams.d.ts +6 -0
  55. package/getUrlHashPathname.d.ts +7 -0
  56. package/getUrlPathnameParts.d.ts +10 -0
  57. package/getUrlQueryParams.d.ts +10 -0
  58. package/hashAny.d.ts +17 -0
  59. package/imgEmptyPixel.d.ts +5 -0
  60. package/index.d.ts +3 -0
  61. package/invariant.d.ts +17 -0
  62. package/isAbsoluteUrl.d.ts +9 -0
  63. package/isAnyObject.d.ts +5 -0
  64. package/isArray.d.ts +5 -0
  65. package/isBlob.d.ts +5 -0
  66. package/isBoolean.d.ts +5 -0
  67. package/isBrowser.d.ts +4 -0
  68. package/isBrowserNow.d.ts +4 -0
  69. package/isDate.d.ts +5 -0
  70. package/isEmptyArray.d.ts +5 -0
  71. package/isEmptyObject.d.ts +5 -0
  72. package/isEmptyString.d.ts +5 -0
  73. package/isError.d.ts +5 -0
  74. package/isExternalUrl.d.ts +7 -0
  75. package/isFile.d.ts +5 -0
  76. package/isFloat.d.ts +5 -0
  77. package/isFormData.d.ts +5 -0
  78. package/isFullArray.d.ts +5 -0
  79. package/isFullObject.d.ts +5 -0
  80. package/isFullString.d.ts +5 -0
  81. package/isFunction.d.ts +5 -0
  82. package/isInt.d.ts +5 -0
  83. package/isMap.d.ts +5 -0
  84. package/isNaNValue.d.ts +5 -0
  85. package/isNegativeNumber.d.ts +5 -0
  86. package/isNull.d.ts +5 -0
  87. package/isNullOrUndefined.d.ts +5 -0
  88. package/isNumber.d.ts +7 -0
  89. package/isNumericLiteral.d.ts +8 -0
  90. package/isObject.d.ts +5 -0
  91. package/isObjectLike.d.ts +7 -0
  92. package/isObjectStringKeyed.d.ts +9 -0
  93. package/isOneOf.d.ts +3 -0
  94. package/isPlainObject.d.ts +5 -0
  95. package/isPositiveNumber.d.ts +5 -0
  96. package/isPrimitive.d.ts +5 -0
  97. package/isPromise.d.ts +5 -0
  98. package/isRegExp.d.ts +5 -0
  99. package/isServer.d.ts +4 -0
  100. package/isServerNow.d.ts +4 -0
  101. package/isSet.d.ts +5 -0
  102. package/isString.d.ts +5 -0
  103. package/isSymbol.d.ts +5 -0
  104. package/isType.d.ts +8 -0
  105. package/isUndefined.d.ts +5 -0
  106. package/isWeakMap.d.ts +5 -0
  107. package/isWeakSet.d.ts +5 -0
  108. package/kbToBytes.d.ts +5 -0
  109. package/location.d.ts +3 -0
  110. package/lowercase.d.ts +5 -0
  111. package/mapListBy.d.ts +5 -0
  112. package/matchSorter.d.ts +10 -0
  113. package/mbToBytes.d.ts +5 -0
  114. package/mergeObjects.d.ts +6 -0
  115. package/mergeUrlQueryParams.d.ts +5 -0
  116. package/moveSortableArrayItemByKey.d.ts +7 -0
  117. package/noop.d.ts +5 -0
  118. package/normaliseUrl.d.ts +9 -0
  119. package/normaliseUrlPathname.d.ts +8 -0
  120. package/objectFlat.d.ts +8 -0
  121. package/objectFlip.d.ts +4 -0
  122. package/objectMergeWithDefaults.d.ts +10 -0
  123. package/objectOmit.d.ts +9 -0
  124. package/objectPick.d.ts +6 -0
  125. package/objectSort.d.ts +8 -0
  126. package/objectSortByKeysMatching.d.ts +9 -0
  127. package/objectToArray.d.ts +6 -0
  128. package/package.json +1 -1
  129. package/parseCookie.d.ts +8 -0
  130. package/parseURL.d.ts +6 -0
  131. package/quaranteneProps.d.ts +15 -0
  132. package/randomInt.d.ts +5 -0
  133. package/randomKey.d.ts +6 -0
  134. package/readCookie.d.ts +5 -0
  135. package/removeAccents.d.ts +3 -0
  136. package/removeCookie.d.ts +3 -0
  137. package/removeDuplicates.d.ts +8 -0
  138. package/removeDuplicatesByKey.d.ts +6 -0
  139. package/removeDuplicatesComparing.d.ts +3 -0
  140. package/removeIndexesFromArray.d.ts +3 -0
  141. package/removeTrailingSlash.d.ts +5 -0
  142. package/removeUrlQueryParams.d.ts +5 -0
  143. package/render.d.ts +40 -0
  144. package/round.d.ts +11 -0
  145. package/roundTo.d.ts +6 -0
  146. package/serializeCookie.d.ts +20 -0
  147. package/setCookie.d.ts +3 -0
  148. package/shuffle.d.ts +15 -0
  149. package/slugify.d.ts +10 -0
  150. package/split.d.ts +6 -0
  151. package/splitReverse.d.ts +6 -0
  152. package/swapMap.d.ts +5 -0
  153. package/throttle.d.ts +6 -0
  154. package/titleCase.d.ts +5 -0
  155. package/toNumber.d.ts +5 -0
  156. package/toRgba.d.ts +5 -0
  157. package/transformToUrlPathname.d.ts +9 -0
  158. package/truncate.d.ts +5 -0
  159. package/tryUntil.d.ts +9 -0
  160. package/types.d.ts +27 -0
  161. package/uid.d.ts +5 -0
  162. package/updateLinkParams.d.ts +7 -0
  163. package/updateUrlQueryParams.d.ts +5 -0
  164. package/uppercase.d.ts +6 -0
  165. package/uuid.d.ts +6 -0
  166. package/uuidNumeric.d.ts +4 -0
  167. package/wait.d.ts +5 -0
package/Defer.d.ts CHANGED
@@ -1,8 +1,22 @@
1
+ /**
2
+ * @category async
3
+ */
1
4
  export type Deferred<T> = Promise<T> & {
2
5
  resolve: (value: T | PromiseLike<T>) => void;
3
6
  reject: (value: T | PromiseLike<T>) => void;
4
7
  catch: Promise<T>["catch"];
5
8
  };
9
+ /**
10
+ * @category async
11
+ * @see https://stackoverflow.com/a/37673534/1938970
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * const deferred = Defer();
16
+ * deferred.resolve();
17
+ * deferred.then(handleSuccess, handleError);
18
+ * ```
19
+ */
6
20
  export declare function Defer<T>(this: Promise<T> & {
7
21
  promise: Promise<T>;
8
22
  resolve: (value: T | PromiseLike<T>) => void;
package/Emitter.d.ts CHANGED
@@ -1,7 +1,27 @@
1
+ /**
2
+ * Emitter super simple class
3
+ *
4
+ * Events will be prefixed with the given `namespace` plus a `.` so:
5
+ * `{namespace}.myevent`
6
+ *
7
+ * Adapted from https://github.com/developit/mitt
8
+ *
9
+ * Regarding typescript support see:
10
+ * - https://stackoverflow.com/q/53299743/1938970
11
+ * - https://github.com/Microsoft/TypeScript/pull/26349
12
+ *
13
+ * @category impl
14
+ */
1
15
  export declare let Emitter: <EventMap extends {
2
16
  [key: string]: any;
3
17
  }>(namespace: string) => {
18
+ /**
19
+ * Register an event handler for the given type.
20
+ */
4
21
  on<EventName extends keyof EventMap>(name: EventName, handler: (data?: EventMap[EventName]) => any): void;
22
+ /**
23
+ * Invoke all handlers for the given type.
24
+ */
5
25
  emit<EventName extends keyof EventMap>(name: EventName, data?: EventMap[EventName]): void;
6
26
  };
7
27
  export default Emitter;
package/accentsSets.d.ts CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * First value is the `to`, second is `from`, from *which* chars do we translates *to*
3
+ *
4
+ * @category text
5
+ */
1
6
  export type AccentsSet = [string, string];
7
+ /**
8
+ * Accent sets
9
+ *
10
+ * @category text
11
+ * @resources
12
+ * - https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
13
+ * - https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
14
+ * of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
15
+ */
2
16
  export declare let accentsSets: AccentsSet[];
3
17
  export default accentsSets;
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Add or replace an item in the given array, it returns a new array (immutable).
3
+ * Typescript wise this is meant to keep the same type on the newly returned
4
+ * array, therefore the `newItem` must match the type of the `list` items.
5
+ *
6
+ * @category array
7
+ */
1
8
  export declare let addOrReplaceAtIdx: <T>(list: T[], newItem: T, newIdx?: number) => T[];
2
9
  export default addOrReplaceAtIdx;
package/areEqual.d.ts CHANGED
@@ -1,4 +1,19 @@
1
1
  type ComparablePrimitive = string | number | boolean;
2
2
  type Comparable = ComparablePrimitive | object | Record<string, ComparablePrimitive> | Array<ComparablePrimitive>;
3
+ /**
4
+ * A simple and quick deep equal objects utility. This is meant to be used
5
+ * solely to deduplicate requests payload and perform comparison on JSON ready
6
+ * objects made of primitives `string`, `number` and `boolean`s.
7
+ *
8
+ * It support nested `object`s and `array`s only.
9
+ *
10
+ * NB: `undefined` and `null` values do not count in the comparison as they are
11
+ * usually meant to be ignored in JSON requestBody payloads.
12
+ *
13
+ * According to very rudimentary tests this function takes on average between
14
+ * 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
15
+ *
16
+ * @category object
17
+ */
3
18
  export declare let areEqual: (a: Comparable, b?: Comparable) => boolean;
4
19
  export default areEqual;
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Given a list it returns it filtered without any falsy values (`null`,
3
+ * `undefined`, `false`, `0`, `""`). It "adjusts" the returned type as well.
4
+ *
5
+ * @category array
6
+ */
1
7
  export declare let arrayFilterFalsy: <T extends unknown[]>(list?: null | T) => Exclude<NonNullable<T>[number], undefined | false | 0 | "">[];
2
8
  export default arrayFilterFalsy;
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Returns the index of the last element in the array where predicate is true, and -1
3
+ * otherwise.
4
+ *
5
+ * @borrows [SO's answer by Nico Timmerman](https://stackoverflow.com/a/53187807/1938970)
6
+ *
7
+ * @category array
8
+ *
9
+ * @param array The source array to search in
10
+ * @param predicate find calls predicate once for each element of the array, in descending
11
+ * order, until it finds one where predicate returns true. If such an element is found,
12
+ * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
13
+ */
1
14
  export declare let arrayFindLastIndex: <T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean) => number;
2
15
  export default arrayFindLastIndex;
package/arrayOfAll.d.ts CHANGED
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Ensure an array contains all desired values
3
+ *
4
+ * @category array
5
+ * @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
6
+ *
7
+ * @usage
8
+ * ```ts
9
+ * type Fruit = "pear" | "apple" | "orange";
10
+ *
11
+ * const arrayOfAllFruits = arrayOfAll<Fruit>();
12
+ *
13
+ * const allFruits = arrayOfAllFruits([ "pear", "apple", "orange" ]); // ts compiler ok
14
+ * const allFruits = arrayOfAllFruits([ "pear", "apple" ]); // ts compiler fails
15
+ * ```
16
+ */
1
17
  export declare let arrayOfAll: <T>() => <U extends T[]>(array: U & ([T] extends [U[number]] ? unknown : "Invalid")) => U & ([T] extends [U[number]] ? unknown : "Invalid");
18
+ /**
19
+ * @usage
20
+ * ```ts
21
+ * type Check_AreAllListed = AssertTrue<ArrayOfAll<typeof myList, MyUnion>>;
22
+ * ```
23
+ */
2
24
  export type ArrayOfAll<List extends unknown[], Union> = List[number] extends Union ? Union extends List[number] ? true : "Incomplete" : "Incomplete";
3
25
  export default arrayOfAll;
package/arraySum.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Sum array of numbers
3
+ *
4
+ * @category array
5
+ * @category math
6
+ */
1
7
  export declare let arraySum: (numbers: number[]) => number;
2
8
  export default arraySum;
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Maps a simple flat array to a lookup dictionary object
3
+ *
4
+ * @category array
5
+ */
1
6
  export declare let arrayToLookup: <T extends string | number | symbol>(array?: T[]) => Record<T, 1>;
2
7
  export default arrayToLookup;
@@ -1,2 +1,10 @@
1
+ /**
2
+ * @borrows [SO answer](https://stackoverflow.com/a/56757215/1938970)
3
+ *
4
+ * @category array
5
+ * @param array The array to filter
6
+ * @param keys The keys to compare in each array item
7
+ * @returns The filtered array
8
+ */
1
9
  export declare let arrayUniqueByProperties: <T extends any[]>(array: T, keys: (keyof T[number])[]) => T;
2
10
  export default arrayUniqueByProperties;
@@ -1,3 +1,12 @@
1
1
  import type { AnyQueryParams } from "./location";
2
+ /**
3
+ * Get clean query string for URL
4
+ *
5
+ * It returns the query string **with** the initial `?`
6
+ *
7
+ * TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
8
+ *
9
+ * @category location
10
+ */
2
11
  export declare let buildUrlQueryString: <T extends AnyQueryParams>(params: T) => string;
3
12
  export default buildUrlQueryString;
package/capitalize.d.ts CHANGED
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Capitalize first letter of the given string.
3
+ *
4
+ * @category text
5
+ * @resources
6
+ * - https://stackoverflow.com/a/11409944/1938970
7
+ */
1
8
  export declare let capitalize: <T extends string>(string?: null | T) => Capitalize<T>;
2
9
  export default capitalize;
@@ -1,3 +1,10 @@
1
1
  import { type PascalCaseOptions } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to camel case (`fooBar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseCamel: (input: string, options?: PascalCaseOptions) => string;
3
10
  export default changeCaseCamel;
@@ -1,3 +1,10 @@
1
1
  import { type Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to sentence case (`Foo Bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseCapital: (input: string, options?: Options) => string;
3
10
  export default changeCaseCapital;
@@ -1,3 +1,10 @@
1
1
  import { type Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to constant case (`FOO_BAR`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseConstant: (input: string, options?: Options) => string;
3
10
  export default changeCaseConstant;
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to dot case (`foo.bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseDot: (input: string, options?: Options) => string;
3
10
  export default changeCaseDot;
@@ -1,14 +1,36 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
5
+ */
6
+ /**
7
+ * Supported locale values. Use `false` to ignore locale.
8
+ * Defaults to `undefined`, which uses the host environment.
9
+ */
1
10
  export type Locale = string[] | string | false | undefined;
11
+ /**
12
+ * Options used for converting strings to pascal/camel case.
13
+ */
2
14
  export interface PascalCaseOptions extends Options {
3
15
  mergeAmbiguousCharacters?: boolean;
4
16
  }
17
+ /**
18
+ * Options used for converting strings to any case.
19
+ */
5
20
  export interface Options {
6
21
  locale?: Locale;
7
22
  split?: (value: string) => string[];
23
+ /** @deprecated Pass `split: splitSeparateNumbers` instead. */
8
24
  separateNumbers?: boolean;
9
25
  delimiter?: string;
10
26
  prefixCharacters?: string;
11
27
  suffixCharacters?: string;
12
28
  }
29
+ /**
30
+ * Split any cased input strings into an array of words.
31
+ */
13
32
  export declare let split: (value: string) => string[];
33
+ /**
34
+ * Split the input string into an array of words, separating numbers.
35
+ */
14
36
  export declare let splitSeparateNumbers: (value: string) => string[];
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to kebab case (`foo.bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseKebab: (input: string, options?: Options) => string;
3
10
  export default changeCaseKebab;
@@ -1,3 +1,10 @@
1
1
  import { type Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to space separated lower case (`foo bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseNone: (input: string, options?: Options) => string;
3
10
  export default changeCaseNone;
@@ -1,3 +1,10 @@
1
1
  import { type PascalCaseOptions } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to camel case (`FooBar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCasePascal: (input: string, options?: PascalCaseOptions) => string;
3
10
  export default changeCasePascal;
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to pascal snake case (`Foo_Bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCasePascalSnake: (input: string, options?: Options) => string;
3
10
  export default changeCasePascalSnake;
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to path case (`foo/bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCasePath: (input: string, options?: Options) => string;
3
10
  export default changeCasePath;
@@ -1,3 +1,10 @@
1
1
  import { type Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to sentence case (`Foo bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseSentence: (input: string, options?: Options) => string;
3
10
  export default changeCaseSentence;
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to snake case (`foo_bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseSnake: (input: string, options?: Options) => string;
3
10
  export default changeCaseSnake;
@@ -1,3 +1,10 @@
1
1
  import type { Options } from "./changeCaseHelpers";
2
+ /**
3
+ * Convert a string to train case (`Foo-Bar`).
4
+ *
5
+ * @category text
6
+ * @category case
7
+ * @borrows [blakeembrey/change-case](https://github.com/blakeembrey/change-case)
8
+ */
2
9
  export declare let changeCaseTrain: (input: string, options?: Options) => string;
3
10
  export default changeCaseTrain;
@@ -1,2 +1,7 @@
1
+ /**
2
+ * @category array
3
+ * @see https://stackoverflow.com/a/8189268/1938970
4
+ * @experimental TODO: untested
5
+ */
1
6
  export declare let chunkByChunks: <T>(arr: T[], nrOfChunks: number, balanced?: boolean) => T[][];
2
7
  export default chunkByChunks;
package/chunkBySize.d.ts CHANGED
@@ -1,2 +1,6 @@
1
+ /**
2
+ * @category array
3
+ * @see https://stackoverflow.com/a/40682136/1938970
4
+ */
1
5
  export declare let chunkBySize: <T>(arr: T[], size: number) => T[][];
2
6
  export default chunkBySize;
package/clamp.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Returns a number whose value is limited to the given range.
3
+ *
4
+ * @category math
5
+ * @see https://stackoverflow.com/a/11409944/1938970
6
+ */
1
7
  export declare let clamp: (num: number, min: number, max: number) => number;
2
8
  export default clamp;
package/clsx.d.ts CHANGED
@@ -2,5 +2,11 @@ type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null
2
2
  type ClassDictionary = Record<string, any>;
3
3
  type ClassArray = ClassValue[];
4
4
  export type ClsxClassValue = ClassValue;
5
+ /**
6
+ * Class names utility
7
+ *
8
+ * @category impl
9
+ * @borrows [lukeed/clsx](https://github.com/lukeed/clsx)
10
+ */
5
11
  export declare let clsx: (...args: ClassValue[]) => string;
6
12
  export default clsx;
package/convertRange.d.ts CHANGED
@@ -1,2 +1,16 @@
1
+ /**
2
+ * Convert range of a number
3
+ *
4
+ * e.g. converting number 5 in a scale/range from 0 10 to a scale/range from 50
5
+ * to 100 would return 75
6
+ * @example
7
+ *
8
+ * ```ts
9
+ * convertRange(5, [0, 10], [50, 100]);
10
+ * ```
11
+ *
12
+ * @category math
13
+ * @see https://stackoverflow.com/a/14224813
14
+ */
1
15
  export declare let convertRange: (num: number, r1: number[], r2: number[]) => number;
2
16
  export default convertRange;
package/cookie.d.ts CHANGED
@@ -1,15 +1,60 @@
1
+ /**
2
+ * @module
3
+ *
4
+ * @category cookie
5
+ *
6
+ * All cookie related code is inspired and adapted from:
7
+ * - [js-cookie](https://github.com/js-cookie/js-cookie)
8
+ * - [cookie](https://github.com/jshttp/cookie)
9
+ */
10
+ /**
11
+ * @category cookie
12
+ */
1
13
  type CookieAttributes = {
14
+ /**
15
+ * Define when the cookie will be removed. Value can be a Number
16
+ * which will be interpreted as days from time of creation or a
17
+ * Date instance. If omitted, the cookie becomes a session cookie.
18
+ */
2
19
  expires?: number | Date | undefined;
20
+ /**
21
+ * Define the path where the cookie is available. Defaults to '/'
22
+ *
23
+ * @default "/"
24
+ */
3
25
  path?: string | undefined;
26
+ /**
27
+ * Define the domain where the cookie is available. Defaults to
28
+ * the domain of the page where the cookie was created.
29
+ */
4
30
  domain?: string | undefined;
31
+ /**
32
+ * A Boolean indicating if the cookie transmission requires a
33
+ * secure protocol (https).
34
+ *
35
+ * @default "true"
36
+ */
5
37
  secure?: boolean | undefined;
38
+ /**
39
+ * Asserts that a cookie must not be sent with cross-origin requests,
40
+ * providing some protection against cross-site request forgery
41
+ * attacks (CSRF)
42
+ *
43
+ * @default "strict"
44
+ */
6
45
  sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
7
46
  };
47
+ /**
48
+ * @category cookie
49
+ */
8
50
  export type CookieAttributesServer = CookieAttributes & {
9
51
  maxAge?: number;
10
52
  httpOnly?: boolean;
11
53
  encode?: (input: string) => string;
12
54
  decode?: (input: string) => string;
13
55
  };
56
+ /**
57
+ * @category cookie
58
+ */
14
59
  export type CookieAttributesClient = CookieAttributes;
15
60
  export {};
@@ -6,5 +6,17 @@ type PaletteMapPair<T extends PaletteShade> = {
6
6
  type PaletteMap<T extends PaletteShades> = {
7
7
  [PS in T[number] as keyof PaletteMapPair<PS>]: PaletteMapPair<PS>[keyof PaletteMapPair<PS>];
8
8
  };
9
+ /**
10
+ * Create palette, this is primarily thought to improve the reuse of a palette
11
+ * definition between TailwindCSS and straight ES imports
12
+ *
13
+ * @category colors
14
+ * @category tailwind
15
+ * @category responsive
16
+ *
17
+ * @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
18
+ * object 3) A flat array of colors (no special sorting, same order as the `shades`
19
+ * given as argument)
20
+ */
9
21
  export declare let createPalette: <TName extends string, TShades extends PaletteShades, TColor = TShades[number][1], TMap = PaletteMap<TShades>>(name: TName, shades: TShades) => readonly [TMap, Record<`${TName}-${TShades[number][0]}`, string>, TColor[]];
10
22
  export default createPalette;
package/debounce.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Debounce function (with `setTimeout`)
3
+ *
4
+ * @category function
5
+ * @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
6
+ */
1
7
  export declare let debounce: <T extends (...args: any[]) => any>(fn: T, wait?: number, immediate?: boolean) => (this: unknown, ...args: Parameters<T>) => void;
2
8
  export default debounce;
@@ -1,11 +1,28 @@
1
+ /**
2
+ * Copy pasted from [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts)
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * @categroy functionn
8
+ */
1
9
  export type DebounceOptions<Result> = {
2
10
  isImmediate?: boolean;
3
11
  maxWait?: number;
4
12
  callback?: (data: Result) => void;
5
13
  };
14
+ /**
15
+ * @categroy functionn
16
+ */
6
17
  export interface DebouncedFunction<Args extends any[], F extends (...args: Args) => any> {
7
18
  (this: ThisParameterType<F>, ...args: Args & Parameters<F>): Promise<ReturnType<F>>;
8
19
  cancel: (reason?: any) => void;
9
20
  }
21
+ /**
22
+ * Debounce function (with `Promise`)
23
+ *
24
+ * @category function
25
+ * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
26
+ */
10
27
  export declare let debouncePromise: <Args extends any[], F extends (...args: Args) => any>(func: F, waitMilliseconds?: number, options?: DebounceOptions<ReturnType<F>>) => DebouncedFunction<Args, F>;
11
28
  export default debouncePromise;
package/debounceRaf.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Debounce function (with `requestAnimationFrame`)
3
+ *
4
+ * @category function
5
+ * @borrows [vanillajstoolkit/debounce by Chris Ferdinandi](https://vanillajstoolkit.com/helpers/debounce/)
6
+ */
1
7
  export declare function debounceRaf<T extends (...args: any[]) => any>(this: unknown, fn: T): (this: unknown, ...args: Parameters<T>) => void;
2
8
  export default debounceRaf;
package/decode.d.ts CHANGED
@@ -1,2 +1,6 @@
1
+ /**
2
+ * @category security
3
+ * @see https://stackoverflow.com/a/22405578/9122820
4
+ */
1
5
  export declare let decode: <TReturn extends string>(str: string) => TReturn;
2
6
  export default decode;
package/encode.d.ts CHANGED
@@ -1,2 +1,6 @@
1
+ /**
2
+ * @category security
3
+ * @see https://stackoverflow.com/a/22405578/9122820
4
+ */
1
5
  export declare let encode: <TReturn extends string>(str: string) => TReturn;
2
6
  export default encode;
package/ensureInt.d.ts CHANGED
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Ensure input to be an integer
3
+ *
4
+ * @category cast
5
+ */
1
6
  export declare let ensureInt: (input: string | number) => number;
2
7
  export default ensureInt;
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
3
+ *
4
+ * @category error
5
+ * @category cast
6
+ */
1
7
  export declare let errorToString: (e: unknown) => string;
2
8
  export default errorToString;
package/escapeRegExp.d.ts CHANGED
@@ -1,2 +1,9 @@
1
+ /**
2
+ * @borrows [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
3
+ * @borrows [SO's answer by Mathias Bynens](https://stackoverflow.com/a/9310752/1938970)
4
+ *
5
+ * @category escape
6
+ * @category RegExp
7
+ */
1
8
  export declare let escapeRegExp: (text: string) => string;
2
9
  export default escapeRegExp;
@@ -1,2 +1,5 @@
1
+ /**
2
+ * @category array
3
+ */
1
4
  export declare let findDuplicatedIndexes: (arr: any[]) => Record<number, true>;
2
5
  export default findDuplicatedIndexes;
package/forin.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ /**
2
+ * To easily get typed native `for in`
3
+ *
4
+ * @category native
5
+ * @category object
6
+ */
1
7
  export declare let forin: <T>(object: T, cb: <K extends keyof T>(key: K, value: T[K]) => void) => void;
2
8
  export default forin;
package/gbToBytes.d.ts CHANGED
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Gigabytes to bytes
3
+ *
4
+ * @category format
5
+ */
1
6
  export declare let gbToBytes: (bytes: number) => number;
2
7
  export default gbToBytes;