@oscarpalmer/atoms 0.111.1 → 0.113.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 (161) hide show
  1. package/dist/array/get.js +9 -11
  2. package/dist/array/sort.js +17 -3
  3. package/dist/atoms.full.js +897 -503
  4. package/dist/color/constants.js +35 -9
  5. package/dist/color/index.js +7 -66
  6. package/dist/color/instance.js +58 -0
  7. package/dist/color/misc/alpha.js +27 -0
  8. package/dist/color/misc/foreground.js +15 -0
  9. package/dist/color/misc/is.js +56 -0
  10. package/dist/color/misc/state.js +81 -0
  11. package/dist/color/space/hex.js +51 -0
  12. package/dist/color/space/hsl.js +49 -0
  13. package/dist/color/space/rgb.js +84 -0
  14. package/dist/function.js +2 -1
  15. package/dist/index.js +7 -3
  16. package/dist/internal/array/callbacks.js +1 -0
  17. package/dist/internal/array/chunk.js +2 -1
  18. package/dist/internal/array/find.js +11 -6
  19. package/dist/internal/array/insert.js +9 -5
  20. package/dist/internal/function.js +4 -4
  21. package/dist/internal/is.js +2 -2
  22. package/dist/internal/math/aggregate.js +7 -7
  23. package/dist/internal/number.js +23 -14
  24. package/dist/internal/string.js +4 -4
  25. package/dist/internal/value/equal.js +12 -10
  26. package/dist/internal/value/misc.js +5 -5
  27. package/dist/internal/value/set.js +2 -2
  28. package/dist/is.js +4 -4
  29. package/dist/query.js +14 -13
  30. package/dist/random.js +11 -7
  31. package/dist/sized.js +20 -9
  32. package/dist/string/case.js +5 -4
  33. package/dist/string/misc.js +4 -5
  34. package/dist/string/template.js +4 -3
  35. package/dist/value/clone.js +9 -8
  36. package/dist/value/diff.js +43 -27
  37. package/dist/value/merge.js +20 -12
  38. package/dist/value/smush.js +2 -1
  39. package/dist/value/unsmush.js +3 -1
  40. package/package.json +7 -6
  41. package/src/array/exists.ts +14 -14
  42. package/src/array/filter.ts +12 -12
  43. package/src/array/find.ts +6 -6
  44. package/src/array/get.ts +18 -18
  45. package/src/array/group-by.ts +53 -36
  46. package/src/array/index-of.ts +10 -10
  47. package/src/array/insert.ts +9 -9
  48. package/src/array/push.ts +4 -4
  49. package/src/array/sort.ts +46 -24
  50. package/src/array/splice.ts +14 -14
  51. package/src/array/to-map.ts +48 -36
  52. package/src/array/to-record.ts +46 -34
  53. package/src/array/to-set.ts +5 -5
  54. package/src/array/unique.ts +5 -5
  55. package/src/color/constants.ts +61 -9
  56. package/src/color/index.ts +29 -131
  57. package/src/color/instance.ts +123 -0
  58. package/src/color/misc/alpha.ts +62 -0
  59. package/src/color/misc/foreground.ts +48 -0
  60. package/src/color/misc/is.ts +156 -0
  61. package/src/color/misc/state.ts +146 -0
  62. package/src/color/models.ts +15 -0
  63. package/src/color/space/hex.ts +110 -0
  64. package/src/color/space/hsl.ts +114 -0
  65. package/src/color/space/rgb.ts +157 -0
  66. package/src/emitter.ts +6 -6
  67. package/src/function.ts +17 -10
  68. package/src/internal/array/callbacks.ts +3 -0
  69. package/src/internal/array/chunk.ts +7 -1
  70. package/src/internal/array/compact.ts +1 -0
  71. package/src/internal/array/find.ts +28 -7
  72. package/src/internal/array/insert.ts +42 -20
  73. package/src/internal/array/shuffle.ts +2 -2
  74. package/src/internal/function.ts +11 -3
  75. package/src/internal/is.ts +7 -7
  76. package/src/internal/math/aggregate.ts +20 -20
  77. package/src/internal/number.ts +30 -24
  78. package/src/internal/random.ts +2 -2
  79. package/src/internal/string.ts +7 -7
  80. package/src/internal/value/compare.ts +6 -3
  81. package/src/internal/value/equal.ts +47 -24
  82. package/src/internal/value/get.ts +6 -6
  83. package/src/internal/value/misc.ts +11 -7
  84. package/src/internal/value/set.ts +10 -10
  85. package/src/is.ts +11 -11
  86. package/src/logger.ts +14 -13
  87. package/src/math.ts +33 -33
  88. package/src/models.ts +2 -0
  89. package/src/query.ts +28 -23
  90. package/src/random.ts +30 -17
  91. package/src/sized.ts +48 -32
  92. package/src/string/case.ts +16 -14
  93. package/src/string/misc.ts +5 -5
  94. package/src/string/template.ts +9 -6
  95. package/src/value/clone.ts +14 -10
  96. package/src/value/diff.ts +77 -43
  97. package/src/value/merge.ts +39 -24
  98. package/src/value/partial.ts +2 -2
  99. package/src/value/smush.ts +5 -1
  100. package/src/value/unsmush.ts +7 -9
  101. package/types/array/exists.d.ts +14 -14
  102. package/types/array/filter.d.ts +12 -12
  103. package/types/array/find.d.ts +6 -6
  104. package/types/array/get.d.ts +3 -3
  105. package/types/array/group-by.d.ts +52 -34
  106. package/types/array/index-of.d.ts +10 -10
  107. package/types/array/insert.d.ts +9 -9
  108. package/types/array/push.d.ts +4 -4
  109. package/types/array/splice.d.ts +14 -14
  110. package/types/array/to-map.d.ts +48 -36
  111. package/types/array/to-record.d.ts +46 -34
  112. package/types/array/to-set.d.ts +5 -5
  113. package/types/array/unique.d.ts +5 -5
  114. package/types/color/constants.d.ts +32 -9
  115. package/types/color/index.d.ts +9 -51
  116. package/types/color/instance.d.ts +56 -0
  117. package/types/color/misc/alpha.d.ts +3 -0
  118. package/types/color/misc/foreground.d.ts +7 -0
  119. package/types/color/misc/is.d.ts +39 -0
  120. package/types/color/misc/state.d.ts +5 -0
  121. package/types/color/models.d.ts +12 -1
  122. package/types/color/space/hex.d.ts +28 -0
  123. package/types/color/space/hsl.d.ts +30 -0
  124. package/types/color/space/rgb.d.ts +38 -0
  125. package/types/function.d.ts +5 -4
  126. package/types/internal/array/compact.d.ts +1 -0
  127. package/types/internal/array/insert.d.ts +3 -1
  128. package/types/internal/array/shuffle.d.ts +2 -2
  129. package/types/internal/is.d.ts +5 -5
  130. package/types/internal/math/aggregate.d.ts +9 -9
  131. package/types/internal/number.d.ts +7 -7
  132. package/types/internal/random.d.ts +2 -2
  133. package/types/internal/string.d.ts +3 -3
  134. package/types/internal/value/compare.d.ts +2 -2
  135. package/types/internal/value/equal.d.ts +10 -6
  136. package/types/internal/value/get.d.ts +6 -6
  137. package/types/internal/value/set.d.ts +8 -8
  138. package/types/is.d.ts +7 -7
  139. package/types/logger.d.ts +11 -34
  140. package/types/math.d.ts +32 -32
  141. package/types/models.d.ts +2 -0
  142. package/types/random.d.ts +7 -6
  143. package/types/sized.d.ts +18 -21
  144. package/types/string/case.d.ts +5 -5
  145. package/types/string/misc.d.ts +2 -2
  146. package/types/string/template.d.ts +3 -3
  147. package/types/value/diff.d.ts +3 -3
  148. package/types/value/merge.d.ts +2 -2
  149. package/types/value/partial.d.ts +2 -2
  150. package/dist/color/is.js +0 -43
  151. package/dist/color/misc.js +0 -9
  152. package/dist/color/state.js +0 -44
  153. package/dist/color/value.js +0 -72
  154. package/src/color/is.ts +0 -98
  155. package/src/color/misc.ts +0 -20
  156. package/src/color/state.ts +0 -55
  157. package/src/color/value.ts +0 -145
  158. package/types/color/is.d.ts +0 -26
  159. package/types/color/misc.d.ts +0 -6
  160. package/types/color/state.d.ts +0 -2
  161. package/types/color/value.d.ts +0 -27
package/dist/array/get.js CHANGED
@@ -1,17 +1,15 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
2
  function getArray(value, indiced) {
3
3
  if (Array.isArray(value)) return value;
4
- if (isPlainObject(value)) {
5
- if (indiced !== true) return Object.values(value);
6
- const keys = Object.keys(value);
7
- const { length } = keys;
8
- const array = [];
9
- for (let index = 0; index < length; index += 1) {
10
- const key = keys[index];
11
- if (!Number.isNaN(Number(key))) array.push(value[key]);
12
- }
13
- return array;
4
+ if (!isPlainObject(value)) return [value];
5
+ if (indiced !== true) return Object.values(value);
6
+ const keys = Object.keys(value);
7
+ const { length } = keys;
8
+ const array = [];
9
+ for (let index = 0; index < length; index += 1) {
10
+ const key = keys[index];
11
+ if (!Number.isNaN(Number(key))) array.push(value[key]);
14
12
  }
15
- return [value];
13
+ return array;
16
14
  }
17
15
  export { getArray };
@@ -1,6 +1,20 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
2
  import "../is.js";
3
3
  import { compare } from "../internal/value/compare.js";
4
+ function getCallback(value, key, isObject) {
5
+ if (key != null) return;
6
+ if (isObject && typeof value.value === "function") return value.value;
7
+ return typeof value === "function" ? value : void 0;
8
+ }
9
+ function getKey(value, isObject) {
10
+ if (isObject && typeof value.key === "string") return value.key;
11
+ return typeof value === "string" ? value : void 0;
12
+ }
13
+ function getModifier(value, modifier, isObject) {
14
+ if (!isObject || typeof value.direction !== "string") return modifier;
15
+ if (value.direction === "ascending") return 1;
16
+ return value.direction === "descending" ? -1 : modifier;
17
+ }
4
18
  function getSorter(value, modifier) {
5
19
  const isObject = isPlainObject(value);
6
20
  const sorter = {
@@ -8,9 +22,9 @@ function getSorter(value, modifier) {
8
22
  modifier
9
23
  };
10
24
  sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
11
- sorter.key = isObject && typeof value.key === "string" ? value.key : typeof value === "string" ? value : void 0;
12
- sorter.callback = sorter.key == null ? isObject && typeof value.value === "function" ? value.value : typeof value === "function" ? value : void 0 : void 0;
13
- if (isObject && typeof value.direction === "string") sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
25
+ sorter.key = getKey(value, isObject);
26
+ sorter.modifier = getModifier(value, modifier, isObject);
27
+ sorter.callback = getCallback(value, sorter.key, isObject);
14
28
  if (sorter.key != null || sorter.callback != null) {
15
29
  sorter.identifier = `${sorter.key ?? sorter.callback}`;
16
30
  return sorter;