@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
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function getCallback(value) {
4
+ switch (typeof value) {
5
+ case "function":
6
+ return value;
7
+ case "number":
8
+ case "string":
9
+ return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
10
+ default:
11
+ return;
12
+ }
13
+ }
14
+ function getCallbacks(bool, key, value) {
15
+ if (typeof bool === "function") {
16
+ return { bool };
17
+ }
18
+ return {
19
+ key: getCallback(key),
20
+ value: getCallback(value)
21
+ };
22
+ }
23
+ exports.getCallbacks = getCallbacks;
@@ -0,0 +1,23 @@
1
+ function getCallback(value) {
2
+ switch (typeof value) {
3
+ case "function":
4
+ return value;
5
+ case "number":
6
+ case "string":
7
+ return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
8
+ default:
9
+ return;
10
+ }
11
+ }
12
+ function getCallbacks(bool, key, value) {
13
+ if (typeof bool === "function") {
14
+ return { bool };
15
+ }
16
+ return {
17
+ key: getCallback(key),
18
+ value: getCallback(value)
19
+ };
20
+ }
21
+ export {
22
+ getCallbacks
23
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const internal_array_callbacks = require("./callbacks.cjs");
4
+ function findValue(type, array, bool, key, value) {
5
+ var _a;
6
+ const callbacks = internal_array_callbacks.getCallbacks(bool, key);
7
+ if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
8
+ return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
9
+ }
10
+ if (callbacks.bool != null) {
11
+ const index = array.findIndex(callbacks.bool);
12
+ return type === "index" ? index : index > -1 ? array[index] : void 0;
13
+ }
14
+ const { length } = array;
15
+ for (let index = 0; index < length; index += 1) {
16
+ const item = array[index];
17
+ if (((_a = callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) === value) {
18
+ return type === "index" ? index : item;
19
+ }
20
+ }
21
+ return type === "index" ? -1 : void 0;
22
+ }
23
+ function findValues(type, array, bool, key, value) {
24
+ var _a;
25
+ const callbacks = internal_array_callbacks.getCallbacks(bool, key);
26
+ const { length } = array;
27
+ if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
28
+ return Array.from(new Set(array));
29
+ }
30
+ if ((callbacks == null ? void 0 : callbacks.bool) != null) {
31
+ return array.filter(callbacks.bool);
32
+ }
33
+ if (type === "all" && key == null) {
34
+ return array.filter((item) => item === value);
35
+ }
36
+ const result = [];
37
+ const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
38
+ for (let index = 0; index < length; index += 1) {
39
+ const item = array[index];
40
+ const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
41
+ if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
42
+ if (values !== result) {
43
+ values.push(keyed);
44
+ }
45
+ result.push(item);
46
+ }
47
+ }
48
+ return result;
49
+ }
50
+ exports.findValue = findValue;
51
+ exports.findValues = findValues;
@@ -0,0 +1,51 @@
1
+ import { getCallbacks } from "./callbacks.js";
2
+ function findValue(type, array, bool, key, value) {
3
+ var _a;
4
+ const callbacks = getCallbacks(bool, key);
5
+ if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
6
+ return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
7
+ }
8
+ if (callbacks.bool != null) {
9
+ const index = array.findIndex(callbacks.bool);
10
+ return type === "index" ? index : index > -1 ? array[index] : void 0;
11
+ }
12
+ const { length } = array;
13
+ for (let index = 0; index < length; index += 1) {
14
+ const item = array[index];
15
+ if (((_a = callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) === value) {
16
+ return type === "index" ? index : item;
17
+ }
18
+ }
19
+ return type === "index" ? -1 : void 0;
20
+ }
21
+ function findValues(type, array, bool, key, value) {
22
+ var _a;
23
+ const callbacks = getCallbacks(bool, key);
24
+ const { length } = array;
25
+ if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
26
+ return Array.from(new Set(array));
27
+ }
28
+ if ((callbacks == null ? void 0 : callbacks.bool) != null) {
29
+ return array.filter(callbacks.bool);
30
+ }
31
+ if (type === "all" && key == null) {
32
+ return array.filter((item) => item === value);
33
+ }
34
+ const result = [];
35
+ const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
36
+ for (let index = 0; index < length; index += 1) {
37
+ const item = array[index];
38
+ const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
39
+ if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
40
+ if (values !== result) {
41
+ values.push(keyed);
42
+ }
43
+ result.push(item);
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+ export {
49
+ findValue,
50
+ findValues
51
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function findKey(needle, haystack, ignoreCase) {
4
+ if (!ignoreCase) {
5
+ return needle;
6
+ }
7
+ const keys = Object.keys(haystack);
8
+ const normalised = keys.map((key) => key.toLowerCase());
9
+ const index = normalised.indexOf(needle.toLowerCase());
10
+ return index > -1 ? keys[index] : needle;
11
+ }
12
+ function handleValue(data, path, value, get, ignoreCase) {
13
+ if (typeof data === "object" && data !== null && !/^(__proto__|constructor|prototype)$/i.test(path)) {
14
+ const key = findKey(path, data, ignoreCase);
15
+ if (get) {
16
+ return data[key];
17
+ }
18
+ data[key] = value;
19
+ }
20
+ }
21
+ exports.handleValue = handleValue;
@@ -1,4 +1,3 @@
1
- // src/js/internal/value-handle.ts
2
1
  function findKey(needle, haystack, ignoreCase) {
3
2
  if (!ignoreCase) {
4
3
  return needle;
@@ -1,5 +1,6 @@
1
- // src/js/is.ts
2
- import { getString } from "./string";
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const string_index = require("./string/index.cjs");
3
4
  function isArrayOrPlainObject(value) {
4
5
  return Array.isArray(value) || isPlainObject(value);
5
6
  }
@@ -7,7 +8,7 @@ function isEmpty(value) {
7
8
  const values = Object.values(value);
8
9
  const { length } = values;
9
10
  let count = 0;
10
- for (let index = 0;index < length; index += 1) {
11
+ for (let index = 0; index < length; index += 1) {
11
12
  if (values[index] != null) {
12
13
  count += 1;
13
14
  }
@@ -21,10 +22,10 @@ function isNullable(value) {
21
22
  return value == null;
22
23
  }
23
24
  function isNullableOrEmpty(value) {
24
- return value == null || getString(value) === "";
25
+ return value == null || string_index.getString(value) === "";
25
26
  }
26
27
  function isNullableOrWhitespace(value) {
27
- return value == null || /^\s*$/.test(getString(value));
28
+ return value == null || /^\s*$/.test(string_index.getString(value));
28
29
  }
29
30
  function isNumber(value) {
30
31
  return typeof value === "number" && !Number.isNaN(value);
@@ -45,16 +46,14 @@ function isPlainObject(value) {
45
46
  function isPrimitive(value) {
46
47
  return value == null || /^(bigint|boolean|number|string|symbol)$/.test(typeof value);
47
48
  }
48
- export {
49
- isPrimitive,
50
- isPlainObject,
51
- isObject,
52
- isNumerical,
53
- isNumber,
54
- isNullableOrWhitespace,
55
- isNullableOrEmpty,
56
- isNullable,
57
- isKey,
58
- isEmpty,
59
- isArrayOrPlainObject
60
- };
49
+ exports.isArrayOrPlainObject = isArrayOrPlainObject;
50
+ exports.isEmpty = isEmpty;
51
+ exports.isKey = isKey;
52
+ exports.isNullable = isNullable;
53
+ exports.isNullableOrEmpty = isNullableOrEmpty;
54
+ exports.isNullableOrWhitespace = isNullableOrWhitespace;
55
+ exports.isNumber = isNumber;
56
+ exports.isNumerical = isNumerical;
57
+ exports.isObject = isObject;
58
+ exports.isPlainObject = isPlainObject;
59
+ exports.isPrimitive = isPrimitive;
package/dist/js/is.js CHANGED
@@ -1,29 +1,17 @@
1
- // src/js/string/index.ts
2
- function getString(value) {
3
- if (typeof value === "string") {
4
- return value;
5
- }
6
- if (typeof value !== "object" || value == null) {
7
- return String(value);
8
- }
9
- const valueOff = value.valueOf?.() ?? value;
10
- const asString = valueOff?.toString?.() ?? String(valueOff);
11
- return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
12
- }
13
- // src/js/is.ts
1
+ import { getString } from "./string/index.js";
14
2
  function isArrayOrPlainObject(value) {
15
3
  return Array.isArray(value) || isPlainObject(value);
16
4
  }
17
5
  function isEmpty(value) {
18
6
  const values = Object.values(value);
19
7
  const { length } = values;
20
- let count2 = 0;
21
- for (let index = 0;index < length; index += 1) {
8
+ let count = 0;
9
+ for (let index = 0; index < length; index += 1) {
22
10
  if (values[index] != null) {
23
- count2 += 1;
11
+ count += 1;
24
12
  }
25
13
  }
26
- return count2 === 0;
14
+ return count === 0;
27
15
  }
28
16
  function isKey(value) {
29
17
  return typeof value === "number" || typeof value === "string";
@@ -57,15 +45,15 @@ function isPrimitive(value) {
57
45
  return value == null || /^(bigint|boolean|number|string|symbol)$/.test(typeof value);
58
46
  }
59
47
  export {
60
- isPrimitive,
61
- isPlainObject,
62
- isObject,
63
- isNumerical,
64
- isNumber,
65
- isNullableOrWhitespace,
66
- isNullableOrEmpty,
67
- isNullable,
68
- isKey,
48
+ isArrayOrPlainObject,
69
49
  isEmpty,
70
- isArrayOrPlainObject
50
+ isKey,
51
+ isNullable,
52
+ isNullableOrEmpty,
53
+ isNullableOrWhitespace,
54
+ isNumber,
55
+ isNumerical,
56
+ isObject,
57
+ isPlainObject,
58
+ isPrimitive
71
59
  };
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _function = require("./function.cjs");
4
+ if (globalThis._atomic_logging == null) {
5
+ globalThis._atomic_logging = true;
6
+ }
7
+ class Logger {
8
+ /**
9
+ * Log any number of values at the "debug" log level
10
+ */
11
+ get debug() {
12
+ return this.enabled ? console.debug : _function.noop;
13
+ }
14
+ /**
15
+ * Log the value and shows all its properties
16
+ */
17
+ get dir() {
18
+ return this.enabled ? console.dir : _function.noop;
19
+ }
20
+ /**
21
+ * Is logging to the console enabled? _(defaults to `true`)_
22
+ */
23
+ get enabled() {
24
+ return globalThis._atomic_logging ?? true;
25
+ }
26
+ /**
27
+ * Enable or disable logging to the console
28
+ */
29
+ set enabled(value) {
30
+ globalThis._atomic_logging = value;
31
+ }
32
+ /**
33
+ * Log any number of values at the "error" log level
34
+ */
35
+ get error() {
36
+ return this.enabled ? console.error : _function.noop;
37
+ }
38
+ /**
39
+ * Log any number of values at the "info" log level
40
+ */
41
+ get info() {
42
+ return this.enabled ? console.info : _function.noop;
43
+ }
44
+ /**
45
+ * Log any number of values at the "log" log level
46
+ */
47
+ get log() {
48
+ return this.enabled ? console.log : _function.noop;
49
+ }
50
+ /**
51
+ * Log data as a table, with optional properties to use as columns
52
+ */
53
+ get table() {
54
+ return this.enabled ? console.table : _function.noop;
55
+ }
56
+ /**
57
+ * Log any number of values together with a trace from where it was called
58
+ */
59
+ get trace() {
60
+ return this.enabled ? console.trace : _function.noop;
61
+ }
62
+ /**
63
+ * Log any number of values at the "warn" log level
64
+ */
65
+ get warn() {
66
+ return this.enabled ? console.warn : _function.noop;
67
+ }
68
+ /**
69
+ * - Start a logged timer with a label
70
+ * - Returns a `Time`-object for logging the current duration of the timer and stopping the timer _(and logging the total duration)_
71
+ */
72
+ time(label) {
73
+ return new Time(label);
74
+ }
75
+ }
76
+ class Time {
77
+ constructor(label) {
78
+ this.state = {
79
+ label,
80
+ started: globalThis._atomic_logging ?? true,
81
+ stopped: false
82
+ };
83
+ if (this.state.started) {
84
+ console.time(label);
85
+ }
86
+ }
87
+ /**
88
+ * - Log the current duration of the timer
89
+ * - _(Ignored if logging is disabled)_
90
+ */
91
+ log() {
92
+ if (this.state.started && !this.state.stopped && logger.enabled) {
93
+ console.timeLog(this.state.label);
94
+ }
95
+ }
96
+ /**
97
+ * - Stop the timer and logs the total duration
98
+ * - _(Will always log the total duration, even if logging is disabled)_
99
+ */
100
+ stop() {
101
+ if (this.state.started && !this.state.stopped) {
102
+ this.state.stopped = true;
103
+ console.timeEnd(this.state.label);
104
+ }
105
+ }
106
+ }
107
+ const logger = new Logger();
108
+ exports.logger = logger;
package/dist/js/logger.js CHANGED
@@ -1,48 +1,76 @@
1
- // src/js/function.ts
2
- function noop() {
3
- }
4
-
5
- // src/js/logger.ts
1
+ import { noop } from "./function.js";
6
2
  if (globalThis._atomic_logging == null) {
7
3
  globalThis._atomic_logging = true;
8
4
  }
9
-
10
5
  class Logger {
6
+ /**
7
+ * Log any number of values at the "debug" log level
8
+ */
11
9
  get debug() {
12
10
  return this.enabled ? console.debug : noop;
13
11
  }
12
+ /**
13
+ * Log the value and shows all its properties
14
+ */
14
15
  get dir() {
15
16
  return this.enabled ? console.dir : noop;
16
17
  }
18
+ /**
19
+ * Is logging to the console enabled? _(defaults to `true`)_
20
+ */
17
21
  get enabled() {
18
22
  return globalThis._atomic_logging ?? true;
19
23
  }
24
+ /**
25
+ * Enable or disable logging to the console
26
+ */
20
27
  set enabled(value) {
21
28
  globalThis._atomic_logging = value;
22
29
  }
30
+ /**
31
+ * Log any number of values at the "error" log level
32
+ */
23
33
  get error() {
24
34
  return this.enabled ? console.error : noop;
25
35
  }
36
+ /**
37
+ * Log any number of values at the "info" log level
38
+ */
26
39
  get info() {
27
40
  return this.enabled ? console.info : noop;
28
41
  }
42
+ /**
43
+ * Log any number of values at the "log" log level
44
+ */
29
45
  get log() {
30
46
  return this.enabled ? console.log : noop;
31
47
  }
48
+ /**
49
+ * Log data as a table, with optional properties to use as columns
50
+ */
32
51
  get table() {
33
52
  return this.enabled ? console.table : noop;
34
53
  }
54
+ /**
55
+ * Log any number of values together with a trace from where it was called
56
+ */
35
57
  get trace() {
36
58
  return this.enabled ? console.trace : noop;
37
59
  }
60
+ /**
61
+ * Log any number of values at the "warn" log level
62
+ */
38
63
  get warn() {
39
64
  return this.enabled ? console.warn : noop;
40
65
  }
66
+ /**
67
+ * - Start a logged timer with a label
68
+ * - Returns a `Time`-object for logging the current duration of the timer and stopping the timer _(and logging the total duration)_
69
+ */
41
70
  time(label) {
42
71
  return new Time(label);
43
72
  }
44
73
  }
45
-
46
74
  class Time {
47
75
  constructor(label) {
48
76
  this.state = {
@@ -54,11 +82,19 @@ class Time {
54
82
  console.time(label);
55
83
  }
56
84
  }
85
+ /**
86
+ * - Log the current duration of the timer
87
+ * - _(Ignored if logging is disabled)_
88
+ */
57
89
  log() {
58
90
  if (this.state.started && !this.state.stopped && logger.enabled) {
59
91
  console.timeLog(this.state.label);
60
92
  }
61
93
  }
94
+ /**
95
+ * - Stop the timer and logs the total duration
96
+ * - _(Will always log the total duration, even if logging is disabled)_
97
+ */
62
98
  stop() {
63
99
  if (this.state.started && !this.state.stopped) {
64
100
  this.state.stopped = true;
@@ -66,7 +102,7 @@ class Time {
66
102
  }
67
103
  }
68
104
  }
69
- var logger = new Logger;
105
+ const logger = new Logger();
70
106
  export {
71
107
  logger
72
108
  };
@@ -1,4 +1,5 @@
1
- // src/js/math.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
3
  function average(values) {
3
4
  return values.length > 0 ? sum(values) / values.length : Number.NaN;
4
5
  }
@@ -18,10 +19,8 @@ function round(value, decimals) {
18
19
  function sum(values) {
19
20
  return values.reduce((previous, current) => previous + current, 0);
20
21
  }
21
- export {
22
- sum,
23
- round,
24
- min,
25
- max,
26
- average
27
- };
22
+ exports.average = average;
23
+ exports.max = max;
24
+ exports.min = min;
25
+ exports.round = round;
26
+ exports.sum = sum;
package/dist/js/math.js CHANGED
@@ -1,4 +1,3 @@
1
- // src/js/math.ts
2
1
  function average(values) {
3
2
  return values.length > 0 ? sum(values) / values.length : Number.NaN;
4
3
  }
@@ -19,9 +18,9 @@ function sum(values) {
19
18
  return values.reduce((previous, current) => previous + current, 0);
20
19
  }
21
20
  export {
22
- sum,
23
- round,
24
- min,
21
+ average,
25
22
  max,
26
- average
23
+ min,
24
+ round,
25
+ sum
27
26
  };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -1,4 +1,5 @@
1
- // src/js/number.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
3
  function between(value, min, max) {
3
4
  return value >= min && value <= max;
4
5
  }
@@ -9,15 +10,16 @@ function clamp(value, min, max, loop) {
9
10
  return value > max ? loop === true ? min : max : value;
10
11
  }
11
12
  function getNumber(value) {
13
+ var _a;
12
14
  if (typeof value === "number") {
13
15
  return value;
14
16
  }
15
17
  if (typeof value === "symbol") {
16
18
  return Number.NaN;
17
19
  }
18
- let parsed = value?.valueOf?.() ?? value;
20
+ let parsed = ((_a = value == null ? void 0 : value.valueOf) == null ? void 0 : _a.call(value)) ?? value;
19
21
  if (typeof parsed === "object") {
20
- parsed = parsed?.toString() ?? parsed;
22
+ parsed = (parsed == null ? void 0 : parsed.toString()) ?? parsed;
21
23
  }
22
24
  if (typeof parsed !== "string") {
23
25
  return parsed == null ? Number.NaN : typeof parsed === "number" ? parsed : +parsed;
@@ -35,8 +37,6 @@ function getNumber(value) {
35
37
  }
36
38
  return +(/^0x[0-9a-f]+$/i.test(trimmed) ? trimmed : trimmed.replace(/_/g, ""));
37
39
  }
38
- export {
39
- getNumber,
40
- clamp,
41
- between
42
- };
40
+ exports.between = between;
41
+ exports.clamp = clamp;
42
+ exports.getNumber = getNumber;
package/dist/js/number.js CHANGED
@@ -1,4 +1,3 @@
1
- // src/js/number.ts
2
1
  function between(value, min, max) {
3
2
  return value >= min && value <= max;
4
3
  }
@@ -9,15 +8,16 @@ function clamp(value, min, max, loop) {
9
8
  return value > max ? loop === true ? min : max : value;
10
9
  }
11
10
  function getNumber(value) {
11
+ var _a;
12
12
  if (typeof value === "number") {
13
13
  return value;
14
14
  }
15
15
  if (typeof value === "symbol") {
16
16
  return Number.NaN;
17
17
  }
18
- let parsed = value?.valueOf?.() ?? value;
18
+ let parsed = ((_a = value == null ? void 0 : value.valueOf) == null ? void 0 : _a.call(value)) ?? value;
19
19
  if (typeof parsed === "object") {
20
- parsed = parsed?.toString() ?? parsed;
20
+ parsed = (parsed == null ? void 0 : parsed.toString()) ?? parsed;
21
21
  }
22
22
  if (typeof parsed !== "string") {
23
23
  return parsed == null ? Number.NaN : typeof parsed === "number" ? parsed : +parsed;
@@ -36,7 +36,7 @@ function getNumber(value) {
36
36
  return +(/^0x[0-9a-f]+$/i.test(trimmed) ? trimmed : trimmed.replace(/_/g, ""));
37
37
  }
38
38
  export {
39
- getNumber,
39
+ between,
40
40
  clamp,
41
- between
41
+ getNumber
42
42
  };