@oscarpalmer/atoms 0.201.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 +16 -185
  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 +18 -175
  24. package/dist/array/to-record.d.mts +18 -175
  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 +244 -584
  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 +14 -15
  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 +58 -46
  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
@@ -1,7 +1,7 @@
1
1
  import { GenericCallback } from "../models.mjs";
2
2
  import { Subscription, SubscriptionProperty } from "./subscription.mjs";
3
3
  //#region src/internal/herald.d.ts
4
- type Herald<Events extends Record<string, GenericCallback>> = {
4
+ export type Herald<Events extends Record<string, GenericCallback>> = {
5
5
  readonly events: HeraldEvents<Events>;
6
6
  /**
7
7
  * Remove all event subscribers
@@ -31,9 +31,9 @@ type Herald<Events extends Record<string, GenericCallback>> = {
31
31
  */
32
32
  subscribe<Event extends keyof Events>(event: Event, callback: Events[Event], signal?: AbortSignal): Subscription;
33
33
  };
34
- type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Key in keyof Events]: Key extends '*' ? never : (callback: Events[Key], signal?: AbortSignal) => void; };
34
+ export type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Key in keyof Events]: Key extends '*' ? never : (callback: Events[Key], signal?: AbortSignal) => void; };
35
35
  type HeraldOnCreate<Events extends Record<string, GenericCallback>> = <Event extends keyof Events>(event: Event, callback: Events[Event], subscription: Subscription) => void;
36
- type HeraldOptions<Events extends Record<string, GenericCallback>> = {
36
+ export type HeraldOptions<Events extends Record<string, GenericCallback>> = {
37
37
  names: Array<keyof Events>;
38
38
  property?: SubscriptionProperty;
39
39
  onCreate?: HeraldOnCreate<Events>;
@@ -45,27 +45,26 @@ type HeraldOptions<Events extends Record<string, GenericCallback>> = {
45
45
  * @param property Optional property for subscription identification _(defaults to `$herald`)_
46
46
  * @returns _Herald_ instance
47
47
  */
48
- declare function herald<Events extends Record<string, GenericCallback>>(options: HeraldOptions<Events>): Herald<Events>;
48
+ export declare function herald<Events extends Record<string, GenericCallback>>(options: HeraldOptions<Events>): Herald<Events>;
49
49
  /**
50
50
  * Is the value a herald?
51
51
  *
52
52
  * @param value Value to check
53
53
  * @returns `true` if the value is a herald, otherwise `false`
54
54
  */
55
- declare function isHerald<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Herald<Events>;
55
+ export declare function isHerald<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Herald<Events>;
56
56
  /**
57
57
  * Is the value events for a herald?
58
58
  *
59
59
  * @param value Value to check
60
60
  * @returns `true` if the value is events for a herald, otherwise `false`
61
61
  */
62
- declare function isHeraldEvents<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is HeraldEvents<Events>;
62
+ export declare function isHeraldEvents<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is HeraldEvents<Events>;
63
63
  /**
64
64
  * Is the value a herald subscription?
65
65
  *
66
66
  * @param value Value to check
67
67
  * @returns `true` if the value is a herald subscription, otherwise `false`
68
68
  */
69
- declare function isHeraldSubscription(value: unknown): value is Subscription;
70
- //#endregion
71
- export { Herald, HeraldEvents, HeraldOptions, herald, isHerald, isHeraldEvents, isHeraldSubscription };
69
+ export declare function isHeraldSubscription(value: unknown): value is Subscription;
70
+ //#endregion
@@ -1,11 +1,34 @@
1
1
  import { isPlainObject } from "./is.mjs";
2
2
  import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./subscription.mjs";
3
3
  //#region src/internal/herald.ts
4
- function createEvents(herald, state) {
5
- const events = {};
6
- Object.defineProperty(events, HERALD_PROPERTY, { value: HERALD_NAME_EVENTS });
7
- for (const key of state.keys) events[key] = (callback, signal) => herald.subscribe(key, callback, signal);
8
- return Object.freeze(events);
4
+ const HERALD_NAME_EVENTS = "events";
5
+ const HERALD_NAME_HERALD = "herald";
6
+ const HERALD_PROPERTY = "$herald";
7
+ function Events(herald, state) {
8
+ for (const key of state.keys) Object.defineProperty(this, key, { value: (callback, signal) => herald.subscribe(key, callback, signal) });
9
+ }
10
+ Events.prototype[HERALD_PROPERTY] = HERALD_NAME_EVENTS;
11
+ function Herald(state) {
12
+ Object.defineProperty(this, HERALD_SYMBOL, { value: {
13
+ state,
14
+ events: new Events(this, state)
15
+ } });
16
+ }
17
+ Object.defineProperties(Herald.prototype, {
18
+ [HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
19
+ clear: { value: clearHerald },
20
+ emit: { value: emitForHerald },
21
+ events: {
22
+ enumerable: true,
23
+ get() {
24
+ return this[HERALD_SYMBOL].events;
25
+ }
26
+ },
27
+ observed: { value: eventIsObserved },
28
+ subscribe: { value: subscribeToHerald }
29
+ });
30
+ function clearHerald() {
31
+ this[HERALD_SYMBOL].state.store.clear();
9
32
  }
10
33
  function createHeraldState(input) {
11
34
  const options = isPlainObject(input) ? input : {};
@@ -31,11 +54,15 @@ function createHeraldSubscriptionProperty(input) {
31
54
  value: property.value
32
55
  };
33
56
  }
34
- function emitForHerald(state, event, ...parameters) {
57
+ function emitForHerald(event, ...parameters) {
58
+ const { state } = this[HERALD_SYMBOL];
35
59
  const items = state.store.values.from.keyed?.get(event);
36
60
  if (items == null || items.size === 0) return;
37
61
  for (const [callback] of items) callback(...parameters);
38
62
  }
63
+ function eventIsObserved(event) {
64
+ return (this[HERALD_SYMBOL].state.store.items.keyed?.get(event)?.size ?? 0) > 0;
65
+ }
39
66
  /**
40
67
  * Create a _Herald_ for announcing named events
41
68
  *
@@ -44,21 +71,7 @@ function emitForHerald(state, event, ...parameters) {
44
71
  * @returns _Herald_ instance
45
72
  */
46
73
  function herald(options) {
47
- const state = createHeraldState(options);
48
- const instance = {
49
- clear: () => state.store.clear(),
50
- emit: (event, ...parameters) => emitForHerald(state, event, ...parameters),
51
- observed: (event) => (state.store.items.keyed?.get(event)?.size ?? 0) > 0,
52
- subscribe: (key, callback, signal) => subscribeToHerald(state, key, callback, signal)
53
- };
54
- Object.defineProperties(instance, {
55
- [HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
56
- events: {
57
- enumerable: true,
58
- value: createEvents(instance, state)
59
- }
60
- });
61
- return Object.freeze(instance);
74
+ return new Herald(createHeraldState(options));
62
75
  }
63
76
  /**
64
77
  * Is the value a herald?
@@ -79,7 +92,7 @@ function isHeraldEvents(value) {
79
92
  return isHeraldInstance(HERALD_NAME_EVENTS, value);
80
93
  }
81
94
  function isHeraldInstance(name, value) {
82
- return isPlainObject(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
95
+ return typeof value === "object" && value !== null && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
83
96
  }
84
97
  /**
85
98
  * Is the value a herald subscription?
@@ -90,7 +103,8 @@ function isHeraldInstance(name, value) {
90
103
  function isHeraldSubscription(value) {
91
104
  return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
92
105
  }
93
- function subscribeToHerald(state, key, callback, signal) {
106
+ function subscribeToHerald(key, callback, signal) {
107
+ const { state } = this[HERALD_SYMBOL];
94
108
  const [subscription, existing] = state.store.create({
95
109
  key,
96
110
  signal,
@@ -99,12 +113,10 @@ function subscribeToHerald(state, key, callback, signal) {
99
113
  if (!existing) state.onCreate?.(key, callback, subscription);
100
114
  return subscription;
101
115
  }
102
- const HERALD_PROPERTY = "$herald";
103
116
  const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
104
117
  const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
105
118
  const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
106
- const HERALD_NAME_EVENTS = "events";
107
- const HERALD_NAME_HERALD = "herald";
119
+ const HERALD_SYMBOL = Symbol(HERALD_PROPERTY);
108
120
  const heraldSubscription = {
109
121
  key: HERALD_PROPERTY,
110
122
  value: SUBSCRIPTION_NAME
@@ -6,14 +6,14 @@ import { ArrayOrPlainObject, Constructor, Key, PlainObject, Primitive, TypedArra
6
6
  * @param value Value to check
7
7
  * @returns `true` if the value is an array or a plain object, otherwise `false`
8
8
  */
9
- declare function isArrayOrPlainObject(value: unknown): value is ArrayOrPlainObject;
9
+ export declare function isArrayOrPlainObject(value: unknown): value is ArrayOrPlainObject;
10
10
  /**
11
11
  * Is the value a constructor function?
12
12
  *
13
13
  * @param value Value to check
14
14
  * @returns `true` if the value is a constructor function, otherwise `false`
15
15
  */
16
- declare function isConstructor(value: unknown): value is Constructor;
16
+ export declare function isConstructor(value: unknown): value is Constructor;
17
17
  /**
18
18
  * Is the value an instance of the constructor?
19
19
  *
@@ -21,28 +21,28 @@ declare function isConstructor(value: unknown): value is Constructor;
21
21
  * @param value Value to check
22
22
  * @returns `true` if the value is an instance of the constructor, otherwise `false`
23
23
  */
24
- declare function isInstanceOf<Instance>(constructor: Constructor<Instance>, value: unknown): value is Instance;
24
+ export declare function isInstanceOf<Instance>(constructor: Constructor<Instance>, value: unknown): value is Instance;
25
25
  /**
26
26
  * Is the value a _Key_?
27
27
  *
28
28
  * @param value Value to check
29
29
  * @returns `true` if the value is a _Key_ _(`number` or `string`)_, otherwise `false`
30
30
  */
31
- declare function isKey(value: unknown): value is Key;
31
+ export declare function isKey(value: unknown): value is Key;
32
32
  /**
33
33
  * Is the value not an array or a plain object?
34
34
  *
35
35
  * @param value Value to check
36
36
  * @returns `true` if the value is not an array or a plain object, otherwise `false`
37
37
  */
38
- declare function isNonArrayOrPlainObject<Value>(value: Value): value is Exclude<Value, ArrayOrPlainObject>;
38
+ export declare function isNonArrayOrPlainObject<Value>(value: Value): value is Exclude<Value, ArrayOrPlainObject>;
39
39
  /**
40
40
  * Is the value not a constructor function?
41
41
  *
42
42
  * @param value Value to check
43
43
  * @returns `true` if the value is not a constructor function, otherwise `false`
44
44
  */
45
- declare function isNonConstructor<Value>(value: Value): value is Exclude<Value, Constructor>;
45
+ export declare function isNonConstructor<Value>(value: Value): value is Exclude<Value, Constructor>;
46
46
  /**
47
47
  * Is the value not an instance of the constructor?
48
48
  *
@@ -50,83 +50,82 @@ declare function isNonConstructor<Value>(value: Value): value is Exclude<Value,
50
50
  * @param value Value to check
51
51
  * @returns `true` if the value is not an instance of the constructor, otherwise `false`
52
52
  */
53
- declare function isNonInstanceOf<Instance, Value>(constructor: Constructor<Instance>, value: Value): value is Exclude<Value, Instance>;
53
+ export declare function isNonInstanceOf<Instance, Value>(constructor: Constructor<Instance>, value: Value): value is Exclude<Value, Instance>;
54
54
  /**
55
55
  * Is the value not a _Key_?
56
56
  *
57
57
  * @param value Value to check
58
58
  * @returns `true` if the value is not a _Key_ _(`number` or `string`)_, otherwise `false`
59
59
  */
60
- declare function isNonKey<Value>(value: Value): value is Exclude<Value, Key>;
60
+ export declare function isNonKey<Value>(value: Value): value is Exclude<Value, Key>;
61
61
  /**
62
62
  * Is the value not a number?
63
63
  *
64
64
  * @param value Value to check
65
65
  * @returns `true` if the value is not a `number`, otherwise `false`
66
66
  */
67
- declare function isNonNumber<Value>(value: Value): value is Exclude<Value, number>;
67
+ export declare function isNonNumber<Value>(value: Value): value is Exclude<Value, number>;
68
68
  /**
69
69
  * Is the value not a plain object?
70
70
  *
71
71
  * @param value Value to check
72
72
  * @returns `true` if the value is not a plain object, otherwise `false`
73
73
  */
74
- declare function isNonPlainObject<Value>(value: Value): value is Exclude<Value, PlainObject>;
74
+ export declare function isNonPlainObject<Value>(value: Value): value is Exclude<Value, PlainObject>;
75
75
  /**
76
76
  * Is the value not a primitive value?
77
77
  *
78
78
  * @param value Value to check
79
79
  * @returns `true` if the value is not a primitive value, otherwise `false`
80
80
  */
81
- declare function isNonPrimitive<Value>(value: Value): value is Exclude<Value, Primitive>;
81
+ export declare function isNonPrimitive<Value>(value: Value): value is Exclude<Value, Primitive>;
82
82
  /**
83
83
  * Is the value not a template strings array?
84
84
  *
85
85
  * @param value Value to check
86
86
  * @returns `true` if the value is not a `TemplateStringsArray`, otherwise `false`
87
87
  */
88
- declare function isNonTemplateStringsArray<Value>(value: Value): value is Exclude<Value, TemplateStringsArray>;
88
+ export declare function isNonTemplateStringsArray<Value>(value: Value): value is Exclude<Value, TemplateStringsArray>;
89
89
  /**
90
90
  * Is the value not a typed array?
91
91
  *
92
92
  * @param value Value to check
93
93
  * @returns `true` if the value is not a typed array, otherwise `false`
94
94
  */
95
- declare function isNonTypedArray<Value>(value: Value): value is Exclude<Value, TypedArray>;
95
+ export declare function isNonTypedArray<Value>(value: Value): value is Exclude<Value, TypedArray>;
96
96
  /**
97
97
  * Is the value a number?
98
98
  *
99
99
  * @param value Value to check
100
100
  * @returns `true` if the value is a `number`, otherwise `false`
101
101
  */
102
- declare function isNumber(value: unknown): value is number;
102
+ export declare function isNumber(value: unknown): value is number;
103
103
  /**
104
104
  * Is the value a plain object?
105
105
  *
106
106
  * @param value Value to check
107
107
  * @returns `true` if the value is a plain object, otherwise `false`
108
108
  */
109
- declare function isPlainObject(value: unknown): value is PlainObject;
109
+ export declare function isPlainObject(value: unknown): value is PlainObject;
110
110
  /**
111
111
  * Is the value a primitive value?
112
112
  *
113
113
  * @param value Value to check
114
114
  * @returns `true` if the value is a primitive value, otherwise `false`
115
115
  */
116
- declare function isPrimitive(value: unknown): value is Primitive;
116
+ export declare function isPrimitive(value: unknown): value is Primitive;
117
117
  /**
118
118
  * Is the value a template strings array?
119
119
  *
120
120
  * @param value Value to check
121
121
  * @returns `true` if the value is a `TemplateStringsArray`, otherwise `false`
122
122
  */
123
- declare function isTemplateStringsArray(value: unknown): value is TemplateStringsArray;
123
+ export declare function isTemplateStringsArray(value: unknown): value is TemplateStringsArray;
124
124
  /**
125
125
  * Is the value a typed array?
126
126
  *
127
127
  * @param value Value to check
128
128
  * @returns `true` if the value is a typed array, otherwise `false`
129
129
  */
130
- declare function isTypedArray(value: unknown): value is TypedArray;
131
- //#endregion
132
- export { isArrayOrPlainObject, isConstructor, isInstanceOf, isKey, isNonArrayOrPlainObject, isNonConstructor, isNonInstanceOf, isNonKey, isNonNumber, isNonPlainObject, isNonPrimitive, isNonTemplateStringsArray, isNonTypedArray, isNumber, isPlainObject, isPrimitive, isTemplateStringsArray, isTypedArray };
130
+ export declare function isTypedArray(value: unknown): value is TypedArray;
131
+ //#endregion
@@ -7,11 +7,11 @@ type Aggregation = {
7
7
  items?: Record<number, unknown[]>;
8
8
  value: number;
9
9
  };
10
- type AggregationType = 'average' | 'max' | 'min' | 'sum';
10
+ export type AggregationType = 'average' | 'max' | 'min' | 'sum';
11
11
  type NonAverageAggregationType = 'max' | 'min' | 'sum';
12
- declare function aggregate(type: AggregationType, array: unknown[], key: unknown, first?: unknown): Aggregation;
13
- declare function getAggregateCallback(key: unknown): Function | undefined;
14
- declare function getAggregated(type: NonAverageAggregationType, array: unknown[], key?: unknown, first?: unknown): unknown;
12
+ export declare function aggregate(type: AggregationType, array: unknown[], key: unknown, first?: unknown): Aggregation;
13
+ export declare function getAggregateCallback(key: unknown): Function | undefined;
14
+ export declare function getAggregated(type: NonAverageAggregationType, array: unknown[], key?: unknown, first?: unknown): unknown;
15
15
  /**
16
16
  * Get the maximum value from a list of items
17
17
  *
@@ -30,7 +30,7 @@ declare function getAggregated(type: NonAverageAggregationType, array: unknown[]
30
30
  * @param first Return only the first item with the maximum value
31
31
  * @returns Item with the maximum value, or `undefined` if no maximum can be found
32
32
  */
33
- declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
33
+ export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
34
34
  /**
35
35
  * Get the maximum value from a list of items
36
36
  *
@@ -49,7 +49,7 @@ declare function max<Item>(items: Item[], callback: (item: Item, index: number,
49
49
  * @param first Return only the first item with the maximum value
50
50
  * @returns Item with the maximum value, or `undefined` if no maximum can be found
51
51
  */
52
- declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
52
+ export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
53
53
  /**
54
54
  * Get the maximum value from a list of items
55
55
  *
@@ -67,7 +67,7 @@ declare function max<Item extends PlainObject>(items: Item[], key: keyof Numeric
67
67
  * @param callback Callback to get an item's value
68
68
  * @returns Items with the maximum value
69
69
  */
70
- declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
70
+ export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
71
71
  /**
72
72
  * Get the maximum value from a list of items
73
73
  *
@@ -85,7 +85,7 @@ declare function max<Item>(items: Item[], callback: (item: Item, index: number,
85
85
  * @param key Key to use for value
86
86
  * @returns Items with the maximum value
87
87
  */
88
- declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
88
+ export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
89
89
  /**
90
90
  * Get the maximum value from a list of numbers
91
91
  *
@@ -98,10 +98,9 @@ declare function max<Item extends PlainObject>(items: Item[], key: keyof Numeric
98
98
  * @param values List of numbers
99
99
  * @returns Maximum value, or `Number.NaN` if no maximum can be found
100
100
  */
101
- declare function max(values: number[]): number;
102
- declare const AGGREGATION_AVERAGE: AggregationType;
103
- declare const AGGREGATION_MAX = "max";
104
- declare const AGGREGATION_MIN = "min";
105
- declare const AGGREGATION_SUM = "sum";
106
- //#endregion
107
- export { AGGREGATION_AVERAGE, AGGREGATION_MAX, AGGREGATION_MIN, AGGREGATION_SUM, AggregationType, aggregate, getAggregateCallback, getAggregated, max };
101
+ export declare function max(values: number[]): number;
102
+ export declare const AGGREGATION_AVERAGE: AggregationType;
103
+ export declare const AGGREGATION_MAX = "max";
104
+ export declare const AGGREGATION_MIN = "min";
105
+ export declare const AGGREGATION_SUM = "sum";
106
+ //#endregion
@@ -6,7 +6,6 @@
6
6
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
7
7
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8
8
  */
9
- declare function round(value: number, decimals?: number): number;
10
- declare function roundNumber(callback: (value: number) => number, value: number, decimals?: number): number;
11
- //#endregion
12
- export { round, roundNumber };
9
+ export declare function round(value: number, decimals?: number): number;
10
+ export declare function roundNumber(callback: (value: number) => number, value: number, decimals?: number): number;
11
+ //#endregion
@@ -7,7 +7,7 @@
7
7
  * @param maximum Maximum value
8
8
  * @returns `true` if the value is between the minimum and maximum, otherwise `false`
9
9
  */
10
- declare function between(value: number, minimum: number, maximum: number): boolean;
10
+ export declare function between(value: number, minimum: number, maximum: number): boolean;
11
11
  /**
12
12
  * Clamp a number between a minimum and maximum value
13
13
  *
@@ -23,7 +23,7 @@ declare function between(value: number, minimum: number, maximum: number): boole
23
23
  * clamp(10, 0, 5, true); // => 0
24
24
  * ```
25
25
  */
26
- declare function clamp(value: number, minimum: number, maximum: number, loop?: boolean): number;
26
+ export declare function clamp(value: number, minimum: number, maximum: number, loop?: boolean): number;
27
27
  /**
28
28
  * Get the number value from an unknown value
29
29
  *
@@ -32,6 +32,5 @@ declare function clamp(value: number, minimum: number, maximum: number, loop?: b
32
32
  * @param value Original value
33
33
  * @returns Original value as a number, or `Number.NaN` if the value is unable to be parsed
34
34
  */
35
- declare function getNumber(value: unknown): number;
36
- //#endregion
37
- export { between, clamp, getNumber };
35
+ export declare function getNumber(value: unknown): number;
36
+ //#endregion
@@ -6,7 +6,7 @@
6
6
  * @param maximum Maximum value
7
7
  * @returns Random floating-point number
8
8
  */
9
- declare function getRandomFloatingNumber(minimum?: number, maximum?: number): number;
9
+ export declare function getRandomFloatingNumber(minimum?: number, maximum?: number): number;
10
10
  /**
11
11
  * Get a random integer
12
12
  *
@@ -14,6 +14,5 @@ declare function getRandomFloatingNumber(minimum?: number, maximum?: number): nu
14
14
  * @param maximum Maximum value
15
15
  * @returns Random integer
16
16
  */
17
- declare function getRandomInteger(minimum?: number, maximum?: number): number;
18
- //#endregion
19
- export { getRandomFloatingNumber, getRandomInteger };
17
+ export declare function getRandomInteger(minimum?: number, maximum?: number): number;
18
+ //#endregion
@@ -7,64 +7,80 @@ import { Err, ExtendedErr, Ok, Result } from "./models.mjs";
7
7
  * @param original Original error
8
8
  * @returns Error result
9
9
  */
10
- declare function error<E>(value: E, original: Error): ExtendedErr<E>;
10
+ export declare function error<E>(value: E, original: Error): ExtendedErr<E>;
11
11
  /**
12
12
  * Creates an error result
13
13
  *
14
14
  * @param value Error value
15
15
  * @returns Error result
16
16
  */
17
- declare function error<E>(value: E): Err<E>;
18
- declare function getError<E>(value: E, original?: Error): Err<E> | ExtendedErr<E>;
17
+ export declare function error<E>(value: E): Err<E>;
18
+ export declare namespace error {
19
+ var is: typeof isError;
20
+ }
21
+ export declare function getError<E>(value: E, original?: Error): Err<E> | ExtendedErr<E>;
19
22
  /**
20
23
  * Is the _Result_ an extended error?
21
24
  *
25
+ * _Available as `isError` and `error.is`_
26
+ *
22
27
  * @param result _Result_ to check
23
28
  * @returns `true` if the _Result_ is an extended error, otherwise `false`
24
29
  */
25
- declare function isError<Value, E = Error>(result: ExtendedErr<E> | Result<Value, E>, extended: true): result is ExtendedErr<E>;
30
+ export declare function isError<Value, E = Error>(result: ExtendedErr<E> | Result<Value, E>, extended: true): result is ExtendedErr<E>;
26
31
  /**
27
32
  * Is the _Result_ an error?
28
33
  *
34
+ * _Available as `isError` and `error.is`_
35
+ *
29
36
  * @param result _Result_ to check
30
37
  * @returns `true` if the _Result_ is an error, otherwise `false`
31
38
  */
32
- declare function isError<Value, E = Error>(result: Result<Value, E>): result is Err<E>;
39
+ export declare function isError<Value, E = Error>(result: Result<Value, E>): result is Err<E>;
33
40
  /**
34
41
  * Is the value an error?
35
42
  *
43
+ * _Available as `isError` and `error.is`_
44
+ *
36
45
  * @param value Value to check
37
46
  * @returns `true` if the value is an error, otherwise `false`
38
47
  */
39
- declare function isError(value: unknown): value is Err<unknown> | ExtendedErr<unknown>;
48
+ export declare function isError(value: unknown): value is Err<unknown> | ExtendedErr<unknown>;
40
49
  /**
41
50
  * Is the _Result_ ok?
42
51
  *
52
+ * _Available as `isOk` and `ok.is`_
53
+ *
43
54
  * @param value _Result_ to check
44
55
  * @returns `true` if the _Result_ is ok, otherwise `false`
45
56
  */
46
- declare function isOk<Value, E = Error>(value: Result<Value, E>): value is Ok<Value>;
57
+ export declare function isOk<Value, E = Error>(value: Result<Value, E>): value is Ok<Value>;
47
58
  /**
48
59
  * Is the value ok?
49
60
  *
61
+ * _Available as `isOk` and `ok.is`_
62
+ *
50
63
  * @param value Value to check
51
64
  * @returns `true` if the value is ok, otherwise `false`
52
65
  */
53
- declare function isOk(value: unknown): value is Ok<unknown>;
66
+ export declare function isOk(value: unknown): value is Ok<unknown>;
54
67
  /**
55
68
  * Is the value a _Result_?
56
69
  *
57
70
  * @param value Value to check
58
71
  * @returns `true` if the value is a _Result_, otherwise `false`
59
72
  */
60
- declare function isResult(value: unknown): value is ExtendedErr<unknown> | Result<unknown, unknown>;
73
+ export declare function isResult(value: unknown): value is ExtendedErr<unknown> | Result<unknown, unknown>;
61
74
  /**
62
75
  * Creates an ok result
63
76
  *
64
77
  * @param value Value
65
78
  * @returns Ok result
66
79
  */
67
- declare function ok<Value>(value: Value): Ok<Value>;
80
+ export declare function ok<Value>(value: Value): Ok<Value>;
81
+ export declare namespace ok {
82
+ var is: typeof isOk;
83
+ }
68
84
  /**
69
85
  * Gets the value of an ok result _(or a default value)_
70
86
  *
@@ -72,7 +88,7 @@ declare function ok<Value>(value: Value): Ok<Value>;
72
88
  * @param defaultValue Default value
73
89
  * @returns Value of the _Result_ _(or the default value)_
74
90
  */
75
- declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue: Value): Value;
91
+ export declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue: Value): Value;
76
92
  /**
77
93
  * Gets the value of an ok result _(or a default value)_
78
94
  *
@@ -80,6 +96,5 @@ declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue:
80
96
  * @param defaultValue Default value
81
97
  * @returns Value of the _Result_ _(or the default value)_
82
98
  */
83
- declare function unwrap(value: unknown, defaultValue: unknown): unknown;
84
- //#endregion
85
- export { error, getError, isError, isOk, isResult, ok, unwrap };
99
+ export declare function unwrap(value: unknown, defaultValue: unknown): unknown;
100
+ //#endregion
@@ -47,5 +47,9 @@ function unwrap(value, defaultValue) {
47
47
  }
48
48
  const RESULT_PROPERTY_ERROR = "error";
49
49
  const RESULT_PROPERTY_VALUE = "value";
50
+ error.is = isError;
51
+ ok.is = isOk;
52
+ Object.defineProperty(error, "is", { value: isError });
53
+ Object.defineProperty(ok, "is", { value: isOk });
50
54
  //#endregion
51
55
  export { error, getError, isError, isOk, isResult, ok, unwrap };
@@ -3,39 +3,39 @@ import { GenericCallback } from "../../models.mjs";
3
3
  /**
4
4
  * An unknown result
5
5
  */
6
- type AnyResult<Value, E> = Err<E> | ExtendedErr<E> | Ok<Value>;
6
+ export type AnyResult<Value, E> = Err<E> | ExtendedErr<E> | Ok<Value>;
7
7
  /**
8
8
  * An error result
9
9
  */
10
- type Err<Error> = {
10
+ export type Err<Error> = {
11
11
  ok: false;
12
12
  error: Error;
13
13
  };
14
14
  /**
15
15
  * An extended error result
16
16
  */
17
- type ExtendedErr<E> = Err<E> & {
17
+ export type ExtendedErr<E> = Err<E> & {
18
18
  original: Error;
19
19
  };
20
20
  /**
21
21
  * An extended, unknown result
22
22
  */
23
- type ExtendedResult<Value, E> = ExtendedErr<E> | Ok<Value>;
23
+ export type ExtendedResult<Value, E> = ExtendedErr<E> | Ok<Value>;
24
24
  /**
25
25
  * A successful result
26
26
  */
27
- type Ok<Value> = {
27
+ export type Ok<Value> = {
28
28
  ok: true;
29
29
  value: Value;
30
30
  };
31
31
  /**
32
32
  * An unknown result
33
33
  */
34
- type Result<Value, E = Error> = Err<E> | Ok<Value>;
34
+ export type Result<Value, E = Error> = Err<E> | Ok<Value>;
35
35
  /**
36
36
  * Match callbacks for a result
37
37
  */
38
- type ResultMatch<Value, Returned, E = Error> = {
38
+ export type ResultMatch<Value, Returned, E = Error> = {
39
39
  /**
40
40
  * Callback for error result
41
41
  *
@@ -59,6 +59,5 @@ type UnwrapResult<Original extends Result<unknown, unknown>> = Original extends
59
59
  /**
60
60
  * Unwrap any value
61
61
  */
62
- type UnwrapValue<Original> = Original extends GenericCallback ? ReturnType<Original> extends Result<unknown, unknown> ? UnwrapResult<ReturnType<Original>> : ReturnType<Original> : Original extends Result<unknown, unknown> ? UnwrapResult<Original> : Original extends Promise<infer Value> ? Awaited<Value> : Original;
63
- //#endregion
64
- export { AnyResult, Err, ExtendedErr, ExtendedResult, Ok, Result, ResultMatch, UnwrapValue };
62
+ export type UnwrapValue<Original> = Original extends GenericCallback ? ReturnType<Original> extends Result<unknown, unknown> ? UnwrapResult<ReturnType<Original>> : ReturnType<Original> : Original extends Result<unknown, unknown> ? UnwrapResult<Original> : Original extends Promise<infer Value> ? Awaited<Value> : Original;
63
+ //#endregion
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Behavior is similar to a _LRU_ cache, where the least recently used entries are removed
6
6
  */
7
- declare class SizedMap<SizedKey = unknown, SizedValue = unknown> extends Map<SizedKey, SizedValue> {
7
+ export declare class SizedMap<SizedKey = unknown, SizedValue = unknown> extends Map<SizedKey, SizedValue> {
8
8
  #private;
9
9
  /**
10
10
  * Is the _Map_ full?
@@ -45,5 +45,4 @@ declare class SizedMap<SizedKey = unknown, SizedValue = unknown> extends Map<Siz
45
45
  */
46
46
  set(key: SizedKey, value: SizedValue): this;
47
47
  }
48
- //#endregion
49
- export { SizedMap };
48
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/internal/sized/misc.d.ts
2
- declare function getSizedMaximum(first?: unknown, second?: unknown): number;
3
- //#endregion
4
- export { getSizedMaximum };
2
+ export declare function getSizedMaximum(first?: unknown, second?: unknown): number;
3
+ //#endregion