@oscarpalmer/atoms 0.202.0 → 0.203.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 (156) hide show
  1. package/dist/array/difference.d.mts +4 -5
  2. package/dist/array/exists.d.mts +5 -6
  3. package/dist/array/filter.d.mts +10 -11
  4. package/dist/array/find.d.mts +10 -11
  5. package/dist/array/first.d.mts +10 -11
  6. package/dist/array/flatten.d.mts +2 -3
  7. package/dist/array/from.d.mts +7 -8
  8. package/dist/array/group-by.d.mts +7 -8
  9. package/dist/array/insert.d.mts +3 -4
  10. package/dist/array/intersection.d.mts +4 -5
  11. package/dist/array/last.d.mts +10 -11
  12. package/dist/array/move.d.mts +9 -10
  13. package/dist/array/partition.d.mts +5 -6
  14. package/dist/array/push.d.mts +2 -3
  15. package/dist/array/reverse.d.mts +2 -3
  16. package/dist/array/select.d.mts +11 -12
  17. package/dist/array/single.d.mts +4 -5
  18. package/dist/array/slice.d.mts +12 -13
  19. package/dist/array/sort.d.mts +31 -32
  20. package/dist/array/sort.mjs +41 -33
  21. package/dist/array/splice.d.mts +5 -6
  22. package/dist/array/swap.d.mts +8 -9
  23. package/dist/array/to-map.d.mts +7 -8
  24. package/dist/array/to-record.d.mts +7 -8
  25. package/dist/array/to-set.d.mts +4 -5
  26. package/dist/array/toggle.d.mts +4 -5
  27. package/dist/array/union.d.mts +4 -5
  28. package/dist/array/unique.d.mts +4 -5
  29. package/dist/array/update.d.mts +4 -5
  30. package/dist/beacon.d.mts +8 -9
  31. package/dist/beacon.mjs +90 -65
  32. package/dist/color/constants.d.mts +14 -13
  33. package/dist/color/constants.mjs +9 -2
  34. package/dist/color/index.d.mts +2 -2
  35. package/dist/color/instance.d.mts +3 -3
  36. package/dist/color/instance.mjs +125 -61
  37. package/dist/color/misc/alpha.d.mts +4 -5
  38. package/dist/color/misc/format.d.mts +6 -7
  39. package/dist/color/misc/format.mjs +15 -12
  40. package/dist/color/misc/get.d.mts +14 -15
  41. package/dist/color/misc/is.d.mts +16 -17
  42. package/dist/color/misc/is.mjs +3 -4
  43. package/dist/color/misc/state.d.mts +8 -10
  44. package/dist/color/misc/state.mjs +22 -20
  45. package/dist/color/models.d.mts +25 -19
  46. package/dist/color/space/hex.d.mts +9 -10
  47. package/dist/color/space/hsl.d.mts +8 -9
  48. package/dist/color/space/hwb.d.mts +9 -10
  49. package/dist/color/space/rgb.d.mts +11 -12
  50. package/dist/function/limit.d.mts +9 -8
  51. package/dist/function/limit.mjs +5 -5
  52. package/dist/function/once.d.mts +26 -6
  53. package/dist/function/once.mjs +135 -76
  54. package/dist/function/retry.d.mts +5 -6
  55. package/dist/function/retry.mjs +3 -3
  56. package/dist/index.d.mts +182 -58
  57. package/dist/index.mjs +1191 -810
  58. package/dist/internal/abort.d.mts +3 -4
  59. package/dist/internal/array/callbacks.d.mts +4 -5
  60. package/dist/internal/array/chunk.d.mts +2 -3
  61. package/dist/internal/array/compact.d.mts +3 -4
  62. package/dist/internal/array/find.d.mts +10 -11
  63. package/dist/internal/array/get.d.mts +7 -8
  64. package/dist/internal/array/group.d.mts +2 -3
  65. package/dist/internal/array/index-of.d.mts +10 -11
  66. package/dist/internal/array/insert.d.mts +5 -6
  67. package/dist/internal/array/match.d.mts +17 -18
  68. package/dist/internal/array/overlap.d.mts +2 -3
  69. package/dist/internal/array/sets.d.mts +5 -6
  70. package/dist/internal/array/shuffle.d.mts +2 -3
  71. package/dist/internal/array/update.d.mts +2 -3
  72. package/dist/internal/defaults.d.mts +3 -4
  73. package/dist/internal/function/assert.d.mts +10 -11
  74. package/dist/internal/function/limit.d.mts +41 -0
  75. package/dist/internal/function/limit.mjs +110 -0
  76. package/dist/internal/function/memoize.d.mts +4 -5
  77. package/dist/internal/function/memoize.mjs +53 -31
  78. package/dist/internal/function/misc.d.mts +2 -3
  79. package/dist/internal/function/work.d.mts +53 -54
  80. package/dist/internal/herald.d.mts +8 -9
  81. package/dist/internal/herald.mjs +38 -26
  82. package/dist/internal/is.d.mts +19 -20
  83. package/dist/internal/math/aggregate.d.mts +14 -15
  84. package/dist/internal/math/misc.d.mts +3 -4
  85. package/dist/internal/number.d.mts +4 -5
  86. package/dist/internal/random.d.mts +3 -4
  87. package/dist/internal/result/misc.d.mts +29 -14
  88. package/dist/internal/result/misc.mjs +4 -0
  89. package/dist/internal/result/models.d.mts +9 -10
  90. package/dist/internal/sized/map.d.mts +2 -3
  91. package/dist/internal/sized/misc.d.mts +2 -3
  92. package/dist/internal/string/case.d.mts +9 -10
  93. package/dist/internal/string/misc.d.mts +8 -9
  94. package/dist/internal/subscription.d.mts +10 -11
  95. package/dist/internal/subscription.mjs +69 -57
  96. package/dist/internal/value/compare.d.mts +17 -9
  97. package/dist/internal/value/compare.mjs +7 -7
  98. package/dist/internal/value/equal.d.mts +34 -15
  99. package/dist/internal/value/equal.mjs +28 -13
  100. package/dist/internal/value/get.d.mts +3 -4
  101. package/dist/internal/value/handlers.d.mts +19 -9
  102. package/dist/internal/value/handlers.mjs +50 -50
  103. package/dist/internal/value/has.d.mts +6 -7
  104. package/dist/internal/value/misc.d.mts +6 -7
  105. package/dist/internal/value/partial.d.mts +3 -4
  106. package/dist/internal/value/set.d.mts +4 -5
  107. package/dist/is.d.mts +13 -13
  108. package/dist/logger.d.mts +5 -4
  109. package/dist/logger.mjs +61 -54
  110. package/dist/math.d.mts +20 -20
  111. package/dist/models.d.mts +45 -49
  112. package/dist/promise/constants.d.mts +14 -15
  113. package/dist/promise/delay.d.mts +3 -4
  114. package/dist/promise/delay.mjs +4 -4
  115. package/dist/promise/helpers.d.mts +7 -8
  116. package/dist/promise/index.d.mts +13 -14
  117. package/dist/promise/misc.d.mts +6 -6
  118. package/dist/promise/models.d.mts +16 -17
  119. package/dist/promise/timed.d.mts +4 -5
  120. package/dist/promise/timed.mjs +5 -5
  121. package/dist/query.d.mts +3 -4
  122. package/dist/queue.d.mts +14 -15
  123. package/dist/queue.mjs +185 -129
  124. package/dist/random.d.mts +8 -8
  125. package/dist/result/index.d.mts +8 -9
  126. package/dist/result/match.d.mts +6 -7
  127. package/dist/result/misc.d.mts +3 -3
  128. package/dist/result/work/flow.d.mts +28 -29
  129. package/dist/result/work/pipe.d.mts +24 -25
  130. package/dist/sized/set.d.mts +2 -3
  131. package/dist/string/fuzzy.d.mts +21 -12
  132. package/dist/string/fuzzy.mjs +77 -49
  133. package/dist/string/index.d.mts +8 -8
  134. package/dist/string/match.d.mts +4 -5
  135. package/dist/string/normalize.d.mts +8 -9
  136. package/dist/string/normalize.mjs +9 -4
  137. package/dist/string/template.d.mts +9 -9
  138. package/dist/string/template.mjs +11 -4
  139. package/dist/value/clone.d.mts +21 -13
  140. package/dist/value/clone.mjs +22 -20
  141. package/dist/value/collection.d.mts +4 -5
  142. package/dist/value/diff.d.mts +5 -6
  143. package/dist/value/freeze.d.mts +18 -19
  144. package/dist/value/freeze.mjs +1 -1
  145. package/dist/value/merge.d.mts +13 -14
  146. package/dist/value/merge.mjs +21 -5
  147. package/dist/value/omit.d.mts +2 -3
  148. package/dist/value/pick.d.mts +2 -3
  149. package/dist/value/shake.d.mts +3 -4
  150. package/dist/value/smush.d.mts +3 -4
  151. package/dist/value/transform.d.mts +15 -10
  152. package/dist/value/transform.mjs +12 -7
  153. package/dist/value/unsmush.d.mts +3 -4
  154. package/package.json +1 -1
  155. package/dist/internal/function/timer.d.mts +0 -10
  156. package/dist/internal/function/timer.mjs +0 -87
@@ -19,7 +19,7 @@ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue } from "../mod
19
19
  * ); // => Map { 10 => 3, 20 => 2 }
20
20
  * ```
21
21
  */
22
- declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
22
+ export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
23
23
  /**
24
24
  * Create a _Map_ from an array of items using a specific key
25
25
  *
@@ -37,7 +37,7 @@ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg e
37
37
  * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
38
38
  * ```
39
39
  */
40
- declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
40
+ export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
41
41
  /**
42
42
  * Create a _Map_ from an array of items _(using indices as keys)_
43
43
  *
@@ -51,8 +51,8 @@ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Ite
51
51
  * ); // => Map { 0 => {id: 1, value: 10}, 1 => {id: 2, value: 20}, 2 => {id: 3, value: 10} }
52
52
  * ```
53
53
  */
54
- declare function toMap<Item>(array: Item[]): Map<number, Item>;
55
- declare namespace toMap {
54
+ export declare function toMap<Item>(array: Item[]): Map<number, Item>;
55
+ export declare namespace toMap {
56
56
  var arrays: typeof toMapArrays;
57
57
  }
58
58
  /**
@@ -74,7 +74,7 @@ declare namespace toMap {
74
74
  * ); // => Map { 10 => [1, 3], 20 => [2] }
75
75
  * ```
76
76
  */
77
- declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
77
+ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
78
78
  /**
79
79
  * Create a _Map_ from an array of items using a specific key, grouping items into arrays
80
80
  *
@@ -92,6 +92,5 @@ declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, Valu
92
92
  * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
93
93
  * ```
94
94
  */
95
- declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
96
- //#endregion
97
- export { toMap, toMapArrays };
95
+ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
96
+ //#endregion
@@ -19,7 +19,7 @@ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } fr
19
19
  * ); // => { 10: 3, 20: 2 }
20
20
  * ```
21
21
  */
22
- declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
22
+ export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
23
23
  /**
24
24
  * Create a record from an array of items using a specific key
25
25
  *
@@ -37,7 +37,7 @@ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueAr
37
37
  * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
38
38
  * ```
39
39
  */
40
- declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
40
+ export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
41
41
  /**
42
42
  * Create a record from an array of items _(using indices as keys)_
43
43
  *
@@ -51,8 +51,8 @@ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array:
51
51
  * ); // => { 0: {id: 1, value: 10}, 1: {id: 2, value: 20}, 2: {id: 3, value: 10} }
52
52
  * ```
53
53
  */
54
- declare function toRecord<Item>(array: Item[]): Record<number, Item>;
55
- declare namespace toRecord {
54
+ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
55
+ export declare namespace toRecord {
56
56
  var arrays: typeof toRecordArrays;
57
57
  }
58
58
  /**
@@ -74,7 +74,7 @@ declare namespace toRecord {
74
74
  * ); // => { 10: [1, 3], 20: [2] }
75
75
  * ```
76
76
  */
77
- declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
77
+ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
78
78
  /**
79
79
  * Create a record from an array of items using a specific key, grouping items into arrays
80
80
  *
@@ -92,6 +92,5 @@ declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, V
92
92
  * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
93
93
  * ```
94
94
  */
95
- declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
96
- //#endregion
97
- export { toRecord, toRecordArrays };
95
+ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
96
+ //#endregion
@@ -15,7 +15,7 @@ import { PlainObject } from "../models.mjs";
15
15
  * ); // => Set { 1, 2, 3 }
16
16
  * ```
17
17
  */
18
- declare function toSet<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback): Set<ReturnType<Callback>>;
18
+ export declare function toSet<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback): Set<ReturnType<Callback>>;
19
19
  /**
20
20
  * Create a _Set_ from an array of items using a key
21
21
  *
@@ -31,7 +31,7 @@ declare function toSet<Item, Callback extends (item: Item, index: number, array:
31
31
  * ); // => Set { 1, 2, 3 }
32
32
  * ```
33
33
  */
34
- declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Set<Item[ItemKey]>;
34
+ export declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Set<Item[ItemKey]>;
35
35
  /**
36
36
  * Create a _Set_ from an array of items
37
37
  *
@@ -43,6 +43,5 @@ declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(arr
43
43
  * toSet([1, 2, 3]); // => Set { 1, 2, 3 }
44
44
  * ```
45
45
  */
46
- declare function toSet<Item>(array: Item[]): Set<Item>;
47
- //#endregion
48
- export { toSet };
46
+ export declare function toSet<Item>(array: Item[]): Set<Item>;
47
+ //#endregion
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
19
19
  * ); // => [{id: 1}, {id: 3}, {id: 4}]
20
20
  * ```
21
21
  */
22
- declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
22
+ export declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
23
23
  /**
24
24
  * Toggle an item in an array
25
25
  *
@@ -39,7 +39,7 @@ declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (i
39
39
  * ); // => [{id: 1}, {id: 3}, {id: 4}]
40
40
  * ```
41
41
  */
42
- declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], toggled: Item[], key: ItemKey): Item[];
42
+ export declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], toggled: Item[], key: ItemKey): Item[];
43
43
  /**
44
44
  * Toggle an item in an array
45
45
  *
@@ -57,6 +57,5 @@ declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(de
57
57
  * ); // => [1, 3, 4]
58
58
  * ```
59
59
  */
60
- declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
61
- //#endregion
62
- export { toggle };
60
+ export declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
61
+ //#endregion
@@ -16,7 +16,7 @@
16
16
  * ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
17
17
  * ```
18
18
  */
19
- declare function union<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): (First | Second)[];
19
+ export declare function union<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): (First | Second)[];
20
20
  /**
21
21
  * Get the combined, unique values from two arrays
22
22
  *
@@ -34,7 +34,7 @@ declare function union<First, Second>(first: First[], second: Second[], callback
34
34
  * ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
35
35
  * ```
36
36
  */
37
- declare function union<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): (First | Second)[];
37
+ export declare function union<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): (First | Second)[];
38
38
  /**
39
39
  * Get the combined, unique values from two arrays
40
40
  *
@@ -50,6 +50,5 @@ declare function union<First extends Record<string, unknown>, Second extends Rec
50
50
  * ); // => [1, 2, 3, 4]
51
51
  * ```
52
52
  */
53
- declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
54
- //#endregion
55
- export { union };
53
+ export declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
54
+ //#endregion
@@ -15,7 +15,7 @@ import { PlainObject } from "../models.mjs";
15
15
  * ); // => [{id: 1}, {id: 2}, {id: 3}]
16
16
  * ```
17
17
  */
18
- declare function unique<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
18
+ export declare function unique<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
19
19
  /**
20
20
  * Get an array of unique items
21
21
  *
@@ -31,7 +31,7 @@ declare function unique<Item>(array: Item[], callback: (item: Item, index: numbe
31
31
  * ); // => [{id: 1}, {id: 2}, {id: 3}]
32
32
  * ```
33
33
  */
34
- declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
34
+ export declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
35
35
  /**
36
36
  * Get an array of unique items
37
37
  *
@@ -43,6 +43,5 @@ declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(ar
43
43
  * unique([1, 2, 3, 2]); // => [1, 2, 3]
44
44
  * ```
45
45
  */
46
- declare function unique<Item>(array: Item[]): Item[];
47
- //#endregion
48
- export { unique };
46
+ export declare function unique<Item>(array: Item[]): Item[];
47
+ //#endregion
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
19
19
  * ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
20
20
  * ```
21
21
  */
22
- declare function update<Item>(destination: Item[], updated: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
22
+ export declare function update<Item>(destination: Item[], updated: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
23
23
  /**
24
24
  * Update an item in an array
25
25
  *
@@ -39,7 +39,7 @@ declare function update<Item>(destination: Item[], updated: Item[], callback: (i
39
39
  * ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
40
40
  * ```
41
41
  */
42
- declare function update<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], updated: Item[], key: ItemKey): Item[];
42
+ export declare function update<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], updated: Item[], key: ItemKey): Item[];
43
43
  /**
44
44
  * Update an item in an array
45
45
  *
@@ -57,6 +57,5 @@ declare function update<Item extends PlainObject, ItemKey extends keyof Item>(de
57
57
  * ); // => [1, 2, 3, 4]
58
58
  * ```
59
59
  */
60
- declare function update<Item>(destination: Item[], updated: Item[]): Item[];
61
- //#endregion
62
- export { update };
60
+ export declare function update<Item>(destination: Item[], updated: Item[]): Item[];
61
+ //#endregion
package/dist/beacon.d.mts CHANGED
@@ -3,7 +3,7 @@ import { Subscription } from "./internal/subscription.mjs";
3
3
  /**
4
4
  * A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
5
5
  */
6
- type Beacon<Value> = {
6
+ export type Beacon<Value> = {
7
7
  /**
8
8
  * Is the beacon active?
9
9
  */
@@ -39,7 +39,7 @@ type Beacon<Value> = {
39
39
  */
40
40
  finish(): void;
41
41
  };
42
- type BeaconOptions<Value> = {
42
+ export type BeaconOptions<Value> = {
43
43
  /**
44
44
  * Method for comparing values for equality
45
45
  *
@@ -50,7 +50,7 @@ type BeaconOptions<Value> = {
50
50
  */
51
51
  equal?: (first: Value, second: Value) => boolean;
52
52
  };
53
- type Observable<Value> = {
53
+ export type Observable<Value> = {
54
54
  /**
55
55
  * Is the observable active?
56
56
  */
@@ -97,27 +97,26 @@ type Observer<Value> = {
97
97
  * @param options Beacon options
98
98
  * @returns Beacon instance
99
99
  */
100
- declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Beacon<Value>;
100
+ export declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Beacon<Value>;
101
101
  /**
102
102
  * Is the value a beacon?
103
103
  *
104
104
  * @param value Value to check
105
105
  * @returns `true` if the value is a beacon, otherwise `false`
106
106
  */
107
- declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
107
+ export declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
108
108
  /**
109
109
  * Is the value a beacon subscription?
110
110
  *
111
111
  * @param value Value to check
112
112
  * @returns `true` if the value is a beacon subscription, otherwise `false`
113
113
  */
114
- declare function isBeaconSubscription(value: unknown): value is Subscription;
114
+ export declare function isBeaconSubscription(value: unknown): value is Subscription;
115
115
  /**
116
116
  * Is the value an observable?
117
117
  *
118
118
  * @param value Value to check
119
119
  * @returns `true` if the value is an observable, otherwise `false`
120
120
  */
121
- declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
122
- //#endregion
123
- export { Beacon, BeaconOptions, Observable, beacon, isBeacon, isBeaconSubscription, isObservable };
121
+ export declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
122
+ //#endregion
package/dist/beacon.mjs CHANGED
@@ -2,6 +2,59 @@ import { noop } from "./internal/function/misc.mjs";
2
2
  import { isPlainObject } from "./internal/is.mjs";
3
3
  import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./internal/subscription.mjs";
4
4
  //#region src/beacon.ts
5
+ const BEACON_PROPERTY = "$beacon";
6
+ const BEACON_NAME = "beacon";
7
+ const BEACON_OBSERVABLE = "observable";
8
+ function Beacon(value, options) {
9
+ Object.defineProperty(this, BEACON_SYMBOL, { value: {
10
+ value,
11
+ active: true,
12
+ options: createBeaconOptions(options)
13
+ } });
14
+ }
15
+ Object.defineProperties(Beacon.prototype, {
16
+ [BEACON_PROPERTY]: { value: BEACON_NAME },
17
+ active: {
18
+ enumerable: true,
19
+ get() {
20
+ return this[BEACON_SYMBOL].active;
21
+ }
22
+ },
23
+ deactivate: { value: deactivateBeacon },
24
+ emit: { value: emitBeaconValue },
25
+ error: { value: emitBeaconError },
26
+ finish: { value: finishBeacon },
27
+ observable: {
28
+ enumerable: true,
29
+ get() {
30
+ return getObservable(this[BEACON_SYMBOL]);
31
+ }
32
+ },
33
+ value: {
34
+ enumerable: true,
35
+ get() {
36
+ return this[BEACON_SYMBOL].value;
37
+ }
38
+ }
39
+ });
40
+ function Observable(beacon) {
41
+ Object.defineProperty(this, BEACON_SYMBOL, { value: {
42
+ beacon,
43
+ active: beacon.active
44
+ } });
45
+ }
46
+ Object.defineProperties(Observable.prototype, {
47
+ [BEACON_PROPERTY]: { value: BEACON_OBSERVABLE },
48
+ active: {
49
+ enumerable: true,
50
+ get() {
51
+ const state = this[BEACON_SYMBOL];
52
+ return state.beacon.active && state.active;
53
+ }
54
+ },
55
+ deactivate: { value: deactiveateObservable },
56
+ subscribe: { value: subscribeToObservable }
57
+ });
5
58
  /**
6
59
  * Create a new beacon
7
60
  *
@@ -10,61 +63,24 @@ import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./internal/sub
10
63
  * @returns Beacon instance
11
64
  */
12
65
  function beacon(value, options) {
13
- const state = {
14
- value,
15
- active: true,
16
- observable: void 0,
17
- options: createBeaconOptions(options),
18
- subscriptions: subscriptions({ property: beaconSubscription })
19
- };
20
- const instance = {
21
- deactivate: () => finishBeacon(state, false),
22
- emit: (value, finish) => updateBeacon(BEACON_TYPE_NEXT, state, value, finish),
23
- error: (value, finish) => updateBeacon(BEACON_TYPE_ERROR, state, value, finish),
24
- finish: () => finishBeacon(state, true)
25
- };
26
- Object.defineProperties(instance, {
27
- [BEACON_PROPERTY]: { value: BEACON_NAME },
28
- active: {
29
- enumerable: true,
30
- get: () => state.active
31
- },
32
- observable: {
33
- enumerable: true,
34
- get: () => getObservable(state)
35
- },
36
- value: {
37
- enumerable: true,
38
- get: () => state.value
39
- }
40
- });
41
- return Object.freeze(instance);
66
+ return new Beacon(value, options);
67
+ }
68
+ function closeBeacon(state, emit) {
69
+ if (!state.active) return;
70
+ state.active = false;
71
+ const subscriptions = state.subscriptions?.values.to.any;
72
+ if (subscriptions != null && subscriptions.size > 0) {
73
+ for (const [, observer] of subscriptions) if (emit) observer.complete?.();
74
+ }
75
+ state.subscriptions?.clear();
76
+ state.observable?.deactivate();
77
+ state.observable = void 0;
42
78
  }
43
79
  function createBeaconOptions(input) {
44
80
  const options = isPlainObject(input) ? input : {};
45
81
  options.equal = typeof options.equal === "function" ? options.equal : Object.is;
46
82
  return options;
47
83
  }
48
- function createObservable(beacon) {
49
- const state = {
50
- beacon,
51
- active: beacon.active
52
- };
53
- const instance = {
54
- deactivate: () => {
55
- state.active = false;
56
- },
57
- subscribe: (first, second, third) => subscribeToObservable(state, first, second, third)
58
- };
59
- Object.defineProperties(instance, {
60
- [BEACON_PROPERTY]: { value: BEACON_OBSERVABLE },
61
- active: {
62
- enumerable: true,
63
- get: () => beacon.active && state.active
64
- }
65
- });
66
- return Object.freeze(instance);
67
- }
68
84
  function createObserver(first, second, third) {
69
85
  let observer = { next: noop };
70
86
  if (typeof first === "function") observer = {
@@ -79,17 +95,24 @@ function createObserver(first, second, third) {
79
95
  }
80
96
  return observer;
81
97
  }
82
- function finishBeacon(state, emit) {
83
- if (!state.active) return;
84
- state.active = false;
85
- for (const [, observer] of state.subscriptions.values.to.any) if (emit) observer.complete?.();
86
- state.subscriptions.clear();
87
- state.observable?.deactivate();
88
- state.observable = void 0;
98
+ function deactivateBeacon() {
99
+ closeBeacon(this[BEACON_SYMBOL], false);
100
+ }
101
+ function deactiveateObservable() {
102
+ this[BEACON_SYMBOL].active = false;
103
+ }
104
+ function emitBeaconError(error, finish) {
105
+ updateBeacon(this, BEACON_TYPE_ERROR, error, finish ?? false);
106
+ }
107
+ function emitBeaconValue(value, finish) {
108
+ updateBeacon(this, BEACON_TYPE_NEXT, value, finish ?? false);
109
+ }
110
+ function finishBeacon() {
111
+ closeBeacon(this[BEACON_SYMBOL], true);
89
112
  }
90
113
  function getObservable(state) {
91
114
  if (!state.active) throw new Error(BEACON_MESSAGE_RETRIEVE);
92
- state.observable ??= createObservable(state);
115
+ state.observable ??= new Observable(state);
93
116
  return state.observable;
94
117
  }
95
118
  function getObservableCallback(value) {
@@ -105,7 +128,7 @@ function isBeacon(value) {
105
128
  return isBeaconInstance(BEACON_NAME, value);
106
129
  }
107
130
  function isBeaconInstance(name, value) {
108
- return isPlainObject(value) && value[BEACON_PROPERTY] === name;
131
+ return typeof value === "object" && value !== null && value[BEACON_PROPERTY] === name;
109
132
  }
110
133
  /**
111
134
  * Is the value a beacon subscription?
@@ -125,8 +148,10 @@ function isBeaconSubscription(value) {
125
148
  function isObservable(value) {
126
149
  return isBeaconInstance(BEACON_OBSERVABLE, value);
127
150
  }
128
- function subscribeToObservable(state, first, second, third) {
151
+ function subscribeToObservable(first, second, third) {
152
+ const state = this[BEACON_SYMBOL];
129
153
  if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
154
+ state.beacon.subscriptions ??= subscriptions({ property: beaconSubscription });
130
155
  const observer = createObserver(first, second, third);
131
156
  const [subscription] = state.beacon.subscriptions.create({
132
157
  isActive: () => state.beacon.active && state.active,
@@ -135,20 +160,20 @@ function subscribeToObservable(state, first, second, third) {
135
160
  observer.next?.(state.beacon.value);
136
161
  return subscription;
137
162
  }
138
- function updateBeacon(type, state, value, finish) {
163
+ function updateBeacon(instance, type, value, finish) {
164
+ const state = instance[BEACON_SYMBOL];
139
165
  if (!state.active) return;
140
166
  if (type === BEACON_TYPE_NEXT) {
141
167
  if (state.options.equal(state.value, value)) return;
142
168
  state.value = value;
143
169
  }
144
- for (const [, observer] of state.subscriptions.values.to.any) observer[type]?.(value);
145
- if (finish === true) finishBeacon(state, true);
170
+ const subscriptions = state.subscriptions?.values.to.any;
171
+ if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
172
+ if (finish === true) closeBeacon(state, true);
146
173
  }
147
174
  const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
148
175
  const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
149
- const BEACON_PROPERTY = "$beacon";
150
- const BEACON_NAME = "beacon";
151
- const BEACON_OBSERVABLE = "observable";
176
+ const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
152
177
  const BEACON_TYPE_ERROR = "error";
153
178
  const BEACON_TYPE_NEXT = "next";
154
179
  const beaconSubscription = {
@@ -1,3 +1,4 @@
1
+ import { SubscriptionProperty } from "../internal/subscription.mjs";
1
2
  import { ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
2
3
  //#region src/color/constants.d.ts
3
4
  type ColorTypes = {
@@ -12,14 +13,14 @@ type ColorTypes = {
12
13
  rgba: 'rgba';
13
14
  wildcard: '*';
14
15
  };
15
- declare const COLOR_ALPHA: {
16
+ export declare const COLOR_ALPHA: {
16
17
  fullHexShort: string;
17
18
  fullHexLong: string;
18
19
  name: string;
19
20
  noneHex: string;
20
21
  noneValue: number;
21
22
  };
22
- declare const COLOR_DEFAULTS: {
23
+ export declare const COLOR_DEFAULTS: {
23
24
  alpha: {
24
25
  hex: string;
25
26
  value: number;
@@ -42,17 +43,17 @@ declare const COLOR_DEFAULTS: {
42
43
  red: number;
43
44
  };
44
45
  };
45
- declare const COLOR_EXPRESSION: {
46
+ export declare const COLOR_EXPRESSION: {
46
47
  alphaHex: RegExp;
47
48
  hexLong: RegExp;
48
49
  hexShort: RegExp;
49
50
  prefix: RegExp;
50
51
  };
51
- declare const COLOR_LENGTHS: {
52
+ export declare const COLOR_LENGTHS: {
52
53
  hexLong: number;
53
54
  hexShort: number;
54
55
  };
55
- declare const COLOR_KEYS: {
56
+ export declare const COLOR_KEYS: {
56
57
  hsl: Array<keyof HSLColor>;
57
58
  hsla: Array<keyof HSLAColor>;
58
59
  hwb: Array<keyof HWBColor>;
@@ -60,16 +61,16 @@ declare const COLOR_KEYS: {
60
61
  rgb: Array<keyof RGBColor>;
61
62
  rgba: Array<keyof RGBAColor>;
62
63
  };
63
- declare const COLOR_MAX: {
64
+ export declare const COLOR_MAX: {
64
65
  degree: number;
65
66
  hex: number;
66
67
  percent: number;
67
68
  };
68
- declare const COLOR_PROPERTY: {
69
- name: string;
70
- };
71
- declare const COLOR_TYPE: ColorTypes;
72
- declare const COLOR_SRGB: {
69
+ export declare const COLOR_NAME = "color";
70
+ export declare const COLOR_PROPERTY = "$color";
71
+ export declare const COLOR_SYMBOL: unique symbol;
72
+ export declare const COLOR_TYPE: ColorTypes;
73
+ export declare const COLOR_SRGB: {
73
74
  luminanceBlue: number;
74
75
  luminanceExponent: number;
75
76
  luminanceGreen: number;
@@ -80,5 +81,5 @@ declare const COLOR_SRGB: {
80
81
  luminanceRed: number;
81
82
  luminanceThreshold: number;
82
83
  };
83
- //#endregion
84
- export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_PROPERTY, COLOR_SRGB, COLOR_TYPE };
84
+ export declare const colorSubscription: SubscriptionProperty;
85
+ //#endregion
@@ -1,3 +1,4 @@
1
+ import { SUBSCRIPTION_NAME } from "../internal/subscription.mjs";
1
2
  //#region src/color/constants.ts
2
3
  const COLOR_ALPHA = {
3
4
  fullHexShort: "f",
@@ -67,7 +68,9 @@ const COLOR_MAX = {
67
68
  hex: 255,
68
69
  percent: 100
69
70
  };
70
- const COLOR_PROPERTY = { name: "$color" };
71
+ const COLOR_NAME = "color";
72
+ const COLOR_PROPERTY = "$color";
73
+ const COLOR_SYMBOL = Symbol(COLOR_PROPERTY);
71
74
  const COLOR_TYPE = {
72
75
  all: void 0,
73
76
  hex: "hex",
@@ -102,5 +105,9 @@ const COLOR_SRGB = {
102
105
  luminanceRed: .2126,
103
106
  luminanceThreshold: .625
104
107
  };
108
+ const colorSubscription = {
109
+ key: COLOR_PROPERTY,
110
+ value: SUBSCRIPTION_NAME
111
+ };
105
112
  //#endregion
106
- export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_PROPERTY, COLOR_SRGB, COLOR_TYPE };
113
+ export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_NAME, COLOR_PROPERTY, COLOR_SRGB, COLOR_SYMBOL, COLOR_TYPE, colorSubscription };
@@ -15,6 +15,6 @@ import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.
15
15
  * @param value Original value
16
16
  * @returns _Color_ instance
17
17
  */
18
- declare function getColor(value: unknown): Color;
18
+ export declare function getColor(value: unknown): Color;
19
19
  //#endregion
20
- export { type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, type RGBAColor, type RGBColor, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
20
+ export { type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, type RGBAColor, type RGBColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
@@ -1,5 +1,5 @@
1
1
  import { Color } from "./models.mjs";
2
2
  //#region src/color/instance.d.ts
3
- declare function color(value: unknown): Color;
4
- //#endregion
5
- export { color };
3
+ declare function Color(this: any, value: unknown): void;
4
+ export declare function color(value: unknown): Color;
5
+ //#endregion