@dxyl/utils 1.0.0 → 1.1.0

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 (262) hide show
  1. package/dist/index.es.js +8985 -0
  2. package/dist/index.umd.js +28 -0
  3. package/lib/glslang/glslang.d.ts +14 -0
  4. package/lib/glslang/glslang.js +113 -0
  5. package/lib/glslang/glslang.wasm +0 -0
  6. package/lib/twgsl/twgsl.js +53 -0
  7. package/lib/twgsl/twgsl.wasm +0 -0
  8. package/package.json +27 -34
  9. package/readme.md +0 -0
  10. package/types/Color.d.ts +69 -0
  11. package/types/Options.d.ts +70 -0
  12. package/types/antv-util/color/arr2rgb.d.ts +12 -0
  13. package/types/antv-util/color/gradient.d.ts +6 -0
  14. package/types/antv-util/color/index.d.ts +4 -0
  15. package/types/antv-util/color/rgb2arr.d.ts +6 -0
  16. package/types/antv-util/color/tocssgradient.d.ts +1 -0
  17. package/types/antv-util/color/torgb.d.ts +6 -0
  18. package/types/antv-util/helper/index.d.ts +2 -0
  19. package/types/antv-util/helper/mod.d.ts +1 -0
  20. package/types/antv-util/helper/to-radian.d.ts +1 -0
  21. package/types/antv-util/index.d.ts +3 -0
  22. package/types/antv-util/matrix/index.d.ts +27 -0
  23. package/types/antv-util/path/convert/path-2-absolute.d.ts +2 -0
  24. package/types/antv-util/path/convert/path-2-curve.d.ts +2 -0
  25. package/types/antv-util/path/convert/path-2-string.d.ts +6 -0
  26. package/types/antv-util/path/index.d.ts +17 -0
  27. package/types/antv-util/path/parser/finalize-segment.d.ts +5 -0
  28. package/types/antv-util/path/parser/is-arc-command.d.ts +4 -0
  29. package/types/antv-util/path/parser/is-digit-start.d.ts +6 -0
  30. package/types/antv-util/path/parser/is-path-command.d.ts +4 -0
  31. package/types/antv-util/path/parser/is-space.d.ts +4 -0
  32. package/types/antv-util/path/parser/params-count.d.ts +13 -0
  33. package/types/antv-util/path/parser/params-parser.d.ts +10 -0
  34. package/types/antv-util/path/parser/parse-path-string.d.ts +6 -0
  35. package/types/antv-util/path/parser/path-parser.d.ts +16 -0
  36. package/types/antv-util/path/parser/scan-flag.d.ts +6 -0
  37. package/types/antv-util/path/parser/scan-param.d.ts +6 -0
  38. package/types/antv-util/path/parser/scan-segment.d.ts +6 -0
  39. package/types/antv-util/path/parser/skip-spaces.d.ts +7 -0
  40. package/types/antv-util/path/process/arc-2-cubic.d.ts +7 -0
  41. package/types/antv-util/path/process/clone-path.d.ts +2 -0
  42. package/types/antv-util/path/process/fix-arc.d.ts +2 -0
  43. package/types/antv-util/path/process/line-2-cubic.d.ts +1 -0
  44. package/types/antv-util/path/process/normalize-path.d.ts +8 -0
  45. package/types/antv-util/path/process/normalize-segment.d.ts +6 -0
  46. package/types/antv-util/path/process/quad-2-cubic.d.ts +1 -0
  47. package/types/antv-util/path/process/reverse-curve.d.ts +2 -0
  48. package/types/antv-util/path/process/round-path.d.ts +6 -0
  49. package/types/antv-util/path/process/segment-2-cubic.d.ts +2 -0
  50. package/types/antv-util/path/types.d.ts +122 -0
  51. package/types/antv-util/path/util/distance-square-root.d.ts +1 -0
  52. package/types/antv-util/path/util/equalize-segments.d.ts +2 -0
  53. package/types/antv-util/path/util/get-draw-direction.d.ts +2 -0
  54. package/types/antv-util/path/util/get-path-area.d.ts +8 -0
  55. package/types/antv-util/path/util/get-path-bbox-total-length.d.ts +5 -0
  56. package/types/antv-util/path/util/get-path-bbox.d.ts +5 -0
  57. package/types/antv-util/path/util/get-point-at-length.d.ts +5 -0
  58. package/types/antv-util/path/util/get-properties-at-length.d.ts +6 -0
  59. package/types/antv-util/path/util/get-properties-at-point.d.ts +7 -0
  60. package/types/antv-util/path/util/get-rotated-curve.d.ts +2 -0
  61. package/types/antv-util/path/util/get-total-length.d.ts +8 -0
  62. package/types/antv-util/path/util/is-absolute-array.d.ts +6 -0
  63. package/types/antv-util/path/util/is-curve-array.d.ts +9 -0
  64. package/types/antv-util/path/util/is-normalized-array.d.ts +7 -0
  65. package/types/antv-util/path/util/is-path-array.d.ts +5 -0
  66. package/types/antv-util/path/util/is-point-in-stroke.d.ts +5 -0
  67. package/types/antv-util/path/util/mid-point.d.ts +1 -0
  68. package/types/antv-util/path/util/path-length-factory.d.ts +7 -0
  69. package/types/antv-util/path/util/rotate-vector.d.ts +4 -0
  70. package/types/antv-util/path/util/segment-arc-factory.d.ts +6 -0
  71. package/types/antv-util/path/util/segment-cubic-factory.d.ts +6 -0
  72. package/types/antv-util/path/util/segment-line-factory.d.ts +6 -0
  73. package/types/antv-util/path/util/segment-quad-factory.d.ts +6 -0
  74. package/types/callbacks.d.ts +30 -0
  75. package/types/color/colord/src/colorModels/cmyk.d.ts +23 -0
  76. package/types/color/colord/src/colorModels/cmykString.d.ts +7 -0
  77. package/types/color/colord/src/colorModels/hex.d.ts +5 -0
  78. package/types/color/colord/src/colorModels/hsl.d.ts +8 -0
  79. package/types/color/colord/src/colorModels/hslString.d.ts +7 -0
  80. package/types/color/colord/src/colorModels/hsv.d.ts +6 -0
  81. package/types/color/colord/src/colorModels/hwb.d.ts +6 -0
  82. package/types/color/colord/src/colorModels/hwbString.d.ts +7 -0
  83. package/types/color/colord/src/colorModels/lab.d.ts +18 -0
  84. package/types/color/colord/src/colorModels/lch.d.ts +19 -0
  85. package/types/color/colord/src/colorModels/lchString.d.ts +7 -0
  86. package/types/color/colord/src/colorModels/rgb.d.ts +13 -0
  87. package/types/color/colord/src/colorModels/rgbString.d.ts +7 -0
  88. package/types/color/colord/src/colorModels/xyz.d.ts +30 -0
  89. package/types/color/colord/src/colord.d.ts +103 -0
  90. package/types/color/colord/src/constants.d.ts +10 -0
  91. package/types/color/colord/src/extend.d.ts +4 -0
  92. package/types/color/colord/src/get/getBrightness.d.ts +7 -0
  93. package/types/color/colord/src/get/getContrast.d.ts +6 -0
  94. package/types/color/colord/src/get/getLuminance.d.ts +6 -0
  95. package/types/color/colord/src/get/getPerceivedDifference.d.ts +24 -0
  96. package/types/color/colord/src/helpers.d.ts +20 -0
  97. package/types/color/colord/src/index.d.ts +5 -0
  98. package/types/color/colord/src/manipulate/changeAlpha.d.ts +2 -0
  99. package/types/color/colord/src/manipulate/invert.d.ts +2 -0
  100. package/types/color/colord/src/manipulate/lighten.d.ts +2 -0
  101. package/types/color/colord/src/manipulate/mix.d.ts +2 -0
  102. package/types/color/colord/src/manipulate/saturate.d.ts +2 -0
  103. package/types/color/colord/src/parse.d.ts +8 -0
  104. package/types/color/colord/src/plugins/a11y.d.ts +38 -0
  105. package/types/color/colord/src/plugins/cmyk.d.ts +24 -0
  106. package/types/color/colord/src/plugins/harmonies.d.ts +16 -0
  107. package/types/color/colord/src/plugins/hwb.d.ts +23 -0
  108. package/types/color/colord/src/plugins/lab.d.ts +23 -0
  109. package/types/color/colord/src/plugins/lch.d.ts +24 -0
  110. package/types/color/colord/src/plugins/minify.d.ts +20 -0
  111. package/types/color/colord/src/plugins/mix.d.ts +27 -0
  112. package/types/color/colord/src/plugins/names.d.ts +19 -0
  113. package/types/color/colord/src/plugins/xyz.d.ts +14 -0
  114. package/types/color/colord/src/random.d.ts +2 -0
  115. package/types/color/colord/src/types.d.ts +67 -0
  116. package/types/data/immer.d.ts +262 -0
  117. package/types/data/immutable.d.ts +5127 -0
  118. package/types/data/mobx.d.ts +154 -0
  119. package/types/data/reactivity.d.ts +755 -0
  120. package/types/data/signals.d.ts +144 -0
  121. package/types/deepmerge.d.ts +16 -0
  122. package/types/events/eventTarget.d.ts +93 -0
  123. package/types/events/event_emiter.d.ts +43 -0
  124. package/types/events/eventemitter3.d.ts +135 -0
  125. package/types/events/mitt.d.ts +21 -0
  126. package/types/fast-deep-equal.d.ts +1 -0
  127. package/types/index.d.ts +20 -0
  128. package/types/ismobilejs.d.ts +46 -0
  129. package/types/lodash/augment.d.ts +2 -0
  130. package/types/lodash/cache.d.ts +14 -0
  131. package/types/lodash/clamp.d.ts +2 -0
  132. package/types/lodash/clear-animation-frame.d.ts +1 -0
  133. package/types/lodash/clone.d.ts +2 -0
  134. package/types/lodash/contains.d.ts +2 -0
  135. package/types/lodash/debounce.d.ts +2 -0
  136. package/types/lodash/deep-mix.d.ts +2 -0
  137. package/types/lodash/difference.d.ts +11 -0
  138. package/types/lodash/each.d.ts +2 -0
  139. package/types/lodash/ends-with.d.ts +3 -0
  140. package/types/lodash/every.d.ts +7 -0
  141. package/types/lodash/extend.d.ts +2 -0
  142. package/types/lodash/filter.d.ts +2 -0
  143. package/types/lodash/find-index.d.ts +2 -0
  144. package/types/lodash/find.d.ts +3 -0
  145. package/types/lodash/first-value.d.ts +2 -0
  146. package/types/lodash/fixed-base.d.ts +2 -0
  147. package/types/lodash/flatten-deep.d.ts +12 -0
  148. package/types/lodash/flatten.d.ts +11 -0
  149. package/types/lodash/for-in.d.ts +2 -0
  150. package/types/lodash/get-range.d.ts +6 -0
  151. package/types/lodash/get-type.d.ts +2 -0
  152. package/types/lodash/get-wrap-behavior.d.ts +9 -0
  153. package/types/lodash/get.d.ts +8 -0
  154. package/types/lodash/group-by.d.ts +6 -0
  155. package/types/lodash/group-to-map.d.ts +8 -0
  156. package/types/lodash/group.d.ts +2 -0
  157. package/types/lodash/has-key.d.ts +2 -0
  158. package/types/lodash/has-value.d.ts +2 -0
  159. package/types/lodash/has.d.ts +2 -0
  160. package/types/lodash/head.d.ts +1 -0
  161. package/types/lodash/identity.d.ts +2 -0
  162. package/types/lodash/index-of.d.ts +2 -0
  163. package/types/lodash/index.d.ts +108 -0
  164. package/types/lodash/is-arguments.d.ts +2 -0
  165. package/types/lodash/is-array-like.d.ts +2 -0
  166. package/types/lodash/is-array.d.ts +2 -0
  167. package/types/lodash/is-boolean.d.ts +2 -0
  168. package/types/lodash/is-date.d.ts +2 -0
  169. package/types/lodash/is-decimal.d.ts +2 -0
  170. package/types/lodash/is-element.d.ts +6 -0
  171. package/types/lodash/is-empty.d.ts +2 -0
  172. package/types/lodash/is-equal-with.d.ts +24 -0
  173. package/types/lodash/is-equal.d.ts +2 -0
  174. package/types/lodash/is-error.d.ts +2 -0
  175. package/types/lodash/is-even.d.ts +2 -0
  176. package/types/lodash/is-finite.d.ts +1 -0
  177. package/types/lodash/is-function.d.ts +2 -0
  178. package/types/lodash/is-integer.d.ts +2 -0
  179. package/types/lodash/is-match.d.ts +2 -0
  180. package/types/lodash/is-negative.d.ts +2 -0
  181. package/types/lodash/is-nil.d.ts +2 -0
  182. package/types/lodash/is-null.d.ts +2 -0
  183. package/types/lodash/is-number-equal.d.ts +1 -0
  184. package/types/lodash/is-number.d.ts +2 -0
  185. package/types/lodash/is-object-like.d.ts +2 -0
  186. package/types/lodash/is-object.d.ts +2 -0
  187. package/types/lodash/is-odd.d.ts +2 -0
  188. package/types/lodash/is-plain-object.d.ts +2 -0
  189. package/types/lodash/is-positive.d.ts +2 -0
  190. package/types/lodash/is-prototype.d.ts +2 -0
  191. package/types/lodash/is-reg-exp.d.ts +2 -0
  192. package/types/lodash/is-segment-equal.d.ts +2 -0
  193. package/types/lodash/is-string.d.ts +2 -0
  194. package/types/lodash/is-type.d.ts +2 -0
  195. package/types/lodash/is-undefined.d.ts +2 -0
  196. package/types/lodash/keys.d.ts +2 -0
  197. package/types/lodash/last.d.ts +1 -0
  198. package/types/lodash/lower-case.d.ts +2 -0
  199. package/types/lodash/lower-first.d.ts +2 -0
  200. package/types/lodash/map-values.d.ts +6 -0
  201. package/types/lodash/map.d.ts +2 -0
  202. package/types/lodash/max-by.d.ts +16 -0
  203. package/types/lodash/max.d.ts +19 -0
  204. package/types/lodash/memoize.d.ts +11 -0
  205. package/types/lodash/merge.d.ts +7 -0
  206. package/types/lodash/min-by.d.ts +16 -0
  207. package/types/lodash/min.d.ts +19 -0
  208. package/types/lodash/mix.d.ts +1 -0
  209. package/types/lodash/mod.d.ts +2 -0
  210. package/types/lodash/noop.d.ts +2 -0
  211. package/types/lodash/number2color.d.ts +2 -0
  212. package/types/lodash/omit.d.ts +3 -0
  213. package/types/lodash/parse-radius.d.ts +9 -0
  214. package/types/lodash/pick.d.ts +16 -0
  215. package/types/lodash/pull-at.d.ts +2 -0
  216. package/types/lodash/pull.d.ts +2 -0
  217. package/types/lodash/reduce.d.ts +3 -0
  218. package/types/lodash/remove.d.ts +2 -0
  219. package/types/lodash/request-animation-frame.d.ts +1 -0
  220. package/types/lodash/set.d.ts +8 -0
  221. package/types/lodash/size.d.ts +1 -0
  222. package/types/lodash/some.d.ts +7 -0
  223. package/types/lodash/sort-by.d.ts +7 -0
  224. package/types/lodash/starts-with.d.ts +3 -0
  225. package/types/lodash/substitute.d.ts +5 -0
  226. package/types/lodash/throttle.d.ts +6 -0
  227. package/types/lodash/to-array.d.ts +2 -0
  228. package/types/lodash/to-degree.d.ts +2 -0
  229. package/types/lodash/to-integer.d.ts +1 -0
  230. package/types/lodash/to-radian.d.ts +2 -0
  231. package/types/lodash/to-string.d.ts +2 -0
  232. package/types/lodash/types/index.d.ts +3 -0
  233. package/types/lodash/union.d.ts +2 -0
  234. package/types/lodash/uniq.d.ts +1 -0
  235. package/types/lodash/unique-id.d.ts +2 -0
  236. package/types/lodash/upper-case.d.ts +2 -0
  237. package/types/lodash/upper-first.d.ts +2 -0
  238. package/types/lodash/values-of-key.d.ts +2 -0
  239. package/types/lodash/values.d.ts +2 -0
  240. package/types/lodash/wrap-behavior.d.ts +9 -0
  241. package/types/parse-svg-path.d.ts +19 -0
  242. package/types/priority_queue.d.ts +41 -0
  243. package/types/radash/array.d.ts +209 -0
  244. package/types/radash/async.d.ts +99 -0
  245. package/types/radash/curry.d.ts +113 -0
  246. package/types/radash/index.d.ts +10 -0
  247. package/types/radash/number.d.ts +27 -0
  248. package/types/radash/object.d.ts +112 -0
  249. package/types/radash/random.d.ts +11 -0
  250. package/types/radash/series.d.ts +13 -0
  251. package/types/radash/string.d.ts +71 -0
  252. package/types/radash/typed.d.ts +26 -0
  253. package/types/stats.module.d.ts +3 -0
  254. package/README.md +0 -1
  255. package/dist/cjs/index.js +0 -19
  256. package/dist/umd/index.js +0 -23
  257. package/esm/extend.js +0 -3
  258. package/esm/index.js +0 -3
  259. package/lib/extend.js +0 -6
  260. package/lib/index.js +0 -6
  261. package/src/extend.ts +0 -6
  262. package/src/index.ts +0 -6
@@ -0,0 +1,2 @@
1
+ declare const upperFirst: (value: string) => string;
2
+ export default upperFirst;
@@ -0,0 +1,2 @@
1
+ declare const _default: (data: any[], name: string) => any[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const values: (obj: any) => any[];
2
+ export default values;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 封装事件,便于使用上下文this,和便于解除事件时使用
3
+ * @protected
4
+ * @param {Object} obj 对象
5
+ * @param {String} action 事件名称
6
+ * @return {Function} 返回事件处理函数
7
+ */
8
+ declare function wrapBehavior(obj: object, action: string): Function;
9
+ export default wrapBehavior;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Represents a single SVG path command
3
+ * First element is the command letter (e.g. 'M' for moveto, 'L' for lineto, etc)
4
+ * Remaining elements are the numeric parameters for that command
5
+ * @example ['M', 10, 20] // Move to x=10, y=20
6
+ * @example ['L', 30, 40] // Line to x=30, y=40
7
+ * @internal
8
+ */
9
+ export type Command = [string, ...number[]];
10
+
11
+ /**
12
+ * Parses an SVG path data string into an array of commands
13
+ * @param path - The SVG path data string to parse
14
+ * @returns Array of parsed commands, each containing a command letter and parameters
15
+ * @example
16
+ * parse('M10 20L30 40')
17
+ * // Returns: [['M', 10, 20], ['L', 30, 40]]
18
+ */
19
+ export default function parse(path: string): Command[];
@@ -0,0 +1,41 @@
1
+ export declare class PriorityQueue<T> {
2
+ private heap;
3
+ private compare;
4
+ /**
5
+ * 创建优先队列
6
+ * @param compare 比较函数 (a, b) => 负数表示a应排在b前面
7
+ */
8
+ constructor(compare: (a: T, b: T) => number);
9
+ /**
10
+ * 获取队列元素数量
11
+ */
12
+ get size(): number;
13
+ /**
14
+ * 判断队列是否为空
15
+ */
16
+ isEmpty(): boolean;
17
+ top(): T | null;
18
+ /**
19
+ * 查看队首元素
20
+ */
21
+ peek(): T | null;
22
+ /**
23
+ * 入队
24
+ * @param value 要添加的元素
25
+ */
26
+ enqueue(value: T): void;
27
+ push(value: T): void;
28
+ pop(): T | null;
29
+ /**
30
+ * 出队
31
+ * @returns 队首元素或null(空队列时)
32
+ */
33
+ dequeue(): T | null;
34
+ private siftUp;
35
+ private siftDown;
36
+ private swap;
37
+ /**
38
+ * 清空队列
39
+ */
40
+ clear(): void;
41
+ }
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Sorts an array of items into groups. The return value is a map where the keys are
3
+ * the group ids the given getGroupId function produced and the value is an array of
4
+ * each item in that group.
5
+ */
6
+ export declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => Partial<Record<Key, T[]>>;
7
+ /**
8
+ * Creates an array of grouped elements, the first of which contains the
9
+ * first elements of the given arrays, the second of which contains the
10
+ * second elements of the given arrays, and so on.
11
+ *
12
+ * Ex. const zipped = zip(['a', 'b'], [1, 2], [true, false]) // [['a', 1, true], ['b', 2, false]]
13
+ */
14
+ export declare function zip<T1, T2, T3, T4, T5>(array1: T1[], array2: T2[], array3: T3[], array4: T4[], array5: T5[]): [T1, T2, T3, T4, T5][];
15
+ export declare function zip<T1, T2, T3, T4>(array1: T1[], array2: T2[], array3: T3[], array4: T4[]): [T1, T2, T3, T4][];
16
+ export declare function zip<T1, T2, T3>(array1: T1[], array2: T2[], array3: T3[]): [T1, T2, T3][];
17
+ export declare function zip<T1, T2>(array1: T1[], array2: T2[]): [T1, T2][];
18
+ /**
19
+ * Creates an object mapping the specified keys to their corresponding values
20
+ *
21
+ * Ex. const zipped = zipToObject(['a', 'b'], [1, 2]) // { a: 1, b: 2 }
22
+ * Ex. const zipped = zipToObject(['a', 'b'], (k, i) => k + i) // { a: 'a0', b: 'b1' }
23
+ * Ex. const zipped = zipToObject(['a', 'b'], 1) // { a: 1, b: 1 }
24
+ */
25
+ export declare function zipToObject<K extends string | number | symbol, V>(keys: K[], values: V | ((key: K, idx: number) => V) | V[]): Record<K, V>;
26
+ /**
27
+ * Go through a list of items, starting with the first item,
28
+ * and comparing with the second. Keep the one you want then
29
+ * compare that to the next item in the list with the same
30
+ *
31
+ * Ex. const greatest = () => boil(numbers, (a, b) => a > b)
32
+ */
33
+ export declare const boil: <T>(array: readonly T[], compareFunc: (a: T, b: T) => T) => T | null;
34
+ /**
35
+ * Sum all numbers in an array. Optionally provide a function
36
+ * to convert objects in the array to number values.
37
+ */
38
+ export declare function sum<T extends number>(array: readonly T[]): number;
39
+ export declare function sum<T extends object>(array: readonly T[], fn: (item: T) => number): number;
40
+ /**
41
+ * Get the first item in an array or a default value
42
+ */
43
+ export declare const first: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
44
+ /**
45
+ * Get the last item in an array or a default value
46
+ */
47
+ export declare const last: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
48
+ /**
49
+ * Sort an array without modifying it and return
50
+ * the newly sorted value
51
+ */
52
+ export declare const sort: <T>(array: readonly T[], getter: (item: T) => number, desc?: boolean) => T[];
53
+ /**
54
+ * Sort an array without modifying it and return
55
+ * the newly sorted value. Allows for a string
56
+ * sorting value.
57
+ */
58
+ export declare const alphabetical: <T>(array: readonly T[], getter: (item: T) => string, dir?: "asc" | "desc") => T[];
59
+ export declare const counting: <T, TId extends string | number | symbol>(list: readonly T[], identity: (item: T) => TId) => Record<TId, number>;
60
+ /**
61
+ * Replace an element in an array with a new
62
+ * item without modifying the array and return
63
+ * the new value
64
+ */
65
+ export declare const replace: <T>(list: readonly T[], newItem: T, match: (item: T, idx: number) => boolean) => T[];
66
+ /**
67
+ * Convert an array to a dictionary by mapping each item
68
+ * into a dictionary key & value
69
+ */
70
+ export declare const objectify: <T, Key extends string | number | symbol, Value = T>(array: readonly T[], getKey: (item: T) => Key, getValue?: (item: T) => Value) => Record<Key, Value>;
71
+ /**
72
+ * Select performs a filter and a mapper inside of a reduce,
73
+ * only iterating the list one time.
74
+ *
75
+ * @example
76
+ * select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]
77
+ */
78
+ export declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition: (item: T, index: number) => boolean) => K[];
79
+ /**
80
+ * Max gets the greatest value from a list
81
+ *
82
+ * @example
83
+ * max([ 2, 3, 5]) == 5
84
+ * max([{ num: 1 }, { num: 2 }], x => x.num) == { num: 2 }
85
+ */
86
+ export declare function max(array: readonly [number, ...number[]]): number;
87
+ export declare function max(array: readonly number[]): number | null;
88
+ export declare function max<T>(array: readonly T[], getter: (item: T) => number): T | null;
89
+ /**
90
+ * Min gets the smallest value from a list
91
+ *
92
+ * @example
93
+ * min([1, 2, 3, 4]) == 1
94
+ * min([{ num: 1 }, { num: 2 }], x => x.num) == { num: 1 }
95
+ */
96
+ export declare function min(array: readonly [number, ...number[]]): number;
97
+ export declare function min(array: readonly number[]): number | null;
98
+ export declare function min<T>(array: readonly T[], getter: (item: T) => number): T | null;
99
+ /**
100
+ * Splits a single list into many lists of the desired size. If
101
+ * given a list of 10 items and a size of 2, it will return 5
102
+ * lists with 2 items each
103
+ */
104
+ export declare const cluster: <T>(list: readonly T[], size?: number) => T[][];
105
+ /**
106
+ * Given a list of items returns a new list with only
107
+ * unique items. Accepts an optional identity function
108
+ * to convert each item in the list to a comparable identity
109
+ * value
110
+ */
111
+ export declare const unique: <T, K extends string | number | symbol>(array: readonly T[], toKey?: (item: T) => K) => T[];
112
+ /**
113
+ * Creates a generator that will produce an iteration through
114
+ * the range of number as requested.
115
+ *
116
+ * @example
117
+ * range(3) // yields 0, 1, 2, 3
118
+ * range(0, 3) // yields 0, 1, 2, 3
119
+ * range(0, 3, 'y') // yields y, y, y, y
120
+ * range(0, 3, () => 'y') // yields y, y, y, y
121
+ * range(0, 3, i => i) // yields 0, 1, 2, 3
122
+ * range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3
123
+ * range(0, 3, obj) // yields obj, obj, obj, obj
124
+ * range(0, 6, i => i, 2) // yields 0, 2, 4, 6
125
+ */
126
+ export declare function range<T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number): Generator<T>;
127
+ /**
128
+ * Creates a list of given start, end, value, and
129
+ * step parameters.
130
+ *
131
+ * @example
132
+ * list(3) // 0, 1, 2, 3
133
+ * list(0, 3) // 0, 1, 2, 3
134
+ * list(0, 3, 'y') // y, y, y, y
135
+ * list(0, 3, () => 'y') // y, y, y, y
136
+ * list(0, 3, i => i) // 0, 1, 2, 3
137
+ * list(0, 3, i => `y${i}`) // y0, y1, y2, y3
138
+ * list(0, 3, obj) // obj, obj, obj, obj
139
+ * list(0, 6, i => i, 2) // 0, 2, 4, 6
140
+ */
141
+ export declare const list: <T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number) => T[];
142
+ /**
143
+ * Given an array of arrays, returns a single
144
+ * dimentional array with all items in it.
145
+ */
146
+ export declare const flat: <T>(lists: readonly T[][]) => T[];
147
+ /**
148
+ * Given two arrays, returns true if any
149
+ * elements intersect
150
+ */
151
+ export declare const intersects: <T, K extends string | number | symbol>(listA: readonly T[], listB: readonly T[], identity?: (t: T) => K) => boolean;
152
+ /**
153
+ * Split an array into two array based on
154
+ * a true/false condition function
155
+ */
156
+ export declare const fork: <T>(list: readonly T[], condition: (item: T) => boolean) => [T[], T[]];
157
+ /**
158
+ * Given two lists of the same type, iterate the first list
159
+ * and replace items matched by the matcher func in the
160
+ * first place.
161
+ */
162
+ export declare const merge: <T>(root: readonly T[], others: readonly T[], matcher: (item: T) => any) => readonly T[];
163
+ /**
164
+ * Replace an item in an array by a match function condition. If
165
+ * no items match the function condition, appends the new item to
166
+ * the end of the list.
167
+ */
168
+ export declare const replaceOrAppend: <T>(list: readonly T[], newItem: T, match: (a: T, idx: number) => boolean) => T[];
169
+ /**
170
+ * If the item matching the condition already exists
171
+ * in the list it will be removed. If it does not it
172
+ * will be added.
173
+ */
174
+ export declare const toggle: <T>(list: readonly T[], item: T,
175
+ /**
176
+ * Converts an item of type T item into a value that
177
+ * can be checked for equality
178
+ */
179
+ toKey?: null | ((item: T, idx: number) => number | string | symbol), options?: {
180
+ strategy?: "prepend" | "append";
181
+ }) => T[];
182
+ type Falsy = null | undefined | false | '' | 0 | 0n;
183
+ /**
184
+ * Given a list returns a new list with
185
+ * only truthy values
186
+ */
187
+ export declare const sift: <T>(list: readonly (T | Falsy)[]) => T[];
188
+ /**
189
+ * Like a reduce but does not require an array.
190
+ * Only need a number and will iterate the function
191
+ * as many times as specified.
192
+ *
193
+ * NOTE: This is NOT zero indexed. If you pass count=5
194
+ * you will get 1, 2, 3, 4, 5 iteration in the callback
195
+ * function
196
+ */
197
+ export declare const iterate: <T>(count: number, func: (currentValue: T, iteration: number) => T, initValue: T) => T;
198
+ /**
199
+ * Returns all items from the first list that
200
+ * do not exist in the second list.
201
+ */
202
+ export declare const diff: <T>(root: readonly T[], other: readonly T[], identity?: (item: T) => string | number | symbol) => T[];
203
+ /**
204
+ * Shift array items by n steps
205
+ * If n > 0 items will shift n steps to the right
206
+ * If n < 0 items will shift n steps to the left
207
+ */
208
+ export declare function shift<T>(arr: Array<T>, n: number): T[];
209
+ export {};
@@ -0,0 +1,99 @@
1
+ /**
2
+ * An async reduce function. Works like the
3
+ * built-in Array.reduce function but handles
4
+ * an async reducer function
5
+ */
6
+ export declare const reduce: <T, K>(array: readonly T[], asyncReducer: (acc: K, item: T, index: number) => Promise<K>, initValue?: K) => Promise<K>;
7
+ /**
8
+ * An async map function. Works like the
9
+ * built-in Array.map function but handles
10
+ * an async mapper function
11
+ */
12
+ export declare const map: <T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) => Promise<K>) => Promise<K[]>;
13
+ /**
14
+ * Useful when for script like things where cleanup
15
+ * should be done on fail or sucess no matter.
16
+ *
17
+ * You can call defer many times to register many
18
+ * defered functions that will all be called when
19
+ * the function exits in any state.
20
+ */
21
+ export declare const defer: <TResponse>(func: (register: (fn: (error?: any) => any, options?: {
22
+ rethrow?: boolean;
23
+ }) => void) => Promise<TResponse>) => Promise<TResponse>;
24
+ /**
25
+ * Support for the built-in AggregateError
26
+ * is still new. Node < 15 doesn't have it
27
+ * so patching here.
28
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
29
+ */
30
+ export declare class AggregateError extends Error {
31
+ errors: Error[];
32
+ constructor(errors?: Error[]);
33
+ }
34
+ /**
35
+ * Executes many async functions in parallel. Returns the
36
+ * results from all functions as an array. After all functions
37
+ * have resolved, if any errors were thrown, they are rethrown
38
+ * in an instance of AggregateError
39
+ */
40
+ export declare const parallel: <T, K>(limit: number, array: readonly T[], func: (item: T) => Promise<K>) => Promise<K[]>;
41
+ type PromiseValues<T extends Promise<any>[]> = {
42
+ [K in keyof T]: T[K] extends Promise<infer U> ? U : never;
43
+ };
44
+ /**
45
+ * Functionally similar to Promise.all or Promise.allSettled. If any
46
+ * errors are thrown, all errors are gathered and thrown in an
47
+ * AggregateError.
48
+ *
49
+ * @example
50
+ * const [user] = await all([
51
+ * api.users.create(...),
52
+ * s3.buckets.create(...),
53
+ * slack.customerSuccessChannel.sendMessage(...)
54
+ * ])
55
+ */
56
+ export declare function all<T extends [Promise<any>, ...Promise<any>[]]>(promises: T): Promise<PromiseValues<T>>;
57
+ export declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValues<T>>;
58
+ /**
59
+ * Functionally similar to Promise.all or Promise.allSettled. If any
60
+ * errors are thrown, all errors are gathered and thrown in an
61
+ * AggregateError.
62
+ *
63
+ * @example
64
+ * const { user } = await all({
65
+ * user: api.users.create(...),
66
+ * bucket: s3.buckets.create(...),
67
+ * message: slack.customerSuccessChannel.sendMessage(...)
68
+ * })
69
+ */
70
+ export declare function all<T extends Record<string, Promise<any>>>(promises: T): Promise<{
71
+ [K in keyof T]: Awaited<T[K]>;
72
+ }>;
73
+ /**
74
+ * Retries the given function the specified number
75
+ * of times.
76
+ */
77
+ export declare const retry: <TResponse>(options: {
78
+ times?: number;
79
+ delay?: number | null;
80
+ backoff?: (count: number) => number;
81
+ }, func: (exit: (err: any) => void) => Promise<TResponse>) => Promise<TResponse>;
82
+ /**
83
+ * Async wait
84
+ */
85
+ export declare const sleep: (milliseconds: number) => Promise<unknown>;
86
+ /**
87
+ * A helper to try an async function without forking
88
+ * the control flow. Returns an error first callback _like_
89
+ * array response as [Error, result]
90
+ */
91
+ export declare const tryit: <Args extends any[], Return>(func: (...args: Args) => Return) => (...args: Args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return];
92
+ /**
93
+ * A helper to try an async function that returns undefined
94
+ * if it fails.
95
+ *
96
+ * e.g. const result = await guard(fetchUsers)() ?? [];
97
+ */
98
+ export declare const guard: <TFunction extends () => any>(func: TFunction, shouldGuard?: (err: any) => boolean) => ReturnType<TFunction> extends Promise<any> ? Promise<Awaited<ReturnType<TFunction>> | undefined> : ReturnType<TFunction> | undefined;
99
+ export {};
@@ -0,0 +1,113 @@
1
+ export declare function chain<T1 extends any[], T2, T3>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3): (...arg: T1) => T3;
2
+ export declare function chain<T1 extends any[], T2, T3, T4>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4): (...arg: T1) => T4;
3
+ export declare function chain<T1 extends any[], T2, T3, T4, T5>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5): (...arg: T1) => T5;
4
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6): (...arg: T1) => T6;
5
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7): (...arg: T1) => T7;
6
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8): (...arg: T1) => T8;
7
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9): (...arg: T1) => T9;
8
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9, T10>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9, f9: (arg: T3) => T10): (...arg: T1) => T10;
9
+ export declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9, f9: (arg: T3) => T10, f10: (arg: T3) => T11): (...arg: T1) => T11;
10
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], LastResult>(f1: (next: (...args: F1NextArgs) => LastResult) => (...args: F1Args) => F1Result, last: (...args: F1NextArgs) => LastResult): (...args: F1Args) => F1Result;
11
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2Result, F2NextArgs extends any[], LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => LastResult) => (...args: F1NextArgs) => F2Result, last: (...args: F2NextArgs) => LastResult): (...args: F1Args) => F1Result;
12
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => LastResult) => (...args: F2NextArgs) => F3Result, last: (...args: F3NextArgs) => LastResult): (...args: F1Args) => F1Result;
13
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => LastResult) => (...args: F3NextArgs) => F4Result, last: (...args: F4NextArgs) => LastResult): (...args: F1Args) => F1Result;
14
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => LastResult) => (...args: F4NextArgs) => F5Result, last: (...args: F5NextArgs) => LastResult): (...args: F1Args) => F1Result;
15
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => LastResult) => (...args: F5NextArgs) => F6Result, last: (...args: F6NextArgs) => LastResult): (...args: F1Args) => F1Result;
16
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, last: (...args: F7NextArgs) => LastResult): (...args: F1Args) => F1Result;
17
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, last: (...args: F8NextArgs) => LastResult): (...args: F1Args) => F1Result;
18
+ export declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, F9NextArgs extends any[], F9Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, f9: (next: (...args: F9NextArgs) => LastResult) => (...args: F8NextArgs) => F9Result, last: (...args: F9NextArgs) => LastResult): (...args: F1Args) => F1Result;
19
+ /**
20
+ * This type produces the type array of TItems with all the type items
21
+ * in TItemsToRemove removed from the start of the array type.
22
+ *
23
+ * @example
24
+ * ```
25
+ * RemoveItemsInFront<[number, number], [number]> = [number]
26
+ * RemoveItemsInFront<[File, number, string], [File, number]> = [string]
27
+ * ```
28
+ */
29
+ type RemoveItemsInFront<TItems extends any[], TItemsToRemove extends any[]> = TItems extends [...TItemsToRemove, ...infer TRest] ? TRest : TItems;
30
+ export declare const partial: <T extends any[], TA extends Partial<T>, R>(fn: (...args: T) => R, ...args: TA) => (...rest: RemoveItemsInFront<T, TA>) => R;
31
+ /**
32
+ * Like partial but for unary functions that accept
33
+ * a single object argument
34
+ */
35
+ export declare const partob: <T, K, PartialArgs extends Partial<T>>(fn: (args: T) => K, argobj: PartialArgs) => (restobj: Omit<T, keyof PartialArgs>) => K;
36
+ /**
37
+ * Creates a Proxy object that will dynamically
38
+ * call the handler argument when attributes are
39
+ * accessed
40
+ */
41
+ export declare const proxied: <T, K>(handler: (propertyName: T) => K) => Record<string, K>;
42
+ /**
43
+ * Creates a memoized function. The returned function
44
+ * will only execute the source function when no value
45
+ * has previously been computed. If a ttl (milliseconds)
46
+ * is given previously computed values will be checked
47
+ * for expiration before being returned.
48
+ */
49
+ export declare const memo: <TArgs extends any[], TResult>(func: (...args: TArgs) => TResult, options?: {
50
+ key?: (...args: TArgs) => string;
51
+ ttl?: number;
52
+ }) => (...args: TArgs) => TResult;
53
+ export type DebounceFunction<TArgs extends any[]> = {
54
+ (...args: TArgs): void;
55
+ /**
56
+ * Cancels the debounced function
57
+ */
58
+ cancel(): void;
59
+ /**
60
+ * Checks if there is any invocation debounced
61
+ */
62
+ isPending(): boolean;
63
+ /**
64
+ * Runs the debounced function immediately
65
+ */
66
+ flush(...args: TArgs): void;
67
+ };
68
+ export type ThrottledFunction<TArgs extends any[]> = {
69
+ (...args: TArgs): void;
70
+ /**
71
+ * Checks if there is any invocation throttled
72
+ */
73
+ isThrottled(): boolean;
74
+ };
75
+ /**
76
+ * Given a delay and a function returns a new function
77
+ * that will only call the source function after delay
78
+ * milliseconds have passed without any invocations.
79
+ *
80
+ * The debounce function comes with a `cancel` method
81
+ * to cancel delayed `func` invocations and a `flush`
82
+ * method to invoke them immediately
83
+ */
84
+ export declare const debounce: <TArgs extends any[]>({ delay }: {
85
+ delay: number;
86
+ }, func: (...args: TArgs) => any) => DebounceFunction<TArgs>;
87
+ /**
88
+ * Given an interval and a function returns a new function
89
+ * that will only call the source function if interval milliseconds
90
+ * have passed since the last invocation
91
+ */
92
+ export declare const throttle: <TArgs extends any[]>({ interval }: {
93
+ interval: number;
94
+ }, func: (...args: TArgs) => any) => ThrottledFunction<TArgs>;
95
+ /**
96
+ * Make an object callable. Given an object and a function
97
+ * the returned object will be a function with all the
98
+ * objects properties.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const car = callable({
103
+ * wheels: 2
104
+ * }, self => () => {
105
+ * return 'driving'
106
+ * })
107
+ *
108
+ * car.wheels // => 2
109
+ * car() // => 'driving'
110
+ * ```
111
+ */
112
+ export declare const callable: <TValue, TObj extends Record<string | number | symbol, TValue>, TFunc extends (...args: any) => any>(obj: TObj, fn: (self: TObj) => TFunc) => TObj & TFunc;
113
+ export {};
@@ -0,0 +1,10 @@
1
+ export { alphabetical, boil, cluster, counting, diff, first, flat, fork, group, intersects, iterate, last, list, max, merge, min, objectify, range, replace, replaceOrAppend, select, shift, sift, sort, sum, toggle, unique, zip, zipToObject } from './array';
2
+ export { all, defer, guard, map, parallel, reduce, retry, sleep, tryit as try, tryit } from './async';
3
+ export type { AggregateError } from './async';
4
+ export { callable, chain, compose, debounce, memo, partial, partob, proxied, throttle } from './curry';
5
+ export { inRange, toFloat, toInt } from './number';
6
+ export { assign, clone, construct, crush, get, invert, keys, listify, lowerize, mapEntries, mapKeys, mapValues, omit, pick, set, shake, upperize } from './object';
7
+ export { draw, random, shuffle, uid } from './random';
8
+ export { series } from './series';
9
+ export { camel, capitalize, dash, pascal, snake, template, title, trim } from './string';
10
+ export { isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './typed';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Checks if the given number is between zero (0) and the ending number. 0 is inclusive.
3
+ *
4
+ * * Numbers can be negative or positive.
5
+ * * Ending number is exclusive.
6
+ *
7
+ * @param {number} number The number to check.
8
+ * @param {number} end The end of the range. Exclusive.
9
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
10
+ */
11
+ export declare function inRange(number: number, end: number): boolean;
12
+ /**
13
+ * Checks if the given number is between two numbers.
14
+ *
15
+ * * Numbers can be negative or positive.
16
+ * * Starting number is inclusive.
17
+ * * Ending number is exclusive.
18
+ * * The start and the end of the range can be ascending OR descending order.
19
+ *
20
+ * @param {number} number The number to check.
21
+ * @param {number} start The start of the range. Inclusive.
22
+ * @param {number} end The end of the range. Exclusive.
23
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
24
+ */
25
+ export declare function inRange(number: number, start: number, end: number): boolean;
26
+ export declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T) => number | T;
27
+ export declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T) => number | T;
@@ -0,0 +1,112 @@
1
+ type LowercasedKeys<T extends Record<string, any>> = {
2
+ [P in keyof T & string as Lowercase<P>]: T[P];
3
+ };
4
+ type UppercasedKeys<T extends Record<string, any>> = {
5
+ [P in keyof T & string as Uppercase<P>]: T[P];
6
+ };
7
+ /**
8
+ * Removes (shakes out) undefined entries from an
9
+ * object. Optional second argument shakes out values
10
+ * by custom evaluation.
11
+ */
12
+ export declare const shake: <RemovedKeys extends string, T>(obj: T, filter?: (value: any) => boolean) => Omit<T, RemovedKeys>;
13
+ /**
14
+ * Map over all the keys of an object to return
15
+ * a new object
16
+ */
17
+ export declare const mapKeys: <TValue, TKey extends string | number | symbol, TNewKey extends string | number | symbol>(obj: Record<TKey, TValue>, mapFunc: (key: TKey, value: TValue) => TNewKey) => Record<TNewKey, TValue>;
18
+ /**
19
+ * Map over all the keys to create a new object
20
+ */
21
+ export declare const mapValues: <TValue, TKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, mapFunc: (value: TValue, key: TKey) => TNewValue) => Record<TKey, TNewValue>;
22
+ /**
23
+ * Map over all the keys to create a new object
24
+ */
25
+ export declare const mapEntries: <TKey extends string | number | symbol, TValue, TNewKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, toEntry: (key: TKey, value: TValue) => [TNewKey, TNewValue]) => Record<TNewKey, TNewValue>;
26
+ /**
27
+ * Returns an object with { [keys]: value }
28
+ * inverted as { [value]: key }
29
+ */
30
+ export declare const invert: <TKey extends string | number | symbol, TValue extends string | number | symbol>(obj: Record<TKey, TValue>) => Record<TValue, TKey>;
31
+ /**
32
+ * Convert all keys in an object to lower case
33
+ */
34
+ export declare const lowerize: <T extends Record<string, any>>(obj: T) => LowercasedKeys<T>;
35
+ /**
36
+ * Convert all keys in an object to upper case
37
+ */
38
+ export declare const upperize: <T extends Record<string, any>>(obj: T) => UppercasedKeys<T>;
39
+ /**
40
+ * Creates a shallow copy of the given obejct/value.
41
+ * @param {*} obj value to clone
42
+ * @returns {*} shallow clone of the given value
43
+ */
44
+ export declare const clone: <T>(obj: T) => T;
45
+ /**
46
+ * Convert an object to a list, mapping each entry
47
+ * into a list item
48
+ */
49
+ export declare const listify: <TValue, TKey extends string | number | symbol, KResult>(obj: Record<TKey, TValue>, toItem: (key: TKey, value: TValue) => KResult) => KResult[];
50
+ /**
51
+ * Pick a list of properties from an object
52
+ * into a new object
53
+ */
54
+ export declare const pick: <T extends object, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Pick<T, TKeys>;
55
+ /**
56
+ * Omit a list of properties from an object
57
+ * returning a new object with the properties
58
+ * that remain
59
+ */
60
+ export declare const omit: <T, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Omit<T, TKeys>;
61
+ /**
62
+ * Dynamically get a nested value from an array or
63
+ * object with a string.
64
+ *
65
+ * @example get(person, 'friends[0].name')
66
+ */
67
+ export declare const get: <TDefault = unknown>(value: any, path: string, defaultValue?: TDefault) => TDefault;
68
+ /**
69
+ * Opposite of get, dynamically set a nested value into
70
+ * an object using a key path. Does not modify the given
71
+ * initial object.
72
+ *
73
+ * @example
74
+ * set({}, 'name', 'ra') // => { name: 'ra' }
75
+ * set({}, 'cards[0].value', 2) // => { cards: [{ value: 2 }] }
76
+ */
77
+ export declare const set: <T extends object, K>(initial: T, path: string, value: K) => T;
78
+ /**
79
+ * Merges two objects together recursivly into a new
80
+ * object applying values from right to left.
81
+ * Recursion only applies to child object properties.
82
+ */
83
+ export declare const assign: <X extends Record<string | symbol | number, any>>(initial: X, override: X) => X;
84
+ /**
85
+ * Get a string list of all key names that exist in
86
+ * an object (deep).
87
+ *
88
+ * @example
89
+ * keys({ name: 'ra' }) // ['name']
90
+ * keys({ name: 'ra', children: [{ name: 'hathor' }] }) // ['name', 'children.0.name']
91
+ */
92
+ export declare const keys: <TValue extends object>(value: TValue) => string[];
93
+ /**
94
+ * Flattens a deep object to a single demension, converting
95
+ * the keys to dot notation.
96
+ *
97
+ * @example
98
+ * crush({ name: 'ra', children: [{ name: 'hathor' }] })
99
+ * // { name: 'ra', 'children.0.name': 'hathor' }
100
+ */
101
+ export declare const crush: <TValue extends object>(value: TValue) => object;
102
+ /**
103
+ * The opposite of crush, given an object that was
104
+ * crushed into key paths and values will return
105
+ * the original object reconstructed.
106
+ *
107
+ * @example
108
+ * construct({ name: 'ra', 'children.0.name': 'hathor' })
109
+ * // { name: 'ra', children: [{ name: 'hathor' }] }
110
+ */
111
+ export declare const construct: <TObject extends object>(obj: TObject) => object;
112
+ export {};