@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,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const math = require("../math.cjs");
4
+ const number = require("../number.cjs");
5
+ const string_index = require("../string/index.cjs");
6
+ function compare(first, second) {
7
+ const firstParts = getParts(first);
8
+ const secondParts = getParts(second);
9
+ const length = math.max([firstParts.length, secondParts.length]);
10
+ const lastIndex = length - 1;
11
+ for (let index = 0; index < length; index += 1) {
12
+ const firstPart = firstParts[index];
13
+ const secondPart = secondParts[index];
14
+ if (firstPart === secondPart) {
15
+ if (index === lastIndex) {
16
+ return 0;
17
+ }
18
+ continue;
19
+ }
20
+ if (firstPart == null || typeof firstPart === "string" && firstPart.length === 0) {
21
+ return -1;
22
+ }
23
+ if (secondPart == null || typeof secondPart === "string" && secondPart.length === 0) {
24
+ return 1;
25
+ }
26
+ const firstNumber = number.getNumber(firstPart);
27
+ const secondNumber = number.getNumber(secondPart);
28
+ const firstIsNaN = Number.isNaN(firstNumber);
29
+ const secondIsNaN = Number.isNaN(secondNumber);
30
+ if (firstIsNaN || secondIsNaN) {
31
+ if (firstIsNaN && secondIsNaN) {
32
+ return string_index.getString(firstPart).localeCompare(string_index.getString(secondPart));
33
+ }
34
+ if (firstIsNaN) {
35
+ return 1;
36
+ }
37
+ if (secondIsNaN) {
38
+ return -1;
39
+ }
40
+ }
41
+ if (firstNumber === secondNumber) {
42
+ if (index === lastIndex) {
43
+ return 0;
44
+ }
45
+ }
46
+ return firstNumber - secondNumber;
47
+ }
48
+ return string_index.join(firstParts).localeCompare(string_index.join(secondParts));
49
+ }
50
+ function getParts(value) {
51
+ if (value == null) {
52
+ return [""];
53
+ }
54
+ if (Array.isArray(value)) {
55
+ return value;
56
+ }
57
+ return typeof value === "object" ? [value] : string_index.words(string_index.getString(value));
58
+ }
59
+ exports.compare = compare;
@@ -1,13 +1,12 @@
1
- // src/js/value/compare.ts
2
- import { max } from "../math";
3
- import { getNumber } from "../number";
4
- import { words, getString, join } from "../string";
1
+ import { max } from "../math.js";
2
+ import { getNumber } from "../number.js";
3
+ import { getString, join, words } from "../string/index.js";
5
4
  function compare(first, second) {
6
5
  const firstParts = getParts(first);
7
6
  const secondParts = getParts(second);
8
7
  const length = max([firstParts.length, secondParts.length]);
9
8
  const lastIndex = length - 1;
10
- for (let index = 0;index < length; index += 1) {
9
+ for (let index = 0; index < length; index += 1) {
11
10
  const firstPart = firstParts[index];
12
11
  const secondPart = secondParts[index];
13
12
  if (firstPart === secondPart) {
@@ -41,7 +40,6 @@ function compare(first, second) {
41
40
  if (index === lastIndex) {
42
41
  return 0;
43
42
  }
44
- continue;
45
43
  }
46
44
  return firstNumber - secondNumber;
47
45
  }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const is = require("../is.cjs");
4
+ const string_index = require("../string/index.cjs");
5
+ const value_equal = require("./equal.cjs");
6
+ function diff(first, second) {
7
+ const result = {
8
+ original: {
9
+ from: first,
10
+ to: second
11
+ },
12
+ type: "partial",
13
+ values: {}
14
+ };
15
+ const same = Object.is(first, second);
16
+ const firstIsArrayOrObject = is.isArrayOrPlainObject(first);
17
+ const secondIsArrayOrObject = is.isArrayOrPlainObject(second);
18
+ if (same || !firstIsArrayOrObject && !secondIsArrayOrObject) {
19
+ result.type = same ? "none" : "full";
20
+ return result;
21
+ }
22
+ if (firstIsArrayOrObject !== secondIsArrayOrObject) {
23
+ result.type = "full";
24
+ }
25
+ const diffs = getDiffs(
26
+ first,
27
+ second
28
+ );
29
+ const { length } = diffs;
30
+ if (length === 0) {
31
+ result.type = "none";
32
+ }
33
+ for (let index = 0; index < length; index += 1) {
34
+ const diff2 = diffs[index];
35
+ result.values[diff2.key] = { from: diff2.from, to: diff2.to };
36
+ }
37
+ return result;
38
+ }
39
+ function getDiffs(first, second, prefix) {
40
+ const changes = [];
41
+ const checked = /* @__PURE__ */ new Set();
42
+ for (let outerIndex = 0; outerIndex < 2; outerIndex += 1) {
43
+ const value = outerIndex === 0 ? first : second;
44
+ if (!value) {
45
+ continue;
46
+ }
47
+ const keys = Object.keys(value);
48
+ const { length } = keys;
49
+ for (let innerIndex = 0; innerIndex < length; innerIndex += 1) {
50
+ const key = keys[innerIndex];
51
+ if (checked.has(key)) {
52
+ continue;
53
+ }
54
+ const from = first == null ? void 0 : first[key];
55
+ const to = second == null ? void 0 : second[key];
56
+ if (!value_equal.equal(from, to)) {
57
+ const prefixed = string_index.join([prefix, key], ".");
58
+ const change = {
59
+ from,
60
+ to,
61
+ key: prefixed
62
+ };
63
+ const nested = is.isArrayOrPlainObject(from) || is.isArrayOrPlainObject(to);
64
+ const diffs = nested ? getDiffs(from, to, prefixed) : [];
65
+ if (!nested || nested && diffs.length > 0) {
66
+ changes.push(change);
67
+ }
68
+ changes.push(...diffs);
69
+ }
70
+ checked.add(key);
71
+ }
72
+ }
73
+ return changes;
74
+ }
75
+ exports.diff = diff;
@@ -1,7 +1,6 @@
1
- // src/js/value/diff.ts
2
- import { isArrayOrPlainObject } from "../is";
3
- import { join } from "../string";
4
- import { equal } from "./equal";
1
+ import { isArrayOrPlainObject } from "../is.js";
2
+ import { join } from "../string/index.js";
3
+ import { equal } from "./equal.js";
5
4
  function diff(first, second) {
6
5
  const result = {
7
6
  original: {
@@ -21,12 +20,15 @@ function diff(first, second) {
21
20
  if (firstIsArrayOrObject !== secondIsArrayOrObject) {
22
21
  result.type = "full";
23
22
  }
24
- const diffs = getDiffs(first, second);
23
+ const diffs = getDiffs(
24
+ first,
25
+ second
26
+ );
25
27
  const { length } = diffs;
26
28
  if (length === 0) {
27
29
  result.type = "none";
28
30
  }
29
- for (let index = 0;index < length; index += 1) {
31
+ for (let index = 0; index < length; index += 1) {
30
32
  const diff2 = diffs[index];
31
33
  result.values[diff2.key] = { from: diff2.from, to: diff2.to };
32
34
  }
@@ -34,21 +36,21 @@ function diff(first, second) {
34
36
  }
35
37
  function getDiffs(first, second, prefix) {
36
38
  const changes = [];
37
- const checked = new Set;
38
- for (let outerIndex = 0;outerIndex < 2; outerIndex += 1) {
39
+ const checked = /* @__PURE__ */ new Set();
40
+ for (let outerIndex = 0; outerIndex < 2; outerIndex += 1) {
39
41
  const value = outerIndex === 0 ? first : second;
40
42
  if (!value) {
41
43
  continue;
42
44
  }
43
45
  const keys = Object.keys(value);
44
46
  const { length } = keys;
45
- for (let innerIndex = 0;innerIndex < length; innerIndex += 1) {
47
+ for (let innerIndex = 0; innerIndex < length; innerIndex += 1) {
46
48
  const key = keys[innerIndex];
47
49
  if (checked.has(key)) {
48
50
  continue;
49
51
  }
50
- const from = first?.[key];
51
- const to = second?.[key];
52
+ const from = first == null ? void 0 : first[key];
53
+ const to = second == null ? void 0 : second[key];
52
54
  if (!equal(from, to)) {
53
55
  const prefixed = join([prefix, key], ".");
54
56
  const change = {
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const is = require("../is.cjs");
4
+ function equal(first, second, ignoreCase) {
5
+ switch (true) {
6
+ case first === second:
7
+ return true;
8
+ case (first == null || second == null):
9
+ return first === second;
10
+ case typeof first !== typeof second:
11
+ return false;
12
+ case (first instanceof ArrayBuffer && second instanceof ArrayBuffer):
13
+ return equalArrayBuffer(first, second);
14
+ case typeof first === "boolean":
15
+ case (first instanceof Date && second instanceof Date):
16
+ return Object.is(Number(first), Number(second));
17
+ case (first instanceof DataView && second instanceof DataView):
18
+ return equalDataView(first, second);
19
+ case (first instanceof Error && second instanceof Error):
20
+ return equalProperties(first, second, ["name", "message"]);
21
+ case (first instanceof Map && second instanceof Map):
22
+ return equalMap(first, second);
23
+ case (first instanceof RegExp && second instanceof RegExp):
24
+ return equalProperties(first, second, ["source", "flags"]);
25
+ case (first instanceof Set && second instanceof Set):
26
+ return equalSet(first, second);
27
+ case (Array.isArray(first) && Array.isArray(second)):
28
+ case (is.isPlainObject(first) && is.isPlainObject(second)):
29
+ return equalObject(first, second);
30
+ case (typeof first === "string" && ignoreCase === true):
31
+ return Object.is(first.toLowerCase(), second.toLowerCase());
32
+ default:
33
+ return Object.is(first, second);
34
+ }
35
+ }
36
+ function equalArrayBuffer(first, second) {
37
+ return first.byteLength === second.byteLength ? equalObject(
38
+ new Uint8Array(first),
39
+ new Uint8Array(second)
40
+ ) : false;
41
+ }
42
+ function equalDataView(first, second) {
43
+ return first.byteOffset === second.byteOffset ? equalArrayBuffer(first.buffer, second.buffer) : false;
44
+ }
45
+ function equalMap(first, second) {
46
+ const { size } = first;
47
+ if (size !== second.size) {
48
+ return false;
49
+ }
50
+ const firstKeys = [...first.keys()];
51
+ const secondKeys = [...second.keys()];
52
+ if (firstKeys.some((key) => !secondKeys.includes(key))) {
53
+ return false;
54
+ }
55
+ for (let index = 0; index < size; index += 1) {
56
+ const key = firstKeys[index];
57
+ if (!equal(first.get(key), second.get(key))) {
58
+ return false;
59
+ }
60
+ }
61
+ return true;
62
+ }
63
+ function equalObject(first, second) {
64
+ const firstKeys = Object.keys(first);
65
+ const secondKeys = Object.keys(second);
66
+ const { length } = firstKeys;
67
+ if (length !== secondKeys.length || firstKeys.some((key) => !secondKeys.includes(key))) {
68
+ return false;
69
+ }
70
+ for (let index = 0; index < length; index += 1) {
71
+ const key = firstKeys[index];
72
+ if (!equal(first[key], second[key])) {
73
+ return false;
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+ function equalProperties(first, second, properties) {
79
+ const { length } = properties;
80
+ for (let index = 0; index < length; index += 1) {
81
+ const property = properties[index];
82
+ if (!equal(
83
+ first[property],
84
+ second[property]
85
+ )) {
86
+ return false;
87
+ }
88
+ }
89
+ return true;
90
+ }
91
+ function equalSet(first, second) {
92
+ const { size } = first;
93
+ if (size !== second.size) {
94
+ return false;
95
+ }
96
+ const firstValues = [...first];
97
+ const secondValues = [...second];
98
+ for (let index = 0; index < size; index += 1) {
99
+ const firstValue = firstValues[index];
100
+ if (!secondValues.some((secondValue) => equal(firstValue, secondValue))) {
101
+ return false;
102
+ }
103
+ }
104
+ return true;
105
+ }
106
+ exports.equal = equal;
@@ -1,5 +1,4 @@
1
- // src/js/value/equal.ts
2
- import { isPlainObject } from "../is";
1
+ import { isPlainObject } from "../is.js";
3
2
  function equal(first, second, ignoreCase) {
4
3
  switch (true) {
5
4
  case first === second:
@@ -33,7 +32,10 @@ function equal(first, second, ignoreCase) {
33
32
  }
34
33
  }
35
34
  function equalArrayBuffer(first, second) {
36
- return first.byteLength === second.byteLength ? equalObject(new Uint8Array(first), new Uint8Array(second)) : false;
35
+ return first.byteLength === second.byteLength ? equalObject(
36
+ new Uint8Array(first),
37
+ new Uint8Array(second)
38
+ ) : false;
37
39
  }
38
40
  function equalDataView(first, second) {
39
41
  return first.byteOffset === second.byteOffset ? equalArrayBuffer(first.buffer, second.buffer) : false;
@@ -48,7 +50,7 @@ function equalMap(first, second) {
48
50
  if (firstKeys.some((key) => !secondKeys.includes(key))) {
49
51
  return false;
50
52
  }
51
- for (let index = 0;index < size; index += 1) {
53
+ for (let index = 0; index < size; index += 1) {
52
54
  const key = firstKeys[index];
53
55
  if (!equal(first.get(key), second.get(key))) {
54
56
  return false;
@@ -63,7 +65,7 @@ function equalObject(first, second) {
63
65
  if (length !== secondKeys.length || firstKeys.some((key) => !secondKeys.includes(key))) {
64
66
  return false;
65
67
  }
66
- for (let index = 0;index < length; index += 1) {
68
+ for (let index = 0; index < length; index += 1) {
67
69
  const key = firstKeys[index];
68
70
  if (!equal(first[key], second[key])) {
69
71
  return false;
@@ -73,9 +75,12 @@ function equalObject(first, second) {
73
75
  }
74
76
  function equalProperties(first, second, properties) {
75
77
  const { length } = properties;
76
- for (let index = 0;index < length; index += 1) {
78
+ for (let index = 0; index < length; index += 1) {
77
79
  const property = properties[index];
78
- if (!equal(first[property], second[property])) {
80
+ if (!equal(
81
+ first[property],
82
+ second[property]
83
+ )) {
79
84
  return false;
80
85
  }
81
86
  }
@@ -88,7 +93,7 @@ function equalSet(first, second) {
88
93
  }
89
94
  const firstValues = [...first];
90
95
  const secondValues = [...second];
91
- for (let index = 0;index < size; index += 1) {
96
+ for (let index = 0; index < size; index += 1) {
92
97
  const firstValue = firstValues[index];
93
98
  if (!secondValues.some((secondValue) => equal(firstValue, secondValue))) {
94
99
  return false;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const internal_value_handle = require("../internal/value/handle.cjs");
4
+ function getValue(data, path, ignoreCase) {
5
+ const shouldIgnoreCase = ignoreCase === true;
6
+ const parts = (shouldIgnoreCase ? path.toLowerCase() : path).split(".");
7
+ const { length } = parts;
8
+ let index = 0;
9
+ let value = data;
10
+ while (index < length && value != null) {
11
+ value = internal_value_handle.handleValue(
12
+ value,
13
+ parts[index++],
14
+ null,
15
+ true,
16
+ shouldIgnoreCase
17
+ );
18
+ }
19
+ return value;
20
+ }
21
+ exports.getValue = getValue;
@@ -1,13 +1,18 @@
1
- // src/js/value/get.ts
2
- import { handleValue } from "../internal/value-handle";
1
+ import { handleValue } from "../internal/value/handle.js";
3
2
  function getValue(data, path, ignoreCase) {
4
3
  const shouldIgnoreCase = ignoreCase === true;
5
4
  const parts = (shouldIgnoreCase ? path.toLowerCase() : path).split(".");
6
5
  const { length } = parts;
7
6
  let index = 0;
8
- let value = typeof data === "object" ? data ?? {} : {};
7
+ let value = data;
9
8
  while (index < length && value != null) {
10
- value = handleValue(value, parts[index++], null, true, shouldIgnoreCase);
9
+ value = handleValue(
10
+ value,
11
+ parts[index++],
12
+ null,
13
+ true,
14
+ shouldIgnoreCase
15
+ );
11
16
  }
12
17
  return value;
13
18
  }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const value_clone = require("./clone.cjs");
4
+ const value_compare = require("./compare.cjs");
5
+ const value_diff = require("./diff.cjs");
6
+ const value_equal = require("./equal.cjs");
7
+ const value_get = require("./get.cjs");
8
+ const value_merge = require("./merge.cjs");
9
+ const value_set = require("./set.cjs");
10
+ const value_smush = require("./smush.cjs");
11
+ const value_unsmush = require("./unsmush.cjs");
12
+ function partial(value, keys) {
13
+ const result = {};
14
+ const { length } = keys;
15
+ for (let index = 0; index < length; index += 1) {
16
+ const key = keys[index];
17
+ result[key] = value[key];
18
+ }
19
+ return result;
20
+ }
21
+ exports.clone = value_clone.clone;
22
+ exports.compare = value_compare.compare;
23
+ exports.diff = value_diff.diff;
24
+ exports.equal = value_equal.equal;
25
+ exports.getValue = value_get.getValue;
26
+ exports.merge = value_merge.merge;
27
+ exports.setValue = value_set.setValue;
28
+ exports.smush = value_smush.smush;
29
+ exports.unsmush = value_unsmush.unsmush;
30
+ exports.partial = partial;