@oscarpalmer/atoms 0.74.1 → 0.76.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 (282) hide show
  1. package/dist/js/array/chunk.cjs +18 -0
  2. package/dist/js/array/{chunk.mjs → chunk.js} +2 -2
  3. package/dist/js/array/compact.cjs +6 -0
  4. package/dist/js/array/{compact.mjs → compact.js} +0 -1
  5. package/dist/js/array/count.cjs +14 -0
  6. package/dist/js/array/count.js +14 -0
  7. package/dist/js/array/exists.cjs +14 -0
  8. package/dist/js/array/exists.js +14 -0
  9. package/dist/js/array/filter.cjs +14 -0
  10. package/dist/js/array/filter.js +14 -0
  11. package/dist/js/array/find.cjs +14 -0
  12. package/dist/js/array/find.js +14 -0
  13. package/dist/js/array/group-by.cjs +35 -0
  14. package/dist/js/array/group-by.js +35 -0
  15. package/dist/js/array/index-of.cjs +14 -0
  16. package/dist/js/array/index-of.js +14 -0
  17. package/dist/js/array/index.cjs +40 -0
  18. package/dist/js/array/index.js +34 -381
  19. package/dist/js/array/insert.cjs +31 -0
  20. package/dist/js/array/insert.js +31 -0
  21. package/dist/js/array/models.cjs +1 -0
  22. package/dist/js/array/models.js +1 -0
  23. package/dist/js/array/shuffle.cjs +13 -0
  24. package/dist/js/array/{shuffle.mjs → shuffle.js} +2 -3
  25. package/dist/js/array/sort.cjs +53 -0
  26. package/dist/js/array/{sort.mjs → sort.js} +13 -9
  27. package/dist/js/array/splice.cjs +14 -0
  28. package/dist/js/array/splice.js +14 -0
  29. package/dist/js/array/to-map.cjs +27 -0
  30. package/dist/js/array/to-map.js +27 -0
  31. package/dist/js/array/to-record.cjs +12 -0
  32. package/dist/js/array/to-record.js +12 -0
  33. package/dist/js/array/unique.cjs +7 -0
  34. package/dist/js/array/unique.js +7 -0
  35. package/dist/js/colour/base.cjs +18 -0
  36. package/dist/js/colour/{base.mjs → base.js} +4 -3
  37. package/dist/js/colour/functions.cjs +96 -0
  38. package/dist/js/colour/{functions.mjs → functions.js} +18 -19
  39. package/dist/js/colour/hex.cjs +56 -0
  40. package/dist/js/colour/{hex.mjs → hex.js} +34 -15
  41. package/dist/js/colour/hsl.cjs +85 -0
  42. package/dist/js/colour/{hsl.mjs → hsl.js} +40 -12
  43. package/dist/js/colour/index.cjs +29 -0
  44. package/dist/js/colour/index.js +14 -272
  45. package/dist/js/colour/is.cjs +27 -0
  46. package/dist/js/colour/{is.mjs → is.js} +7 -6
  47. package/dist/js/colour/rgb.cjs +87 -0
  48. package/dist/js/colour/{rgb.mjs → rgb.js} +43 -12
  49. package/dist/js/{emitter.mjs → emitter.cjs} +88 -56
  50. package/dist/js/emitter.js +85 -56
  51. package/dist/js/{function.mjs → function.cjs} +66 -46
  52. package/dist/js/function.js +61 -48
  53. package/dist/js/index.cjs +136 -0
  54. package/dist/js/index.js +133 -1724
  55. package/dist/js/internal/array/callbacks.cjs +23 -0
  56. package/dist/js/internal/array/callbacks.js +23 -0
  57. package/dist/js/internal/array/find.cjs +51 -0
  58. package/dist/js/internal/array/find.js +51 -0
  59. package/dist/js/internal/value/handle.cjs +21 -0
  60. package/dist/js/internal/{value-handle.mjs → value/handle.js} +0 -1
  61. package/dist/js/{is.mjs → is.cjs} +17 -18
  62. package/dist/js/is.js +15 -27
  63. package/dist/js/logger.cjs +108 -0
  64. package/dist/js/logger.js +44 -8
  65. package/dist/js/{math.mjs → math.cjs} +7 -8
  66. package/dist/js/math.js +4 -5
  67. package/dist/js/models.cjs +1 -0
  68. package/dist/js/models.js +1 -0
  69. package/dist/js/{number.mjs → number.cjs} +8 -8
  70. package/dist/js/number.js +5 -5
  71. package/dist/js/{query.mjs → query.cjs} +18 -18
  72. package/dist/js/query.js +17 -86
  73. package/dist/js/{queue.mjs → queue.cjs} +12 -13
  74. package/dist/js/queue.js +9 -10
  75. package/dist/js/{random.mjs → random.cjs} +14 -21
  76. package/dist/js/random.js +9 -26
  77. package/dist/js/{sized.mjs → sized.cjs} +68 -33
  78. package/dist/js/sized.js +66 -38
  79. package/dist/js/string/case.cjs +41 -0
  80. package/dist/js/string/{case.mjs → case.js} +13 -9
  81. package/dist/js/string/index.cjs +59 -0
  82. package/dist/js/string/index.js +30 -100
  83. package/dist/js/string/template.cjs +21 -0
  84. package/dist/js/string/{template.mjs → template.js} +4 -5
  85. package/dist/js/{touch.mjs → touch.cjs} +4 -7
  86. package/dist/js/touch.js +3 -5
  87. package/dist/js/value/clone.cjs +76 -0
  88. package/dist/js/value/{clone.mjs → clone.js} +5 -6
  89. package/dist/js/value/compare.cjs +59 -0
  90. package/dist/js/value/{compare.mjs → compare.js} +4 -6
  91. package/dist/js/value/diff.cjs +75 -0
  92. package/dist/js/value/{diff.mjs → diff.js} +13 -11
  93. package/dist/js/value/equal.cjs +106 -0
  94. package/dist/js/value/{equal.mjs → equal.js} +13 -8
  95. package/dist/js/value/get.cjs +21 -0
  96. package/dist/js/value/{get.mjs → get.js} +9 -4
  97. package/dist/js/value/index.cjs +30 -0
  98. package/dist/js/value/index.js +19 -510
  99. package/dist/js/value/merge.cjs +35 -0
  100. package/dist/js/value/{merge.mjs → merge.js} +7 -6
  101. package/dist/js/value/set.cjs +25 -0
  102. package/dist/js/value/{set.mjs → set.js} +3 -4
  103. package/dist/js/value/smush.cjs +26 -0
  104. package/dist/js/value/{smush.mjs → smush.js} +3 -4
  105. package/dist/js/value/unsmush.cjs +39 -0
  106. package/dist/js/value/{unsmush.mjs → unsmush.js} +10 -7
  107. package/package.json +50 -47
  108. package/src/js/array/chunk.ts +6 -5
  109. package/src/js/array/compact.ts +8 -10
  110. package/src/js/array/count.ts +39 -19
  111. package/src/js/array/exists.ts +39 -15
  112. package/src/js/array/filter.ts +42 -20
  113. package/src/js/array/find.ts +45 -20
  114. package/src/js/array/group-by.ts +158 -27
  115. package/src/js/array/index-of.ts +40 -18
  116. package/src/js/array/index.ts +10 -9
  117. package/src/js/array/insert.ts +28 -14
  118. package/src/js/array/models.ts +18 -15
  119. package/src/js/array/shuffle.ts +3 -3
  120. package/src/js/array/sort.ts +32 -34
  121. package/src/js/array/splice.ts +22 -26
  122. package/src/js/array/to-map.ts +133 -45
  123. package/src/js/array/to-record.ts +137 -39
  124. package/src/js/array/unique.ts +20 -15
  125. package/src/js/colour/base.ts +3 -3
  126. package/src/js/colour/functions.ts +4 -6
  127. package/src/js/colour/hex.ts +5 -5
  128. package/src/js/colour/hsl.ts +18 -12
  129. package/src/js/colour/index.ts +1 -1
  130. package/src/js/colour/is.ts +3 -3
  131. package/src/js/colour/rgb.ts +17 -11
  132. package/src/js/emitter.ts +12 -9
  133. package/src/js/function.ts +17 -17
  134. package/src/js/index.ts +16 -16
  135. package/src/js/internal/array/callbacks.ts +33 -0
  136. package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
  137. package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
  138. package/src/js/is.ts +2 -2
  139. package/src/js/logger.ts +14 -14
  140. package/src/js/math.ts +1 -1
  141. package/src/js/models.ts +5 -5
  142. package/src/js/number.ts +2 -2
  143. package/src/js/query.ts +6 -10
  144. package/src/js/queue.ts +1 -1
  145. package/src/js/random.ts +9 -19
  146. package/src/js/sized.ts +145 -145
  147. package/src/js/string/case.ts +1 -1
  148. package/src/js/string/index.ts +13 -7
  149. package/src/js/string/template.ts +6 -3
  150. package/src/js/value/clone.ts +3 -7
  151. package/src/js/value/compare.ts +3 -5
  152. package/src/js/value/diff.ts +4 -4
  153. package/src/js/value/equal.ts +2 -2
  154. package/src/js/value/get.ts +3 -3
  155. package/src/js/value/index.ts +2 -2
  156. package/src/js/value/merge.ts +3 -3
  157. package/src/js/value/set.ts +3 -4
  158. package/src/js/value/smush.ts +4 -4
  159. package/src/js/value/unsmush.ts +4 -4
  160. package/types/array/chunk.d.cts +8 -0
  161. package/types/array/chunk.d.ts +2 -2
  162. package/types/array/compact.d.cts +12 -0
  163. package/types/array/compact.d.ts +4 -4
  164. package/types/array/count.d.cts +24 -0
  165. package/types/array/count.d.ts +13 -7
  166. package/types/array/exists.d.cts +26 -0
  167. package/types/array/exists.d.ts +11 -3
  168. package/types/array/filter.d.cts +26 -0
  169. package/types/array/filter.d.ts +14 -6
  170. package/types/array/find.d.cts +26 -0
  171. package/types/array/find.d.ts +14 -6
  172. package/types/array/group-by.d.cts +58 -0
  173. package/types/array/group-by.d.ts +49 -5
  174. package/types/array/index-of.d.cts +26 -0
  175. package/types/array/index-of.d.ts +14 -6
  176. package/types/array/index.d.cts +239 -95
  177. package/types/array/index.d.ts +7 -6
  178. package/types/array/insert.d.cts +16 -0
  179. package/types/array/insert.d.ts +10 -5
  180. package/types/array/models.d.cts +14 -11
  181. package/types/array/models.d.ts +14 -12
  182. package/types/array/shuffle.d.cts +8 -0
  183. package/types/array/shuffle.d.ts +2 -2
  184. package/types/array/sort.d.cts +24 -0
  185. package/types/array/sort.d.ts +10 -10
  186. package/types/array/splice.d.cts +22 -0
  187. package/types/array/splice.d.ts +4 -4
  188. package/types/array/to-map.d.cts +61 -0
  189. package/types/array/to-map.d.ts +42 -20
  190. package/types/array/to-record.d.cts +61 -0
  191. package/types/array/to-record.d.ts +42 -20
  192. package/types/array/unique.d.cts +21 -0
  193. package/types/array/unique.d.ts +10 -6
  194. package/types/colour/base.d.cts +153 -0
  195. package/types/colour/base.d.ts +2 -2
  196. package/types/colour/functions.d.cts +173 -0
  197. package/types/colour/functions.d.ts +3 -3
  198. package/types/colour/hex.d.cts +157 -0
  199. package/types/colour/hex.d.ts +4 -4
  200. package/types/colour/hsl.d.cts +157 -0
  201. package/types/colour/hsl.d.ts +16 -10
  202. package/types/colour/index.d.cts +28 -16
  203. package/types/colour/index.d.ts +1 -1
  204. package/types/colour/is.d.cts +170 -0
  205. package/types/colour/is.d.ts +3 -3
  206. package/types/colour/rgb.d.cts +157 -0
  207. package/types/colour/rgb.d.ts +15 -9
  208. package/types/emitter.d.cts +11 -8
  209. package/types/emitter.d.ts +11 -8
  210. package/types/function.d.cts +10 -10
  211. package/types/function.d.ts +11 -11
  212. package/types/index.d.cts +1120 -736
  213. package/types/index.d.ts +16 -16
  214. package/types/internal/array/callbacks.d.cts +11 -0
  215. package/types/internal/array/callbacks.d.ts +2 -0
  216. package/types/internal/array/find.d.cts +7 -0
  217. package/types/internal/array/find.d.ts +3 -0
  218. package/types/internal/value/handle.d.cts +37 -0
  219. package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
  220. package/types/is.d.ts +1 -1
  221. package/types/logger.d.cts +13 -21
  222. package/types/logger.d.ts +13 -21
  223. package/types/math.d.cts +1 -1
  224. package/types/math.d.ts +1 -1
  225. package/types/models.d.cts +4 -4
  226. package/types/models.d.ts +1 -4
  227. package/types/number.d.cts +2 -2
  228. package/types/number.d.ts +2 -2
  229. package/types/query.d.cts +2 -2
  230. package/types/query.d.ts +3 -3
  231. package/types/queue.d.cts +1 -1
  232. package/types/queue.d.ts +1 -1
  233. package/types/random.d.cts +8 -12
  234. package/types/random.d.ts +8 -12
  235. package/types/sized.d.cts +6 -6
  236. package/types/sized.d.ts +6 -6
  237. package/types/string/case.d.cts +28 -0
  238. package/types/string/index.d.cts +30 -27
  239. package/types/string/index.d.ts +3 -3
  240. package/types/string/template.d.cts +50 -0
  241. package/types/string/template.d.ts +4 -1
  242. package/types/value/clone.d.cts +8 -0
  243. package/types/value/clone.d.ts +4 -2
  244. package/types/value/compare.d.cts +8 -0
  245. package/types/value/diff.d.cts +25 -0
  246. package/types/value/equal.d.cts +12 -0
  247. package/types/value/get.d.cts +1319 -0
  248. package/types/value/get.d.ts +1 -1
  249. package/types/value/index.d.cts +8 -6
  250. package/types/value/index.d.ts +2 -2
  251. package/types/value/merge.d.cts +72 -0
  252. package/types/value/merge.d.ts +2 -2
  253. package/types/value/set.d.cts +1011 -0
  254. package/types/value/set.d.ts +1 -1
  255. package/types/value/smush.d.cts +1368 -0
  256. package/types/value/smush.d.ts +2 -2
  257. package/types/value/unsmush.d.cts +141 -0
  258. package/types/value/unsmush.d.ts +2 -2
  259. package/dist/js/array/count.mjs +0 -8
  260. package/dist/js/array/exists.mjs +0 -8
  261. package/dist/js/array/filter.mjs +0 -8
  262. package/dist/js/array/find.mjs +0 -8
  263. package/dist/js/array/group-by.mjs +0 -33
  264. package/dist/js/array/index-of.mjs +0 -8
  265. package/dist/js/array/index.mjs +0 -34
  266. package/dist/js/array/insert.mjs +0 -22
  267. package/dist/js/array/models.mjs +0 -0
  268. package/dist/js/array/splice.mjs +0 -9
  269. package/dist/js/array/to-map.mjs +0 -27
  270. package/dist/js/array/to-record.mjs +0 -8
  271. package/dist/js/array/unique.mjs +0 -8
  272. package/dist/js/colour/index.mjs +0 -30
  273. package/dist/js/index.mjs +0 -17
  274. package/dist/js/internal/array-callbacks.mjs +0 -19
  275. package/dist/js/internal/array-find.mjs +0 -51
  276. package/dist/js/logger.mjs +0 -69
  277. package/dist/js/models.mjs +0 -0
  278. package/dist/js/string/index.mjs +0 -44
  279. package/dist/js/value/index.mjs +0 -23
  280. package/src/js/internal/array-callbacks.ts +0 -28
  281. package/types/internal/array-callbacks.d.ts +0 -2
  282. package/types/internal/array-find.d.ts +0 -4
@@ -1,16 +1,16 @@
1
- import type { Key } from '../models';
2
- import type { SortKey, SortKeyCallback } from './models';
1
+ import type { SortKey, SortKeyCallback } from '~/array/models';
2
+ import type { Key } from '~/models';
3
3
  /**
4
- * Sorts an array of items _(ascending by default)_
4
+ * Sort an array of items _(defaults to ascending)_
5
5
  */
6
- export declare function sort<Value>(array: Value[], descending?: boolean): Value[];
6
+ export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
7
7
  /**
8
- * - Sorts an array of items, using a `key` to sort by a specific value
9
- * - Ascending by default, but can be changed by setting `descending` to `true`, or using a `SortKey`
8
+ * - Sort an array of items, using a `key` to sort by a specific value
9
+ * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using a `SortKey`
10
10
  */
11
- export declare function sort<Value>(array: Value[], key: Key | SortKey<Value> | SortKeyCallback<Value>, descending?: boolean): Value[];
11
+ export declare function sort<Item>(array: Item[], key: Key | SortKey<Item> | SortKeyCallback<Item>, descending?: boolean): Item[];
12
12
  /**
13
- * - Sorts an array of items, using multiple `keys` to sort by specific values
14
- * - Ascending by default, but can be changed by setting `descending` to `true`, or using `SortKey`
13
+ * - Sort an array of items, using multiple `keys` to sort by specific values
14
+ * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using `SortKey`
15
15
  */
16
- export declare function sort<Value>(array: Value[], keys: Array<Key | SortKey<Value> | SortKeyCallback<Value>>, descending?: boolean): Value[];
16
+ export declare function sort<Item>(array: Item[], keys: Array<Key | SortKey<Item> | SortKeyCallback<Item>>, descending?: boolean): Item[];
@@ -0,0 +1,22 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * Removes and returns all items from an array starting from a specific index
5
+ */
6
+ export declare function splice<Item>(array: Item[], start: number): Item[];
7
+ /**
8
+ * Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
9
+ */
10
+ export declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
11
+ /**
12
+ * - Splices values into an array and returns any removed values
13
+ * - Uses chunking to avoid stack overflow
14
+ */
15
+ export declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
16
+ /**
17
+ * - Splices values into an array and returns any removed values
18
+ * - Uses chunking to avoid stack overflow
19
+ */
20
+ export declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
21
+
22
+ export {};
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Removes and returns all items from an array starting from a specific index
3
3
  */
4
- export declare function splice<Value>(array: Value[], start: number): Value[];
4
+ export declare function splice<Item>(array: Item[], start: number): Item[];
5
5
  /**
6
6
  * Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
7
7
  */
8
- export declare function splice<Value>(array: Value[], start: number, amount: number): Value[];
8
+ export declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
9
9
  /**
10
10
  * - Splices values into an array and returns any removed values
11
11
  * - Uses chunking to avoid stack overflow
12
12
  */
13
- export declare function splice<Value>(array: Value[], start: number, values: Value[]): Value[];
13
+ export declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
14
14
  /**
15
15
  * - Splices values into an array and returns any removed values
16
16
  * - Uses chunking to avoid stack overflow
17
17
  */
18
- export declare function splice<Value>(array: Value[], start: number, amount: number, values: Value[]): Value[];
18
+ export declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
@@ -0,0 +1,61 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
4
+ export type Key = number | string;
5
+ export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
6
+ export type KeyCallback<Item> = ArrayCallback<Item, Key>;
7
+ export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
8
+ /**
9
+ * Create a map from an array of items _(using their indices as keys)_
10
+ */
11
+ export declare function toMap<Item>(array: Item[]): Map<number, Item>;
12
+ /**
13
+ * Create a map from an array of items using a specific key
14
+ */
15
+ export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key): Map<KeyedValue<Item, Key>, Item>;
16
+ /**
17
+ * Create a map from an array of items using a specific key, and grouping them into arrays
18
+ */
19
+ export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Map<KeyedValue<Item, Key>, Item[]>;
20
+ /**
21
+ * Create a map from an array of items using a specific key
22
+ */
23
+ export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Map<ReturnType<Key>, Item>;
24
+ /**
25
+ * Create a map from an array of items using a specific key, and grouping them into arrays
26
+ */
27
+ export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Map<ReturnType<Key>, Item[]>;
28
+ /**
29
+ * Create a map from an array of items using a specific key and value
30
+ */
31
+ export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
32
+ /**
33
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
34
+ */
35
+ export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
36
+ /**
37
+ * Create a map from an array of items using a specific key and value
38
+ */
39
+ export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, ReturnType<Value>>;
40
+ /**
41
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
42
+ */
43
+ export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
44
+ /**
45
+ * Create a map from an array of items using a specific key and value
46
+ */
47
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, KeyedValue<Item, Value>>;
48
+ /**
49
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
50
+ */
51
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
52
+ /**
53
+ * Create a map from an array of items using a specific key and value
54
+ */
55
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, ReturnType<Value>>;
56
+ /**
57
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
58
+ */
59
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
60
+
61
+ export {};
@@ -1,32 +1,54 @@
1
- import type { Key } from '../models';
2
- import type { KeyCallback } from './models';
1
+ import type { KeyCallback, ValueCallback } from '~/array/models';
2
+ import type { KeyedValue } from '~/models';
3
3
  /**
4
- * Converts an array into a map, using indices as keys
4
+ * Create a map from an array of items _(using their indices as keys)_
5
5
  */
6
- export declare function toMap<Value>(array: Value[]): Map<number, Value>;
6
+ export declare function toMap<Item>(array: Item[]): Map<number, Item>;
7
7
  /**
8
- * Converts an array into a map, using indices as keys and grouping values into arrays
8
+ * Create a map from an array of items using a specific key
9
9
  */
10
- export declare function toMap<Value>(array: Value[], arrays: true): Map<number, Value[]>;
10
+ export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key): Map<KeyedValue<Item, Key>, Item>;
11
11
  /**
12
- * - Converts an array into a map
13
- * - Uses `key` to find an identifcation value to use as keys
12
+ * Create a map from an array of items using a specific key, and grouping them into arrays
14
13
  */
15
- export declare function toMap<Value>(array: Value[], key: Key): Map<Key, Value>;
14
+ export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Map<KeyedValue<Item, Key>, Item[]>;
16
15
  /**
17
- * - Converts an array into a map
18
- * - Uses `key` to find an identifcation value to use as keys
19
- * - Groups values into arrays
16
+ * Create a map from an array of items using a specific key
20
17
  */
21
- export declare function toMap<Value>(array: Value[], key: Key, arrays: true): Map<Key, Value[]>;
18
+ export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Map<ReturnType<Key>, Item>;
22
19
  /**
23
- * - Converts an array into a map
24
- * - Uses `key` to find an identifcation value to use as keys
20
+ * Create a map from an array of items using a specific key, and grouping them into arrays
25
21
  */
26
- export declare function toMap<Value>(array: Value[], key: KeyCallback<Value>): Map<Key, Value>;
22
+ export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Map<ReturnType<Key>, Item[]>;
27
23
  /**
28
- * - Converts an array into a map
29
- * - Uses `key` to find an identifcation value to use as keys
30
- * - Groups values into arrays
24
+ * Create a map from an array of items using a specific key and value
31
25
  */
32
- export declare function toMap<Value>(array: Value[], key: KeyCallback<Value>, arrays: true): Map<Key, Value[]>;
26
+ export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
27
+ /**
28
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
29
+ */
30
+ export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
31
+ /**
32
+ * Create a map from an array of items using a specific key and value
33
+ */
34
+ export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, ReturnType<Value>>;
35
+ /**
36
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
37
+ */
38
+ export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
39
+ /**
40
+ * Create a map from an array of items using a specific key and value
41
+ */
42
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, KeyedValue<Item, Value>>;
43
+ /**
44
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
45
+ */
46
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
47
+ /**
48
+ * Create a map from an array of items using a specific key and value
49
+ */
50
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, ReturnType<Value>>;
51
+ /**
52
+ * Create a map from an array of items using a specific key and value, and grouping them into arrays
53
+ */
54
+ export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
@@ -0,0 +1,61 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
4
+ export type Key = number | string;
5
+ export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
6
+ export type KeyCallback<Item> = ArrayCallback<Item, Key>;
7
+ export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
8
+ /**
9
+ * Create a record from an array of items _(using their indices as keys)_
10
+ */
11
+ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
12
+ /**
13
+ * Create a record from an array of items using a specific key
14
+ */
15
+ export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
16
+ /**
17
+ * Create a record from an array of items using a specific key, and grouping them into arrays
18
+ */
19
+ export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
20
+ /**
21
+ * Create a record from an array of items using a specific key
22
+ */
23
+ export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
24
+ /**
25
+ * Create a record from an array of items using a specific key, and grouping them into arrays
26
+ */
27
+ export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
28
+ /**
29
+ * Create a record from an array of items using a specific key and value
30
+ */
31
+ export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
32
+ /**
33
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
34
+ */
35
+ export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
36
+ /**
37
+ * Create a record from an array of items using a specific key and value
38
+ */
39
+ export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
40
+ /**
41
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
42
+ */
43
+ export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
44
+ /**
45
+ * Create a record from an array of items using a specific key and value
46
+ */
47
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
48
+ /**
49
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
50
+ */
51
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
52
+ /**
53
+ * Create a record from an array of items using a specific key and value
54
+ */
55
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
56
+ /**
57
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
58
+ */
59
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
60
+
61
+ export {};
@@ -1,32 +1,54 @@
1
- import type { Key } from '../models';
2
- import type { KeyCallback } from './models';
1
+ import type { KeyCallback, ValueCallback } from '~/array/models';
2
+ import type { KeyedValue } from '~/models';
3
3
  /**
4
- * Converts an array into a record, using indices as keys
4
+ * Create a record from an array of items _(using their indices as keys)_
5
5
  */
6
- export declare function toRecord<Value>(array: Value[]): Record<number, Value>;
6
+ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
7
7
  /**
8
- * Converts an array into a record, using indices as keys and grouping values into arrays
8
+ * Create a record from an array of items using a specific key
9
9
  */
10
- export declare function toRecord<Value>(array: Value[], arrays: true): Record<number, Value[]>;
10
+ export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
11
11
  /**
12
- * - Converts an array into a record
13
- * - Uses `key` to find an identifcation value to use as keys
12
+ * Create a record from an array of items using a specific key, and grouping them into arrays
14
13
  */
15
- export declare function toRecord<Value>(array: Value[], key: Key): Record<Key, Value>;
14
+ export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
16
15
  /**
17
- * - Converts an array into a record
18
- * - Uses `key` to find an identifcation value to use as keys
19
- * - Groups values into arrays
16
+ * Create a record from an array of items using a specific key
20
17
  */
21
- export declare function toRecord<Value>(array: Value[], key: Key, arrays: true): Record<Key, Value[]>;
18
+ export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
22
19
  /**
23
- * - Converts an array into a record
24
- * - Uses `key` to find an identifcation value to use as keys
20
+ * Create a record from an array of items using a specific key, and grouping them into arrays
25
21
  */
26
- export declare function toRecord<Value>(array: Value[], key: KeyCallback<Value>): Record<Key, Value>;
22
+ export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
27
23
  /**
28
- * - Converts an array into a record
29
- * - Uses `key` to find an identifcation value to use as keys
30
- * - Groups values into arrays
24
+ * Create a record from an array of items using a specific key and value
31
25
  */
32
- export declare function toRecord<Value>(array: Value[], key: KeyCallback<Value>, arrays: true): Record<Key, Value[]>;
26
+ export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
27
+ /**
28
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
29
+ */
30
+ export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
31
+ /**
32
+ * Create a record from an array of items using a specific key and value
33
+ */
34
+ export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
35
+ /**
36
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
37
+ */
38
+ export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
39
+ /**
40
+ * Create a record from an array of items using a specific key and value
41
+ */
42
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
43
+ /**
44
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
45
+ */
46
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
47
+ /**
48
+ * Create a record from an array of items using a specific key and value
49
+ */
50
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
51
+ /**
52
+ * Create a record from an array of items using a specific key and value, and grouping them into arrays
53
+ */
54
+ export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
@@ -0,0 +1,21 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type Key = number | string;
4
+ export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
5
+ export type KeyCallback<Item> = ArrayCallback<Item, Key>;
6
+ /**
7
+ * Get an array of unique items
8
+ */
9
+ export declare function unique<Item>(array: Item[]): Item[];
10
+ /**
11
+ * - Get an array of unique items
12
+ * - Use `key` to find a comparison value to match with `value`
13
+ */
14
+ export declare function unique<Item, Key extends keyof Item>(array: Item[], key: Key): Item[];
15
+ /**
16
+ * - Get an array of unique items
17
+ * - Use `key` to find a comparison value to match with `value`
18
+ */
19
+ export declare function unique<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Item[];
20
+
21
+ export {};
@@ -1,11 +1,15 @@
1
- import type { Key } from '../models';
2
- import type { KeyCallback } from './models';
1
+ import type { KeyCallback } from '~/array/models';
3
2
  /**
4
- * Returns an array of unique items
3
+ * Get an array of unique items
5
4
  */
6
- export declare function unique<Value>(array: Value[]): Value[];
5
+ export declare function unique<Item>(array: Item[]): Item[];
7
6
  /**
8
- * - Returns an array of unique items
7
+ * - Get an array of unique items
9
8
  * - Use `key` to find a comparison value to match with `value`
10
9
  */
11
- export declare function unique<Value>(array: Value[], key: Key | KeyCallback<Value>): Value[];
10
+ export declare function unique<Item, Key extends keyof Item>(array: Item[], key: Key): Item[];
11
+ /**
12
+ * - Get an array of unique items
13
+ * - Use `key` to find a comparison value to match with `value`
14
+ */
15
+ export declare function unique<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Item[];
@@ -0,0 +1,153 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type HSLColourValue = {
4
+ hue: number;
5
+ lightness: number;
6
+ saturation: number;
7
+ };
8
+ declare class HSLColour extends Colour<HSLColourValue> {
9
+ /**
10
+ * Get the current hue
11
+ */
12
+ get hue(): number;
13
+ /**
14
+ * Set the current hue
15
+ */
16
+ set hue(value: number);
17
+ /**
18
+ * Get the current lightness
19
+ */
20
+ get lightness(): number;
21
+ /**
22
+ * Set the current lightness
23
+ */
24
+ set lightness(value: number);
25
+ /**
26
+ * Get the current saturation
27
+ */
28
+ get saturation(): number;
29
+ /**
30
+ * Set the current saturation
31
+ */
32
+ set saturation(value: number);
33
+ constructor(value: HSLColourValue);
34
+ /**
35
+ * @inheritdoc
36
+ */
37
+ toHex(): HexColour;
38
+ /**
39
+ * Convert the colour to an RGB-colour
40
+ */
41
+ toRgb(): RGBColour;
42
+ /**
43
+ * @inheritdoc
44
+ */
45
+ toString(): string;
46
+ /**
47
+ * Convert an HSL-colour to an RGB-colour
48
+ */
49
+ static toRgb(value: HSLColourValue): RGBColour;
50
+ }
51
+ declare class HexColour {
52
+ private readonly $colour;
53
+ private readonly state;
54
+ /**
55
+ * Get the value of the colour
56
+ */
57
+ get value(): string;
58
+ /**
59
+ * Set the value of the colour
60
+ */
61
+ set value(value: string);
62
+ constructor(value: string);
63
+ /**
64
+ * Convert the colour to an RGB-colour
65
+ */
66
+ toHsl(): HSLColour;
67
+ /**
68
+ * Convert the colour to an HSL-colour
69
+ */
70
+ toRgb(): RGBColour;
71
+ /**
72
+ * Get the colour as a string _(prefixed with #)_
73
+ */
74
+ toString(): string;
75
+ /**
76
+ * Convert a hex-colour to an RGB-colour
77
+ */
78
+ static toRgb(value: string): RGBColour;
79
+ }
80
+ export declare abstract class Colour<Model> {
81
+ private readonly $colour;
82
+ protected readonly state: ColourState<Model>;
83
+ /**
84
+ * Get the current value of the colour
85
+ */
86
+ get value(): Model;
87
+ constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
88
+ /**
89
+ * Convert the colour to a hex-colour
90
+ */
91
+ abstract toHex(): HexColour;
92
+ /**
93
+ * Get the colour as a _CSS-formatted_ string
94
+ */
95
+ abstract toString(): string;
96
+ }
97
+ export type ColourState<Model> = {
98
+ value: Model;
99
+ };
100
+ export type RGBColourValue = {
101
+ blue: number;
102
+ green: number;
103
+ red: number;
104
+ };
105
+ declare class RGBColour extends Colour<RGBColourValue> {
106
+ /**
107
+ * Get the current blue value
108
+ */
109
+ get blue(): number;
110
+ /**
111
+ * Set the current blue value
112
+ */
113
+ set blue(value: number);
114
+ /**
115
+ * Get the current green value
116
+ */
117
+ get green(): number;
118
+ /**
119
+ * Set the current green value
120
+ */
121
+ set green(value: number);
122
+ /**
123
+ * Get the current red value
124
+ */
125
+ get red(): number;
126
+ /**
127
+ * Set the current red value
128
+ */
129
+ set red(value: number);
130
+ constructor(value: RGBColourValue);
131
+ /**
132
+ * @inheritdoc
133
+ */
134
+ toHex(): HexColour;
135
+ /**
136
+ * Convert the colour to an HSL-colour
137
+ */
138
+ toHsl(): HSLColour;
139
+ /**
140
+ * @inheritdoc
141
+ */
142
+ toString(): string;
143
+ /**
144
+ * Convert an RGB-colour to a hex-colour
145
+ */
146
+ static toHex(value: RGBColourValue): HexColour;
147
+ /**
148
+ * - Convert an RGB-colour to an HSL-colour
149
+ */
150
+ static toHsl(rgb: RGBColourValue): HSLColour;
151
+ }
152
+
153
+ export {};
@@ -1,9 +1,9 @@
1
- import type { HexColour } from './hex';
1
+ import type { HexColour } from '~/colour/hex';
2
2
  export declare abstract class Colour<Model> {
3
3
  private readonly $colour;
4
4
  protected readonly state: ColourState<Model>;
5
5
  /**
6
- * Gets the current value of the colour
6
+ * Get the current value of the colour
7
7
  */
8
8
  get value(): Model;
9
9
  constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);