@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
package/dist/js/index.js CHANGED
@@ -1,1727 +1,136 @@
1
- // src/js/array/chunk.ts
2
- function chunk(array, size) {
3
- const { length } = array;
4
- const chunkSize = typeof size === "number" && size > 0 ? size : 64000;
5
- if (length <= chunkSize) {
6
- return [array];
7
- }
8
- const chunks = [];
9
- let remaining = Number(length);
10
- while (remaining > 0) {
11
- chunks.push(array.splice(0, chunkSize));
12
- remaining -= chunkSize;
13
- }
14
- return chunks;
15
- }
16
-
17
- // src/js/array/insert.ts
18
- function insert(array, index, values) {
19
- insertValues("splice", array, values, index, 0);
20
- }
21
- function insertValues(type, array, values, start, deleteCount) {
22
- const chunked = chunk(values);
23
- const lastIndex = chunked.length - 1;
24
- let index = Number(chunked.length);
25
- let returned;
26
- while (--index >= 0) {
27
- const result = array.splice(start, index === lastIndex ? deleteCount : 0, ...chunked[index]);
28
- if (returned == null) {
29
- returned = result;
30
- }
31
- }
32
- return type === "splice" ? returned : array.length;
33
- }
34
-
35
- // src/js/array/index.ts
36
- function flatten2(array) {
37
- return array.flat(Number.POSITIVE_INFINITY);
38
- }
39
- function push(array, values) {
40
- return insertValues("push", array, values, array.length, 0);
41
- }
42
-
43
- // src/js/array/compact.ts
44
- function compact(array, strict) {
45
- return strict === true ? array.filter((item) => !!item) : array.filter((item) => item != null);
46
- }
47
- // src/js/internal/array-callbacks.ts
48
- function getCallbacks(bool, key) {
49
- if (typeof bool === "function") {
50
- return { bool };
51
- }
52
- if (typeof key === "function") {
53
- return { key };
54
- }
55
- const isString = typeof key === "string";
56
- if (!isString && typeof key !== "number" || isString && key.includes(".")) {
57
- return;
58
- }
59
- return {
60
- key: (value) => value?.[key]
61
- };
62
- }
63
-
64
- // src/js/internal/array-find.ts
65
- function findValue(type, array, value, key) {
66
- const callbacks = getCallbacks(value, key);
67
- if (callbacks?.bool == null && callbacks?.key == null) {
68
- return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
69
- }
70
- if (callbacks.bool != null) {
71
- const index = array.findIndex(callbacks.bool);
72
- return type === "index" ? index : index > -1 ? array[index] : undefined;
73
- }
74
- const { length } = array;
75
- for (let index = 0;index < length; index += 1) {
76
- const item = array[index];
77
- if (callbacks.key?.(item, index, array) === value) {
78
- return type === "index" ? index : item;
79
- }
80
- }
81
- return type === "index" ? -1 : undefined;
82
- }
83
- function findValues(type, array, value, key) {
84
- const callbacks = getCallbacks(value, key);
85
- const { length } = array;
86
- if (type === "unique" && callbacks?.key == null && length >= 100) {
87
- return Array.from(new Set(array));
88
- }
89
- if (typeof callbacks?.bool === "function") {
90
- return array.filter(callbacks.bool);
91
- }
92
- if (type === "all" && key == null) {
93
- return array.filter((item) => item === value);
94
- }
95
- const hasCallback = typeof callbacks?.key === "function";
96
- const result = [];
97
- const values = hasCallback ? [] : result;
98
- for (let index = 0;index < length; index += 1) {
99
- const item = array[index];
100
- const itemKey = hasCallback ? callbacks.key?.(item, index, array) : item;
101
- if (type === "all" && itemKey === value || type === "unique" && values.indexOf(itemKey) === -1) {
102
- if (values !== result) {
103
- values.push(itemKey);
104
- }
105
- result.push(item);
106
- }
107
- }
108
- return result;
109
- }
110
-
111
- // src/js/array/count.ts
112
- function count(array, value, key) {
113
- return findValues("all", array, value, key).length;
114
- }
115
- // src/js/array/exists.ts
116
- function exists(array, value, key) {
117
- return findValue("index", array, value, key) > -1;
118
- }
119
- // src/js/array/filter.ts
120
- function filter(array, value, key) {
121
- return findValues("all", array, value, key);
122
- }
123
- // src/js/array/find.ts
124
- function find(array, value, key) {
125
- return findValue("value", array, value, key);
126
- }
127
- // src/js/array/group-by.ts
128
- function groupBy(array, key) {
129
- return groupValues(array, key, true, false);
130
- }
131
- function groupValues(array, key, arrays, indicable) {
132
- const callbacks = getCallbacks(undefined, key);
133
- const hasCallback = typeof callbacks?.key === "function";
134
- if (!hasCallback && !indicable) {
135
- return {};
136
- }
137
- const record = {};
138
- const { length } = array;
139
- for (let index = 0;index < length; index += 1) {
140
- const value = array[index];
141
- const key2 = hasCallback ? callbacks?.key?.(value, index, array) ?? index : index;
142
- if (arrays) {
143
- const existing = record[key2];
144
- if (Array.isArray(existing)) {
145
- existing.push(value);
146
- } else {
147
- record[key2] = [value];
148
- }
149
- } else {
150
- record[key2] = value;
151
- }
152
- }
153
- return record;
154
- }
155
- // src/js/array/index-of.ts
156
- function indexOf(array, value, key) {
157
- return findValue("index", array, value, key);
158
- }
159
- // src/js/random.ts
160
- function getRandomBoolean() {
161
- return Math.random() > 0.5;
162
- }
163
- function getRandomCharacters(length, selection) {
164
- if (length < 1) {
165
- return "";
166
- }
167
- const actual = typeof selection === "string" && selection.length > 0 ? selection : "abcdefghijklmnopqrstuvwxyz";
168
- let characters = "";
169
- for (let index = 0;index < length; index += 1) {
170
- characters += actual.charAt(getRandomInteger(0, actual.length));
171
- }
172
- return characters;
173
- }
174
- function getRandomColour() {
175
- return `#${Array.from({ length: 6 }, getRandomHex).join("")}`;
176
- }
177
- function getRandomDate(earliest, latest) {
178
- const earliestTime = earliest?.getTime() ?? -8640000000000000;
179
- const latestTime = latest?.getTime() ?? 8640000000000000;
180
- return new Date(getRandomInteger(earliestTime, latestTime));
181
- }
182
- function getRandomFloat(min, max) {
183
- const minimum = min ?? Number.MIN_SAFE_INTEGER;
184
- return Math.random() * ((max ?? Number.MAX_SAFE_INTEGER) - minimum) + minimum;
185
- }
186
- function getRandomHex() {
187
- return "0123456789ABCDEF"[getRandomInteger(0, 16)];
188
- }
189
- function getRandomInteger(min, max) {
190
- return Math.floor(getRandomFloat(min, max));
191
- }
192
- function getRandomItem(array) {
193
- return array[getRandomInteger(0, array.length)];
194
- }
195
- function getRandomItems(array, amount) {
196
- if (amount === 1) {
197
- return array.length === 0 ? [] : [array[getRandomInteger(0, array.length)]];
198
- }
199
- return amount == null || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
200
- }
201
-
202
- // src/js/array/shuffle.ts
203
- function shuffle(array) {
204
- const shuffled = array.slice();
205
- const { length } = shuffled;
206
- for (let index = 0;index < length; index += 1) {
207
- const random = getRandomInteger(0, length);
208
- [shuffled[index], shuffled[random]] = [shuffled[random], shuffled[index]];
209
- }
210
- return shuffled;
211
- }
212
- // src/js/string/index.ts
213
- function createUuid() {
214
- return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (substring) => (substring ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> substring / 4).toString(16));
215
- }
216
- function getString(value) {
217
- if (typeof value === "string") {
218
- return value;
219
- }
220
- if (typeof value !== "object" || value == null) {
221
- return String(value);
222
- }
223
- const valueOff = value.valueOf?.() ?? value;
224
- const asString = valueOff?.toString?.() ?? String(valueOff);
225
- return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
226
- }
227
- function join(value, delimiter) {
228
- return compact(value).map(getString).filter((value2) => value2.trim().length > 0).join(typeof delimiter === "string" ? delimiter : "");
229
- }
230
- function parse(value, reviver) {
231
- try {
232
- return JSON.parse(value, reviver);
233
- } catch {
234
- }
235
- }
236
- function truncate(value, length, suffix) {
237
- const suffixLength = suffix?.length ?? 0;
238
- const truncatedLength = length - suffixLength;
239
- return value.length <= length ? value : `${value.slice(0, truncatedLength)}${suffix ?? ""}`;
240
- }
241
- function words(value) {
242
- return value.match(/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g) ?? [];
243
- }
244
-
245
- // src/js/string/case.ts
246
- function camelCase(value) {
247
- return toCase(value, "", true, false);
248
- }
249
- function capitalise(value) {
250
- if (value.length === 0) {
251
- return value;
252
- }
253
- return value.length === 1 ? value.toLocaleUpperCase() : `${value.charAt(0).toLocaleUpperCase()}${value.slice(1).toLocaleLowerCase()}`;
254
- }
255
- function kebabCase(value) {
256
- return toCase(value, "-", false, false);
257
- }
258
- function pascalCase(value) {
259
- return toCase(value, "", true, true);
260
- }
261
- function snakeCase(value) {
262
- return toCase(value, "_", false, false);
263
- }
264
- function titleCase(value) {
265
- return words(value).map(capitalise).join(" ");
266
- }
267
- function toCase(value, delimiter, capitaliseAny, capitaliseFirst) {
268
- return words(value).map((word, index) => {
269
- const parts = word.replace(/(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").split("-");
270
- return parts.filter((part) => part.length > 0).map((part, partIndex) => !capitaliseAny || partIndex === 0 && index === 0 && !capitaliseFirst ? part.toLocaleLowerCase() : capitalise(part)).join(delimiter);
271
- }).join(delimiter);
272
- }
273
- // src/js/value/index.ts
274
- function partial(value, keys) {
275
- const result = {};
276
- const { length } = keys;
277
- for (let index = 0;index < length; index += 1) {
278
- const key = keys[index];
279
- result[key] = value[key];
280
- }
281
- return result;
282
- }
283
-
284
- // src/js/value/clone.ts
285
- function clone(value) {
286
- switch (true) {
287
- case value == null:
288
- return value;
289
- case typeof value === "bigint":
290
- return BigInt(value);
291
- case typeof value === "boolean":
292
- return Boolean(value);
293
- case typeof value === "function":
294
- return;
295
- case typeof value === "number":
296
- return Number(value);
297
- case typeof value === "string":
298
- return String(value);
299
- case typeof value === "symbol":
300
- return Symbol(value.description);
301
- case value instanceof ArrayBuffer:
302
- return cloneArrayBuffer(value);
303
- case value instanceof DataView:
304
- return cloneDataView(value);
305
- case value instanceof Map:
306
- case value instanceof Set:
307
- return cloneMapOrSet(value);
308
- case value instanceof Node:
309
- return value.cloneNode(true);
310
- case value instanceof RegExp:
311
- return cloneRegularExpression(value);
312
- case isArrayOrPlainObject(value):
313
- return cloneObject(value);
314
- default:
315
- return structuredClone(value);
316
- }
317
- }
318
- function cloneArrayBuffer(value) {
319
- const cloned = new ArrayBuffer(value.byteLength);
320
- new Uint8Array(cloned).set(new Uint8Array(value));
321
- return cloned;
322
- }
323
- function cloneDataView(value) {
324
- const buffer = cloneArrayBuffer(value.buffer);
325
- return new DataView(buffer, value.byteOffset, value.byteLength);
326
- }
327
- function cloneMapOrSet(value) {
328
- const isMap = value instanceof Map;
329
- const cloned = isMap ? new Map : new Set;
330
- const entries = [...value.entries()];
331
- const { length } = entries;
332
- for (let index = 0;index < length; index += 1) {
333
- const entry = entries[index];
334
- if (isMap) {
335
- cloned.set(clone(entry[0]), clone(entry[1]));
336
- } else {
337
- cloned.add(clone(entry[0]));
338
- }
339
- }
340
- return cloned;
341
- }
342
- function cloneObject(value) {
343
- const cloned = Array.isArray(value) ? [] : {};
344
- const keys = Object.keys(value);
345
- const { length } = keys;
346
- for (let index = 0;index < length; index += 1) {
347
- const key = keys[index];
348
- cloned[key] = clone(value[key]);
349
- }
350
- return cloned;
351
- }
352
- function cloneRegularExpression(value) {
353
- const cloned = new RegExp(value.source, value.flags);
354
- cloned.lastIndex = value.lastIndex;
355
- return cloned;
356
- }
357
- // src/js/math.ts
358
- function average(values) {
359
- return values.length > 0 ? sum(values) / values.length : Number.NaN;
360
- }
361
- function max(values) {
362
- return values.length > 0 ? Math.max(...values) : Number.NaN;
363
- }
364
- function min(values) {
365
- return values.length > 0 ? Math.min(...values) : Number.NaN;
366
- }
367
- function round(value, decimals) {
368
- if (typeof decimals !== "number" || decimals < 1) {
369
- return Math.round(value);
370
- }
371
- const mod = 10 ** decimals;
372
- return Math.round((value + Number.EPSILON) * mod) / mod;
373
- }
374
- function sum(values) {
375
- return values.reduce((previous, current) => previous + current, 0);
376
- }
377
-
378
- // src/js/number.ts
379
- function between(value, min2, max2) {
380
- return value >= min2 && value <= max2;
381
- }
382
- function clamp(value, min2, max2, loop) {
383
- if (value < min2) {
384
- return loop === true ? max2 : min2;
385
- }
386
- return value > max2 ? loop === true ? min2 : max2 : value;
387
- }
388
- function getNumber(value) {
389
- if (typeof value === "number") {
390
- return value;
391
- }
392
- if (typeof value === "symbol") {
393
- return Number.NaN;
394
- }
395
- let parsed = value?.valueOf?.() ?? value;
396
- if (typeof parsed === "object") {
397
- parsed = parsed?.toString() ?? parsed;
398
- }
399
- if (typeof parsed !== "string") {
400
- return parsed == null ? Number.NaN : typeof parsed === "number" ? parsed : +parsed;
401
- }
402
- if (/^\s*0+\s*$/.test(parsed)) {
403
- return 0;
404
- }
405
- const trimmed = parsed.trim();
406
- if (trimmed.length === 0) {
407
- return Number.NaN;
408
- }
409
- const isBinary = /^0b[01]+$/i.test(trimmed);
410
- if (isBinary || /^0o[0-7]+$/i.test(trimmed)) {
411
- return Number.parseInt(trimmed.slice(2), isBinary ? 2 : 8);
412
- }
413
- return +(/^0x[0-9a-f]+$/i.test(trimmed) ? trimmed : trimmed.replace(/_/g, ""));
414
- }
415
-
416
- // src/js/value/compare.ts
417
- function compare(first, second) {
418
- const firstParts = getParts(first);
419
- const secondParts = getParts(second);
420
- const length = max([firstParts.length, secondParts.length]);
421
- const lastIndex = length - 1;
422
- for (let index = 0;index < length; index += 1) {
423
- const firstPart = firstParts[index];
424
- const secondPart = secondParts[index];
425
- if (firstPart === secondPart) {
426
- if (index === lastIndex) {
427
- return 0;
428
- }
429
- continue;
430
- }
431
- if (firstPart == null || typeof firstPart === "string" && firstPart.length === 0) {
432
- return -1;
433
- }
434
- if (secondPart == null || typeof secondPart === "string" && secondPart.length === 0) {
435
- return 1;
436
- }
437
- const firstNumber = getNumber(firstPart);
438
- const secondNumber = getNumber(secondPart);
439
- const firstIsNaN = Number.isNaN(firstNumber);
440
- const secondIsNaN = Number.isNaN(secondNumber);
441
- if (firstIsNaN || secondIsNaN) {
442
- if (firstIsNaN && secondIsNaN) {
443
- return getString(firstPart).localeCompare(getString(secondPart));
444
- }
445
- if (firstIsNaN) {
446
- return 1;
447
- }
448
- if (secondIsNaN) {
449
- return -1;
450
- }
451
- }
452
- if (firstNumber === secondNumber) {
453
- if (index === lastIndex) {
454
- return 0;
455
- }
456
- continue;
457
- }
458
- return firstNumber - secondNumber;
459
- }
460
- return join(firstParts).localeCompare(join(secondParts));
461
- }
462
- function getParts(value) {
463
- if (value == null) {
464
- return [""];
465
- }
466
- if (Array.isArray(value)) {
467
- return value;
468
- }
469
- return typeof value === "object" ? [value] : words(getString(value));
470
- }
471
- // src/js/value/equal.ts
472
- function equal(first, second, ignoreCase) {
473
- switch (true) {
474
- case first === second:
475
- return true;
476
- case (first == null || second == null):
477
- return first === second;
478
- case typeof first !== typeof second:
479
- return false;
480
- case (first instanceof ArrayBuffer && second instanceof ArrayBuffer):
481
- return equalArrayBuffer(first, second);
482
- case typeof first === "boolean":
483
- case (first instanceof Date && second instanceof Date):
484
- return Object.is(Number(first), Number(second));
485
- case (first instanceof DataView && second instanceof DataView):
486
- return equalDataView(first, second);
487
- case (first instanceof Error && second instanceof Error):
488
- return equalProperties(first, second, ["name", "message"]);
489
- case (first instanceof Map && second instanceof Map):
490
- return equalMap(first, second);
491
- case (first instanceof RegExp && second instanceof RegExp):
492
- return equalProperties(first, second, ["source", "flags"]);
493
- case (first instanceof Set && second instanceof Set):
494
- return equalSet(first, second);
495
- case (Array.isArray(first) && Array.isArray(second)):
496
- case (isPlainObject(first) && isPlainObject(second)):
497
- return equalObject(first, second);
498
- case (typeof first === "string" && ignoreCase === true):
499
- return Object.is(first.toLowerCase(), second.toLowerCase());
500
- default:
501
- return Object.is(first, second);
502
- }
503
- }
504
- function equalArrayBuffer(first, second) {
505
- return first.byteLength === second.byteLength ? equalObject(new Uint8Array(first), new Uint8Array(second)) : false;
506
- }
507
- function equalDataView(first, second) {
508
- return first.byteOffset === second.byteOffset ? equalArrayBuffer(first.buffer, second.buffer) : false;
509
- }
510
- function equalMap(first, second) {
511
- const { size } = first;
512
- if (size !== second.size) {
513
- return false;
514
- }
515
- const firstKeys = [...first.keys()];
516
- const secondKeys = [...second.keys()];
517
- if (firstKeys.some((key) => !secondKeys.includes(key))) {
518
- return false;
519
- }
520
- for (let index = 0;index < size; index += 1) {
521
- const key = firstKeys[index];
522
- if (!equal(first.get(key), second.get(key))) {
523
- return false;
524
- }
525
- }
526
- return true;
527
- }
528
- function equalObject(first, second) {
529
- const firstKeys = Object.keys(first);
530
- const secondKeys = Object.keys(second);
531
- const { length } = firstKeys;
532
- if (length !== secondKeys.length || firstKeys.some((key) => !secondKeys.includes(key))) {
533
- return false;
534
- }
535
- for (let index = 0;index < length; index += 1) {
536
- const key = firstKeys[index];
537
- if (!equal(first[key], second[key])) {
538
- return false;
539
- }
540
- }
541
- return true;
542
- }
543
- function equalProperties(first, second, properties) {
544
- const { length } = properties;
545
- for (let index = 0;index < length; index += 1) {
546
- const property = properties[index];
547
- if (!equal(first[property], second[property])) {
548
- return false;
549
- }
550
- }
551
- return true;
552
- }
553
- function equalSet(first, second) {
554
- const { size } = first;
555
- if (size !== second.size) {
556
- return false;
557
- }
558
- const firstValues = [...first];
559
- const secondValues = [...second];
560
- for (let index = 0;index < size; index += 1) {
561
- const firstValue = firstValues[index];
562
- if (!secondValues.some((secondValue) => equal(firstValue, secondValue))) {
563
- return false;
564
- }
565
- }
566
- return true;
567
- }
568
-
569
- // src/js/value/diff.ts
570
- function diff(first, second) {
571
- const result = {
572
- original: {
573
- from: first,
574
- to: second
575
- },
576
- type: "partial",
577
- values: {}
578
- };
579
- const same = Object.is(first, second);
580
- const firstIsArrayOrObject = isArrayOrPlainObject(first);
581
- const secondIsArrayOrObject = isArrayOrPlainObject(second);
582
- if (same || !firstIsArrayOrObject && !secondIsArrayOrObject) {
583
- result.type = same ? "none" : "full";
584
- return result;
585
- }
586
- if (firstIsArrayOrObject !== secondIsArrayOrObject) {
587
- result.type = "full";
588
- }
589
- const diffs = getDiffs(first, second);
590
- const { length } = diffs;
591
- if (length === 0) {
592
- result.type = "none";
593
- }
594
- for (let index = 0;index < length; index += 1) {
595
- const diff2 = diffs[index];
596
- result.values[diff2.key] = { from: diff2.from, to: diff2.to };
597
- }
598
- return result;
599
- }
600
- function getDiffs(first, second, prefix) {
601
- const changes = [];
602
- const checked = new Set;
603
- for (let outerIndex = 0;outerIndex < 2; outerIndex += 1) {
604
- const value = outerIndex === 0 ? first : second;
605
- if (!value) {
606
- continue;
607
- }
608
- const keys = Object.keys(value);
609
- const { length } = keys;
610
- for (let innerIndex = 0;innerIndex < length; innerIndex += 1) {
611
- const key = keys[innerIndex];
612
- if (checked.has(key)) {
613
- continue;
614
- }
615
- const from = first?.[key];
616
- const to = second?.[key];
617
- if (!equal(from, to)) {
618
- const prefixed = join([prefix, key], ".");
619
- const change = {
620
- from,
621
- to,
622
- key: prefixed
623
- };
624
- const nested = isArrayOrPlainObject(from) || isArrayOrPlainObject(to);
625
- const diffs = nested ? getDiffs(from, to, prefixed) : [];
626
- if (!nested || nested && diffs.length > 0) {
627
- changes.push(change);
628
- }
629
- changes.push(...diffs);
630
- }
631
- checked.add(key);
632
- }
633
- }
634
- return changes;
635
- }
636
- // src/js/internal/value-handle.ts
637
- function findKey(needle, haystack, ignoreCase) {
638
- if (!ignoreCase) {
639
- return needle;
640
- }
641
- const keys = Object.keys(haystack);
642
- const normalised = keys.map((key) => key.toLowerCase());
643
- const index = normalised.indexOf(needle.toLowerCase());
644
- return index > -1 ? keys[index] : needle;
645
- }
646
- function handleValue(data, path, value, get, ignoreCase) {
647
- if (typeof data === "object" && data !== null && !/^(__proto__|constructor|prototype)$/i.test(path)) {
648
- const key = findKey(path, data, ignoreCase);
649
- if (get) {
650
- return data[key];
651
- }
652
- data[key] = value;
653
- }
654
- }
655
-
656
- // src/js/value/get.ts
657
- function getValue(data, path, ignoreCase) {
658
- const shouldIgnoreCase = ignoreCase === true;
659
- const parts = (shouldIgnoreCase ? path.toLowerCase() : path).split(".");
660
- const { length } = parts;
661
- let index = 0;
662
- let value = typeof data === "object" ? data ?? {} : {};
663
- while (index < length && value != null) {
664
- value = handleValue(value, parts[index++], null, true, shouldIgnoreCase);
665
- }
666
- return value;
667
- }
668
- // src/js/value/merge.ts
669
- function merge(values, options) {
670
- if (values.length === 0) {
671
- return {};
672
- }
673
- const skipNullable = options?.skipNullable ?? false;
674
- const actual = values.filter((value) => isArrayOrPlainObject(value));
675
- const result = actual.every(Array.isArray) ? [] : {};
676
- const isArray = Array.isArray(result);
677
- const { length } = actual;
678
- for (let outerIndex = 0;outerIndex < length; outerIndex += 1) {
679
- const item = actual[outerIndex];
680
- const keys = Object.keys(item);
681
- const size = keys.length;
682
- for (let innerIndex = 0;innerIndex < size; innerIndex += 1) {
683
- const key = keys[innerIndex];
684
- const next = item[key];
685
- const previous = result[key];
686
- if (isArray && skipNullable && next == null) {
687
- continue;
688
- }
689
- if (isArrayOrPlainObject(next)) {
690
- result[key] = isArrayOrPlainObject(previous) ? merge([previous, next]) : merge([next]);
691
- } else {
692
- result[key] = next;
693
- }
694
- }
695
- }
696
- return result;
697
- }
698
- // src/js/value/set.ts
699
- function setValue(data, path, value, ignoreCase) {
700
- const shouldIgnoreCase = ignoreCase === true;
701
- const parts = (shouldIgnoreCase ? path.toLowerCase() : path).split(".");
702
- const { length } = parts;
703
- const lastIndex = length - 1;
704
- let target = typeof data === "object" && data !== null ? data : {};
705
- for (let index = 0;index < length; index += 1) {
706
- const part = parts[index];
707
- if (index === lastIndex) {
708
- handleValue(target, part, value, false, shouldIgnoreCase);
709
- break;
710
- }
711
- let next = handleValue(target, part, null, true, shouldIgnoreCase);
712
- if (typeof next !== "object" || next === null) {
713
- next = {};
714
- target[part] = next;
715
- }
716
- target = next;
717
- }
718
- return data;
719
- }
720
- // src/js/value/smush.ts
721
- function flatten(value, prefix) {
722
- const keys = Object.keys(value);
723
- const { length } = keys;
724
- const smushed = {};
725
- for (let index = 0;index < length; index += 1) {
726
- const key = keys[index];
727
- const val = value[key];
728
- if (isArrayOrPlainObject(val)) {
729
- Object.assign(smushed, {
730
- [join([prefix, key], ".")]: Array.isArray(val) ? [...val] : { ...val },
731
- ...flatten(val, join([prefix, key], "."))
732
- });
733
- } else {
734
- smushed[join([prefix, key], ".")] = val;
735
- }
736
- }
737
- return smushed;
738
- }
739
- function smush(value) {
740
- return flatten(value);
741
- }
742
- // src/js/value/unsmush.ts
743
- function getKeyGroups(value) {
744
- const keys = Object.keys(value);
745
- const { length } = keys;
746
- const grouped = [];
747
- for (let index = 0;index < length; index += 1) {
748
- const key = keys[index];
749
- const dots = key.split(".");
750
- if (grouped[dots.length] == null) {
751
- grouped[dots.length] = [key];
752
- } else {
753
- grouped[dots.length].push(key);
754
- }
755
- }
756
- return grouped;
757
- }
758
- function unsmush(value) {
759
- const groups = getKeyGroups(value);
760
- const { length } = groups;
761
- const unsmushed = {};
762
- for (let groupIndex = 1;groupIndex < length; groupIndex += 1) {
763
- const group = groups[groupIndex];
764
- const groupLength = group.length;
765
- for (let keyIndex = 0;keyIndex < groupLength; keyIndex += 1) {
766
- const key = group[keyIndex];
767
- const val = value[key];
768
- setValue(unsmushed, key, isArrayOrPlainObject(val) ? Array.isArray(val) ? [...val] : { ...val } : val);
769
- }
770
- }
771
- return unsmushed;
772
- }
773
- // src/js/string/template.ts
774
- function template(value, variables, options) {
775
- const ignoreCase = options?.ignoreCase === true;
776
- const pattern = options?.pattern instanceof RegExp ? options.pattern : /{{([\s\S]+?)}}/g;
777
- const values = {};
778
- return value.replace(pattern, (_, key) => {
779
- if (values[key] != null) {
780
- return values[key];
781
- }
782
- const value2 = getValue(variables, key, ignoreCase);
783
- if (value2 == null) {
784
- return "";
785
- }
786
- values[key] = getString(value2);
787
- return values[key];
788
- });
789
- }
790
- // src/js/is.ts
791
- function isArrayOrPlainObject(value) {
792
- return Array.isArray(value) || isPlainObject(value);
793
- }
794
- function isEmpty(value) {
795
- const values = Object.values(value);
796
- const { length } = values;
797
- let count2 = 0;
798
- for (let index = 0;index < length; index += 1) {
799
- if (values[index] != null) {
800
- count2 += 1;
801
- }
802
- }
803
- return count2 === 0;
804
- }
805
- function isKey(value) {
806
- return typeof value === "number" || typeof value === "string";
807
- }
808
- function isNullable(value) {
809
- return value == null;
810
- }
811
- function isNullableOrEmpty(value) {
812
- return value == null || getString(value) === "";
813
- }
814
- function isNullableOrWhitespace(value) {
815
- return value == null || /^\s*$/.test(getString(value));
816
- }
817
- function isNumber(value) {
818
- return typeof value === "number" && !Number.isNaN(value);
819
- }
820
- function isNumerical(value) {
821
- return isNumber(value) || typeof value === "string" && value.trim().length > 0 && !Number.isNaN(+value);
822
- }
823
- function isObject(value) {
824
- return typeof value === "object" && value !== null || typeof value === "function";
825
- }
826
- function isPlainObject(value) {
827
- if (typeof value !== "object" || value === null) {
828
- return false;
829
- }
830
- const prototype = Object.getPrototypeOf(value);
831
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
832
- }
833
- function isPrimitive(value) {
834
- return value == null || /^(bigint|boolean|number|string|symbol)$/.test(typeof value);
835
- }
836
-
837
- // src/js/array/sort.ts
838
- function sort(array, first, second) {
839
- if (array.length < 2) {
840
- return array;
841
- }
842
- if (first == null || typeof first === "boolean") {
843
- return first === true ? array.sort((first2, second2) => second2 - first2) : array.sort();
844
- }
845
- const direction = second === true ? "desc" : "asc";
846
- const keys = (Array.isArray(first) ? first : [first]).map((key) => {
847
- const returned = {
848
- direction,
849
- callback: undefined
850
- };
851
- if (isKey(key)) {
852
- returned.callback = (value) => value[key];
853
- } else if (typeof key === "function") {
854
- returned.callback = key;
855
- } else if (typeof key?.value === "function" || isKey(key?.value)) {
856
- returned.direction = key?.direction ?? direction;
857
- returned.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
858
- }
859
- return returned;
860
- }).filter((key) => typeof key.callback === "function");
861
- const { length } = keys;
862
- if (length === 0) {
863
- return direction === "asc" ? array.sort() : array.sort((first2, second2) => second2 - first2);
864
- }
865
- if (length === 1) {
866
- return array.sort((first2, second2) => compare(keys[0].callback(first2), keys[0].callback(second2)) * (keys[0].direction === "asc" ? 1 : -1));
867
- }
868
- const sorted = array.sort((first2, second2) => {
869
- for (let index = 0;index < length; index += 1) {
870
- const { callback, direction: direction2 } = keys[index];
871
- const descending = direction2 === "desc";
872
- const compared = compare(callback(descending ? second2 : first2), callback(descending ? first2 : second2));
873
- if (compared !== 0) {
874
- return compared;
875
- }
876
- }
877
- return 0;
878
- });
879
- return sorted;
880
- }
881
- // src/js/array/splice.ts
882
- function splice(array, start, amountOrValues, values) {
883
- const amoutOrValuesIsArray = Array.isArray(amountOrValues);
884
- return insertValues("splice", array, amoutOrValuesIsArray ? amountOrValues : values ?? [], start, amoutOrValuesIsArray ? array.length : typeof amountOrValues === "number" && amountOrValues > 0 ? amountOrValues : 0);
885
- }
886
- // src/js/array/to-map.ts
887
- function toMap(array, first, second) {
888
- const asArrays = first === true || second === true;
889
- const callbacks = getCallbacks(undefined, first);
890
- const hasCallback = typeof callbacks?.key === "function";
891
- const map = new Map;
892
- const { length } = array;
893
- for (let index = 0;index < length; index += 1) {
894
- const value = array[index];
895
- const key = hasCallback ? callbacks?.key?.(value, index, array) ?? index : index;
896
- if (asArrays) {
897
- const existing = map.get(key);
898
- if (Array.isArray(existing)) {
899
- existing.push(value);
900
- } else {
901
- map.set(key, [value]);
902
- }
903
- } else {
904
- map.set(key, value);
905
- }
906
- }
907
- return map;
908
- }
909
- // src/js/array/to-record.ts
910
- function toRecord(array, first, second) {
911
- return groupValues(array, first, first === true || second === true, true);
912
- }
913
- // src/js/array/unique.ts
914
- function unique(array, key) {
915
- return findValues("unique", array, undefined, key);
916
- }
917
- // src/js/colour/index.ts
918
- function getForegroundColour(value) {
919
- const values = [value.blue / 255, value.green / 255, value.red / 255];
920
- for (let colour of values) {
921
- if (colour <= 0.03928) {
922
- colour /= 12.92;
923
- } else {
924
- colour = ((colour + 0.055) / 1.055) ** 2.4;
925
- }
926
- }
927
- const luminance = 0.2126 * values[2] + 0.7152 * values[1] + 0.0722 * values[0];
928
- return luminance > 0.625 ? "black" : "white";
929
- }
930
-
931
- // src/js/colour/is.ts
932
- function isColour(value) {
933
- return isInstance(/^(hex|hsl|rgb)$/, value);
934
- }
935
- function isColourValue(value, properties) {
936
- return typeof value === "object" && value !== null && properties.every((property) => (property in value) && typeof value[property] === "number");
937
- }
938
- function isHexColour(value) {
939
- return isInstance(/^hex$/, value);
940
- }
941
- function isHSLColour(value) {
942
- return isInstance(/^hsl$/, value);
943
- }
944
- function isInstance(pattern, value) {
945
- return typeof value === "object" && value !== null && "$colour" in value && typeof value.$colour === "string" && pattern.test(value.$colour);
946
- }
947
- function isRGBColour(value) {
948
- return isInstance(/^rgb$/, value);
949
- }
950
-
951
- // src/js/colour/base.ts
952
- class Colour {
953
- get value() {
954
- return { ...this.state.value };
955
- }
956
- constructor(type, value, defaults, properties) {
957
- this.$colour = type;
958
- this.state = {
959
- value: isColourValue(value, properties) ? { ...value } : { ...defaults }
960
- };
961
- }
962
- }
963
-
964
- // src/js/colour/hsl.ts
965
- function getHSLColour(value) {
966
- return new HSLColour(value);
967
- }
968
-
969
- class HSLColour extends Colour {
970
- get hue() {
971
- return +this.state.value.hue;
972
- }
973
- set hue(value) {
974
- this.state.value.hue = clamp(value, 0, 360);
975
- }
976
- get lightness() {
977
- return +this.state.value.lightness;
978
- }
979
- set lightness(value) {
980
- this.state.value.lightness = clamp(value, 0, 100);
981
- }
982
- get saturation() {
983
- return +this.state.value.saturation;
984
- }
985
- set saturation(value) {
986
- this.state.value.saturation = clamp(value, 0, 100);
987
- }
988
- constructor(value) {
989
- super("hsl", value, defaults, properties);
990
- }
991
- toHex() {
992
- return HSLColour.toRgb(this.state.value).toHex();
993
- }
994
- toRgb() {
995
- return HSLColour.toRgb(this.state.value);
996
- }
997
- toString() {
998
- return `hsl(${this.state.value.hue}, ${this.state.value.saturation}%, ${this.state.value.lightness}%)`;
999
- }
1000
- static toRgb(value) {
1001
- return hslToRgb(value);
1002
- }
1003
- }
1004
- var defaults = {
1005
- hue: 0,
1006
- lightness: 0,
1007
- saturation: 0
1008
- };
1009
- var properties = [
1010
- "hue",
1011
- "lightness",
1012
- "saturation"
1013
- ];
1014
-
1015
- // src/js/colour/rgb.ts
1016
- function getRGBColour(value) {
1017
- return new RGBColour(value);
1018
- }
1019
-
1020
- class RGBColour extends Colour {
1021
- get blue() {
1022
- return +this.state.value.blue;
1023
- }
1024
- set blue(value) {
1025
- this.state.value.blue = clamp(value, 0, 255);
1026
- }
1027
- get green() {
1028
- return +this.state.value.green;
1029
- }
1030
- set green(value) {
1031
- this.state.value.green = clamp(value, 0, 255);
1032
- }
1033
- get red() {
1034
- return +this.state.value.red;
1035
- }
1036
- set red(value) {
1037
- this.state.value.red = clamp(value, 0, 255);
1038
- }
1039
- constructor(value) {
1040
- super("rgb", value, defaults2, properties2);
1041
- }
1042
- toHex() {
1043
- return RGBColour.toHex(this.value);
1044
- }
1045
- toHsl() {
1046
- return RGBColour.toHsl(this.value);
1047
- }
1048
- toString() {
1049
- return `rgb(${this.value.red}, ${this.value.green}, ${this.value.blue})`;
1050
- }
1051
- static toHex(value) {
1052
- return rgbToHex(value);
1053
- }
1054
- static toHsl(rgb) {
1055
- return rgbToHsl(rgb);
1056
- }
1057
- }
1058
- var defaults2 = {
1059
- blue: 0,
1060
- green: 0,
1061
- red: 0
1062
- };
1063
- var properties2 = ["blue", "green", "red"];
1064
-
1065
- // src/js/colour/functions.ts
1066
- function getNormalisedHex(value) {
1067
- const normalised = value.replace(/^#/, "");
1068
- return normalised.length === 3 ? normalised.split("").map((character) => character.repeat(2)).join("") : normalised;
1069
- }
1070
- function hexToRgb(value) {
1071
- const hex = anyPattern.test(value) ? getNormalisedHex(value) : "";
1072
- const pairs = groupedPattern.exec(hex) ?? [];
1073
- const rgb = [];
1074
- const { length } = pairs;
1075
- for (let index = 1;index < length; index += 1) {
1076
- rgb.push(Number.parseInt(pairs[index], 16));
1077
- }
1078
- return new RGBColour({
1079
- blue: rgb[2] ?? 0,
1080
- green: rgb[1] ?? 0,
1081
- red: rgb[0] ?? 0
1082
- });
1083
- }
1084
- function hslToRgb(value) {
1085
- let hue = value.hue % 360;
1086
- if (hue < 0) {
1087
- hue += 360;
1088
- }
1089
- const saturation = value.saturation / 100;
1090
- const lightness = value.lightness / 100;
1091
- function get2(value2) {
1092
- const part = (value2 + hue / 30) % 12;
1093
- const mod = saturation * Math.min(lightness, 1 - lightness);
1094
- return lightness - mod * Math.max(-1, Math.min(part - 3, 9 - part, 1));
1095
- }
1096
- return new RGBColour({
1097
- blue: clamp(Math.round(get2(4) * 255), 0, 255),
1098
- green: clamp(Math.round(get2(8) * 255), 0, 255),
1099
- red: clamp(Math.round(get2(0) * 255), 0, 255)
1100
- });
1101
- }
1102
- function rgbToHex(value) {
1103
- return new HexColour(`${[value.red, value.green, value.blue].map((colour) => {
1104
- const hex = colour.toString(16);
1105
- return hex.length === 1 ? `0${hex}` : hex;
1106
- }).join("")}`);
1107
- }
1108
- function rgbToHsl(rgb) {
1109
- const blue = rgb.blue / 255;
1110
- const green = rgb.green / 255;
1111
- const red = rgb.red / 255;
1112
- const max2 = Math.max(blue, green, red);
1113
- const min2 = Math.min(blue, green, red);
1114
- const delta = max2 - min2;
1115
- const lightness = (min2 + max2) / 2;
1116
- let hue = 0;
1117
- let saturation = 0;
1118
- if (delta !== 0) {
1119
- saturation = lightness === 0 || lightness === 1 ? 0 : (max2 - lightness) / Math.min(lightness, 1 - lightness);
1120
- switch (max2) {
1121
- case blue:
1122
- hue = (red - green) / delta + 4;
1123
- break;
1124
- case green:
1125
- hue = (blue - red) / delta + 2;
1126
- break;
1127
- case red:
1128
- hue = (green - blue) / delta + (green < blue ? 6 : 0);
1129
- break;
1130
- default:
1131
- break;
1132
- }
1133
- hue *= 60;
1134
- }
1135
- if (saturation < 0) {
1136
- hue += 180;
1137
- saturation = Math.abs(saturation);
1138
- }
1139
- if (hue >= 360) {
1140
- hue -= 360;
1141
- }
1142
- return new HSLColour({
1143
- hue: +hue.toFixed(2),
1144
- lightness: +(lightness * 100).toFixed(2),
1145
- saturation: +(saturation * 100).toFixed(2)
1146
- });
1147
- }
1148
- var anyPattern = /^#*([a-f0-9]{3}){1,2}$/i;
1149
- var groupedPattern = /^#*([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
1150
-
1151
- // src/js/colour/hex.ts
1152
- function getHexColour(value) {
1153
- return new HexColour(value);
1154
- }
1155
-
1156
- class HexColour {
1157
- state;
1158
- get value() {
1159
- return `#${this.state.value}`;
1160
- }
1161
- set value(value) {
1162
- this.state.value = anyPattern.test(value) ? getNormalisedHex(value) : "000000";
1163
- }
1164
- constructor(value) {
1165
- this.$colour = "hex";
1166
- this.state = {
1167
- value: typeof value === "string" && anyPattern.test(value) ? getNormalisedHex(value) : "000000"
1168
- };
1169
- }
1170
- toHsl() {
1171
- return HexColour.toRgb(this.value).toHsl();
1172
- }
1173
- toRgb() {
1174
- return HexColour.toRgb(this.value);
1175
- }
1176
- toString() {
1177
- return this.value;
1178
- }
1179
- static toRgb(value) {
1180
- return hexToRgb(value);
1181
- }
1182
- }
1183
- // src/js/function.ts
1184
- function debounce(callback, time) {
1185
- const interval = clamp(time ?? 0, 0, 1000);
1186
- let timer;
1187
- const debounced = (...parameters) => {
1188
- clearTimeout(timer);
1189
- timer = setTimeout(() => {
1190
- callback(...parameters);
1191
- }, interval);
1192
- };
1193
- debounced.cancel = () => {
1194
- clearTimeout(timer);
1195
- };
1196
- return debounced;
1197
- }
1198
- function memoise(callback) {
1199
- return new Memoised(callback);
1200
- }
1201
- function noop() {
1202
- }
1203
- function throttle(callback, time) {
1204
- const interval = clamp(time ?? 0, 0, 1000);
1205
- let timestamp = performance.now();
1206
- let timer;
1207
- return (...parameters) => {
1208
- clearTimeout(timer);
1209
- const now = performance.now();
1210
- const difference = now - timestamp;
1211
- if (difference >= interval) {
1212
- timestamp = now;
1213
- callback(...parameters);
1214
- } else {
1215
- timer = setTimeout(() => {
1216
- timestamp = performance.now();
1217
- callback(...parameters);
1218
- }, difference + interval);
1219
- }
1220
- };
1221
- }
1222
-
1223
- class Memoised {
1224
- constructor(callback) {
1225
- const cache = new Map;
1226
- const getter = (...parameters) => {
1227
- const key = parameters[0];
1228
- if (cache.has(key)) {
1229
- return cache.get(key);
1230
- }
1231
- const value = callback(...parameters);
1232
- cache.set(key, value);
1233
- return value;
1234
- };
1235
- this.state = { cache, getter };
1236
- }
1237
- clear() {
1238
- this.state.cache?.clear();
1239
- }
1240
- delete(key) {
1241
- return this.state.cache?.delete(key);
1242
- }
1243
- destroy() {
1244
- this.state.cache.clear();
1245
- this.state.cache = undefined;
1246
- this.state.getter = noop;
1247
- }
1248
- get(key) {
1249
- return this.state.cache?.get(key);
1250
- }
1251
- has(key) {
1252
- return this.state.cache?.has(key) ?? false;
1253
- }
1254
- run(...parameters) {
1255
- return this.state.getter(...parameters);
1256
- }
1257
- }
1258
-
1259
- // src/js/emitter.ts
1260
- function emitter(value) {
1261
- return new Emitter(value);
1262
- }
1263
- function finishEmitter(state, emit) {
1264
- if (state.active) {
1265
- state.active = false;
1266
- const entries = [...state.observers.entries()];
1267
- const { length } = entries;
1268
- for (let index = 0;index < length; index += 1) {
1269
- const [subscription, observer] = entries[index];
1270
- if (emit) {
1271
- observer.complete?.();
1272
- }
1273
- subscription.destroy();
1274
- }
1275
- state.observers.clear();
1276
- state.observable = undefined;
1277
- state.observers = undefined;
1278
- state.value = undefined;
1279
- }
1280
- }
1281
- function getObserver(first, second, third) {
1282
- let observer = {
1283
- next: noop
1284
- };
1285
- if (typeof first === "object") {
1286
- observer = first !== null && properties3.every((property) => {
1287
- const value = first[property];
1288
- return value == null || typeof value === "function";
1289
- }) ? first : observer;
1290
- } else if (typeof first === "function") {
1291
- observer = {
1292
- error: typeof second === "function" ? second : noop,
1293
- next: first,
1294
- complete: typeof third === "function" ? third : undefined
1295
- };
1296
- }
1297
- return observer;
1298
- }
1299
-
1300
- class Emitter {
1301
- get active() {
1302
- return this.state.active;
1303
- }
1304
- get observable() {
1305
- return this.state.observable;
1306
- }
1307
- get value() {
1308
- return this.state.value;
1309
- }
1310
- constructor(value) {
1311
- const observers = new Map;
1312
- this.state = {
1313
- observers,
1314
- value,
1315
- active: true,
1316
- observable: new Observable(this, observers)
1317
- };
1318
- }
1319
- destroy() {
1320
- finishEmitter(this.state, false);
1321
- }
1322
- emit(value, finish) {
1323
- if (this.state.active) {
1324
- this.state.value = value;
1325
- for (const [, observer] of this.state.observers) {
1326
- observer.next?.(value);
1327
- }
1328
- if (finish === true) {
1329
- finishEmitter(this.state, true);
1330
- }
1331
- }
1332
- }
1333
- error(error, finish) {
1334
- if (this.state.active) {
1335
- for (const [, observer] of this.state.observers) {
1336
- observer.error?.(error);
1337
- }
1338
- if (finish === true) {
1339
- finishEmitter(this.state, true);
1340
- }
1341
- }
1342
- }
1343
- finish() {
1344
- finishEmitter(this.state, true);
1345
- }
1346
- }
1347
-
1348
- class Observable {
1349
- constructor(emitter2, observers) {
1350
- this.state = {
1351
- emitter: emitter2,
1352
- observers
1353
- };
1354
- }
1355
- subscribe(first, second, third) {
1356
- const observer = getObserver(first, second, third);
1357
- const instance = new Subscription(this.state);
1358
- this.state.observers.set(instance, observer);
1359
- observer.next?.(this.state.emitter.value);
1360
- return instance;
1361
- }
1362
- }
1363
-
1364
- class Subscription {
1365
- constructor(state) {
1366
- this.state = {
1367
- ...state,
1368
- closed: false
1369
- };
1370
- }
1371
- get closed() {
1372
- return this.state.closed || !(this.state.emitter?.active ?? false);
1373
- }
1374
- destroy() {
1375
- this.unsubscribe();
1376
- this.state.emitter = undefined;
1377
- this.state.observers = undefined;
1378
- }
1379
- unsubscribe() {
1380
- if (!this.state.closed) {
1381
- this.state.closed = true;
1382
- this.state.observers?.delete(this);
1383
- }
1384
- }
1385
- }
1386
- var properties3 = ["complete", "error", "next"];
1387
- // src/js/logger.ts
1388
- if (globalThis._atomic_logging == null) {
1389
- globalThis._atomic_logging = true;
1390
- }
1391
-
1392
- class Logger {
1393
- get debug() {
1394
- return this.enabled ? console.debug : noop;
1395
- }
1396
- get dir() {
1397
- return this.enabled ? console.dir : noop;
1398
- }
1399
- get enabled() {
1400
- return globalThis._atomic_logging ?? true;
1401
- }
1402
- set enabled(value) {
1403
- globalThis._atomic_logging = value;
1404
- }
1405
- get error() {
1406
- return this.enabled ? console.error : noop;
1407
- }
1408
- get info() {
1409
- return this.enabled ? console.info : noop;
1410
- }
1411
- get log() {
1412
- return this.enabled ? console.log : noop;
1413
- }
1414
- get table() {
1415
- return this.enabled ? console.table : noop;
1416
- }
1417
- get trace() {
1418
- return this.enabled ? console.trace : noop;
1419
- }
1420
- get warn() {
1421
- return this.enabled ? console.warn : noop;
1422
- }
1423
- time(label) {
1424
- return new Time(label);
1425
- }
1426
- }
1427
-
1428
- class Time {
1429
- constructor(label) {
1430
- this.state = {
1431
- label,
1432
- started: globalThis._atomic_logging ?? true,
1433
- stopped: false
1434
- };
1435
- if (this.state.started) {
1436
- console.time(label);
1437
- }
1438
- }
1439
- log() {
1440
- if (this.state.started && !this.state.stopped && logger.enabled) {
1441
- console.timeLog(this.state.label);
1442
- }
1443
- }
1444
- stop() {
1445
- if (this.state.started && !this.state.stopped) {
1446
- this.state.stopped = true;
1447
- console.timeEnd(this.state.label);
1448
- }
1449
- }
1450
- }
1451
- var logger = new Logger;
1452
- // src/js/query.ts
1453
- function fromQuery(query) {
1454
- const parts = query.split("&");
1455
- const { length } = parts;
1456
- const parameters = {};
1457
- for (let index = 0;index < length; index += 1) {
1458
- const [key, value] = parts[index].split("=").map(decodeURIComponent);
1459
- if (isNullableOrWhitespace(key)) {
1460
- continue;
1461
- }
1462
- if (key.includes(".")) {
1463
- setValue(parameters, key, getValue2(value));
1464
- } else {
1465
- if (key in parameters) {
1466
- if (!Array.isArray(parameters[key])) {
1467
- parameters[key] = [parameters[key]];
1468
- }
1469
- parameters[key].push(getValue2(value));
1470
- } else {
1471
- parameters[key] = getValue2(value);
1472
- }
1473
- }
1474
- }
1475
- return parameters;
1476
- }
1477
- function getParts2(value, fromArray, prefix) {
1478
- const keys = Object.keys(value);
1479
- const { length } = keys;
1480
- const parts = [];
1481
- for (let index = 0;index < length; index += 1) {
1482
- const key = keys[index];
1483
- const val = value[key];
1484
- if (Array.isArray(val)) {
1485
- parts.push(...getParts2(val, true, join([prefix, fromArray ? null : key], ".")));
1486
- } else if (isPlainObject(val)) {
1487
- parts.push(...getParts2(val, false, join([prefix, key], ".")));
1488
- } else if (isDecodable(val)) {
1489
- parts.push(`${encodeURIComponent(join([prefix, fromArray ? null : key], "."))}=${encodeURIComponent(val)}`);
1490
- }
1491
- }
1492
- return parts;
1493
- }
1494
- function getValue2(value) {
1495
- if (/^(false|true)$/.test(value)) {
1496
- return value === "true";
1497
- }
1498
- const asNumber = Number(value);
1499
- if (!Number.isNaN(asNumber)) {
1500
- return asNumber;
1501
- }
1502
- return value;
1503
- }
1504
- function isDecodable(value) {
1505
- return ["boolean", "number", "string"].includes(typeof value);
1506
- }
1507
- function toQuery(parameters) {
1508
- return getParts2(parameters, false).filter((part) => part.length > 0).join("&");
1509
- }
1510
- // src/js/queue.ts
1511
- function queue(callback) {
1512
- _atomic_queued.add(callback);
1513
- if (_atomic_queued.size > 0) {
1514
- queueMicrotask(() => {
1515
- const callbacks = [..._atomic_queued];
1516
- const { length } = callbacks;
1517
- _atomic_queued.clear();
1518
- for (let index = 0;index < length; index += 1) {
1519
- callbacks[index]();
1520
- }
1521
- });
1522
- }
1523
- }
1524
- if (globalThis._atomic_queued == null) {
1525
- const queued = new Set;
1526
- Object.defineProperty(globalThis, "_atomic_queued", {
1527
- get() {
1528
- return queued;
1529
- }
1530
- });
1531
- }
1532
- // src/js/sized.ts
1533
- function getMaximum(first, second) {
1534
- const actual = (typeof first === "number" ? first : typeof second === "number" ? second : undefined) ?? 2 ** 20;
1535
- return clamp(actual, 1, 2 ** 24);
1536
- }
1537
-
1538
- class SizedMap extends Map {
1539
- maximumSize;
1540
- get full() {
1541
- return this.size >= this.maximumSize;
1542
- }
1543
- get maximum() {
1544
- return this.maximumSize;
1545
- }
1546
- constructor(entries, maximum) {
1547
- const maximumSize = getMaximum(typeof entries === "number" ? entries : typeof maximum === "number" ? maximum : undefined);
1548
- super(Array.isArray(entries) ? entries.slice(0, maximumSize) : undefined);
1549
- this.maximumSize = maximumSize;
1550
- if (Array.isArray(entries) && entries.length > maximumSize) {
1551
- for (let index = 0;index < maximumSize; index += 1) {
1552
- this.set(...entries[entries.length - maximumSize + index]);
1553
- }
1554
- }
1555
- }
1556
- get(key) {
1557
- const value = super.get(key);
1558
- if (value === undefined && !this.has(key)) {
1559
- return;
1560
- }
1561
- this.set(key, value);
1562
- return value;
1563
- }
1564
- set(key, value) {
1565
- if (this.has(key)) {
1566
- this.delete(key);
1567
- } else if (this.size >= this.maximumSize) {
1568
- this.delete(this.keys().next().value);
1569
- }
1570
- return super.set(key, value);
1571
- }
1572
- }
1573
-
1574
- class SizedSet extends Set {
1575
- maximumSize;
1576
- get full() {
1577
- return this.size >= this.maximumSize;
1578
- }
1579
- get maximum() {
1580
- return this.maximumSize;
1581
- }
1582
- constructor(values, maximum) {
1583
- const maximumSize = getMaximum(typeof values === "number" ? values : typeof maximum === "number" ? maximum : undefined);
1584
- super(Array.isArray(values) && values.length <= maximumSize ? values : undefined);
1585
- this.maximumSize = maximumSize;
1586
- if (Array.isArray(values) && values.length > maximumSize) {
1587
- for (let index = 0;index < maximumSize; index += 1) {
1588
- this.add(values[values.length - maximumSize + index]);
1589
- }
1590
- }
1591
- }
1592
- add(value) {
1593
- if (this.has(value)) {
1594
- this.delete(value);
1595
- } else if (this.size >= this.maximumSize) {
1596
- this.delete(this.values().next().value);
1597
- }
1598
- return super.add(value);
1599
- }
1600
- at(index, update) {
1601
- const value = [...this.values()][index < 0 ? this.size + index : index];
1602
- if ((update ?? false) && this.has(value)) {
1603
- this.delete(value);
1604
- this.add(value);
1605
- }
1606
- return value;
1607
- }
1608
- get(value, update) {
1609
- if (this.has(value)) {
1610
- if (update ?? false) {
1611
- this.delete(value);
1612
- this.add(value);
1613
- }
1614
- return value;
1615
- }
1616
- }
1617
- }
1618
- // src/js/touch.ts
1619
- var supportsTouch = (() => {
1620
- let value = false;
1621
- try {
1622
- if ("matchMedia" in window) {
1623
- const media = matchMedia("(pointer: coarse)");
1624
- if (typeof media?.matches === "boolean") {
1625
- value = media.matches;
1626
- }
1627
- }
1628
- if (!value) {
1629
- value = "ontouchstart" in window || navigator.maxTouchPoints > 0 || (navigator.msMaxTouchPoints ?? 0) > 0;
1630
- }
1631
- } catch {
1632
- value = false;
1633
- }
1634
- return value;
1635
- })();
1
+ import { flatten, push } from "./array/index.js";
2
+ import { getForegroundColour } from "./colour/index.js";
3
+ import { emitter } from "./emitter.js";
4
+ import { debounce, memoise, noop, throttle } from "./function.js";
5
+ import { isArrayOrPlainObject, isEmpty, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive } from "./is.js";
6
+ import { logger } from "./logger.js";
7
+ import { average, max, min, round, sum } from "./math.js";
8
+ import { between, clamp, getNumber } from "./number.js";
9
+ import { fromQuery, toQuery } from "./query.js";
10
+ import { queue } from "./queue.js";
11
+ import { getRandomBoolean, getRandomCharacters, getRandomColour, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems } from "./random.js";
12
+ import { SizedMap, SizedSet } from "./sized.js";
13
+ import { createUuid, getString, join, parse, truncate, words } from "./string/index.js";
14
+ import "./touch.js";
15
+ import { partial } from "./value/index.js";
16
+ import { groupBy } from "./array/group-by.js";
17
+ import { insert } from "./array/insert.js";
18
+ import { sort } from "./array/sort.js";
19
+ import { chunk } from "./array/chunk.js";
20
+ import { compact } from "./array/compact.js";
21
+ import { count } from "./array/count.js";
22
+ import { exists } from "./array/exists.js";
23
+ import { filter } from "./array/filter.js";
24
+ import { find } from "./array/find.js";
25
+ import { indexOf } from "./array/index-of.js";
26
+ import { shuffle } from "./array/shuffle.js";
27
+ import { splice } from "./array/splice.js";
28
+ import { toMap } from "./array/to-map.js";
29
+ import { toRecord } from "./array/to-record.js";
30
+ import { unique } from "./array/unique.js";
31
+ import { HexColour, getHexColour } from "./colour/hex.js";
32
+ import { HSLColour, getHSLColour } from "./colour/hsl.js";
33
+ import { isColour, isHSLColour, isHexColour, isRGBColour } from "./colour/is.js";
34
+ import { RGBColour, getRGBColour } from "./colour/rgb.js";
35
+ import { camelCase, capitalise, kebabCase, pascalCase, snakeCase, titleCase } from "./string/case.js";
36
+ import { template } from "./string/template.js";
37
+ import { clone } from "./value/clone.js";
38
+ import { compare } from "./value/compare.js";
39
+ import { diff } from "./value/diff.js";
40
+ import { equal } from "./value/equal.js";
41
+ import { getValue } from "./value/get.js";
42
+ import { merge } from "./value/merge.js";
43
+ import { setValue } from "./value/set.js";
44
+ import { smush } from "./value/smush.js";
45
+ import { unsmush } from "./value/unsmush.js";
1636
46
  export {
1637
- words,
1638
- unsmush,
1639
- unique,
1640
- truncate,
1641
- toRecord,
1642
- toQuery,
1643
- toMap,
1644
- titleCase,
1645
- throttle,
1646
- template,
1647
- sum,
1648
- splice,
1649
- sort,
1650
- snakeCase,
1651
- smush,
1652
- shuffle,
1653
- setValue,
1654
- round,
1655
- queue,
1656
- push,
1657
- pascalCase,
1658
- partial,
1659
- parse,
1660
- noop,
1661
- min,
1662
- merge,
1663
- memoise,
1664
- max,
1665
- logger,
1666
- kebabCase,
1667
- join,
1668
- isRGBColour,
1669
- isPrimitive,
1670
- isPlainObject,
1671
- isObject,
1672
- isNumerical,
1673
- isNumber,
1674
- isNullableOrWhitespace,
1675
- isNullableOrEmpty,
1676
- isNullable,
1677
- isKey,
1678
- isHexColour,
1679
- isHSLColour,
1680
- isEmpty,
1681
- isColour,
1682
- isArrayOrPlainObject,
1683
- insert,
1684
- indexOf,
1685
- groupBy,
1686
- getValue,
1687
- getString,
1688
- getRandomItems,
1689
- getRandomItem,
1690
- getRandomInteger,
1691
- getRandomHex,
1692
- getRandomFloat,
1693
- getRandomDate,
1694
- getRandomColour,
1695
- getRandomCharacters,
1696
- getRandomBoolean,
1697
- getRGBColour,
1698
- getNumber,
1699
- getHexColour,
1700
- getHSLColour,
1701
- getForegroundColour,
1702
- fromQuery,
1703
- flatten2 as flatten,
1704
- find,
1705
- filter,
1706
- exists,
1707
- equal,
1708
- emitter,
1709
- diff,
1710
- debounce,
1711
- createUuid,
1712
- count,
1713
- compare,
1714
- compact,
1715
- clone,
1716
- clamp,
1717
- chunk,
1718
- capitalise,
1719
- camelCase,
1720
- between,
1721
- average,
1722
- SizedSet,
1723
- SizedMap,
1724
- RGBColour,
47
+ HSLColour,
1725
48
  HexColour,
1726
- HSLColour
49
+ RGBColour,
50
+ SizedMap,
51
+ SizedSet,
52
+ average,
53
+ between,
54
+ camelCase,
55
+ capitalise,
56
+ chunk,
57
+ clamp,
58
+ clone,
59
+ compact,
60
+ compare,
61
+ count,
62
+ createUuid,
63
+ debounce,
64
+ diff,
65
+ emitter,
66
+ equal,
67
+ exists,
68
+ filter,
69
+ find,
70
+ flatten,
71
+ fromQuery,
72
+ getForegroundColour,
73
+ getHSLColour,
74
+ getHexColour,
75
+ getNumber,
76
+ getRGBColour,
77
+ getRandomBoolean,
78
+ getRandomCharacters,
79
+ getRandomColour,
80
+ getRandomFloat,
81
+ getRandomHex,
82
+ getRandomInteger,
83
+ getRandomItem,
84
+ getRandomItems,
85
+ getString,
86
+ getValue,
87
+ groupBy,
88
+ indexOf,
89
+ insert,
90
+ isArrayOrPlainObject,
91
+ isColour,
92
+ isEmpty,
93
+ isHSLColour,
94
+ isHexColour,
95
+ isKey,
96
+ isNullable,
97
+ isNullableOrEmpty,
98
+ isNullableOrWhitespace,
99
+ isNumber,
100
+ isNumerical,
101
+ isObject,
102
+ isPlainObject,
103
+ isPrimitive,
104
+ isRGBColour,
105
+ join,
106
+ kebabCase,
107
+ logger,
108
+ max,
109
+ memoise,
110
+ merge,
111
+ min,
112
+ noop,
113
+ parse,
114
+ partial,
115
+ pascalCase,
116
+ push,
117
+ queue,
118
+ round,
119
+ setValue,
120
+ shuffle,
121
+ smush,
122
+ snakeCase,
123
+ sort,
124
+ splice,
125
+ sum,
126
+ template,
127
+ throttle,
128
+ titleCase,
129
+ toMap,
130
+ toQuery,
131
+ toRecord,
132
+ truncate,
133
+ unique,
134
+ unsmush,
135
+ words
1727
136
  };