@oscarpalmer/atoms 0.193.0 → 0.193.1

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 (126) hide show
  1. package/package.json +3 -4
  2. package/src/array/difference.ts +0 -73
  3. package/src/array/exists.ts +0 -93
  4. package/src/array/filter.ts +0 -182
  5. package/src/array/find.ts +0 -183
  6. package/src/array/first.ts +0 -196
  7. package/src/array/flatten.ts +0 -20
  8. package/src/array/from.ts +0 -129
  9. package/src/array/get.ts +0 -131
  10. package/src/array/group-by.ts +0 -369
  11. package/src/array/index.ts +0 -26
  12. package/src/array/insert.ts +0 -52
  13. package/src/array/intersection.ts +0 -72
  14. package/src/array/last.ts +0 -194
  15. package/src/array/match.ts +0 -436
  16. package/src/array/move.ts +0 -315
  17. package/src/array/partition.ts +0 -91
  18. package/src/array/push.ts +0 -23
  19. package/src/array/reverse.ts +0 -33
  20. package/src/array/select.ts +0 -260
  21. package/src/array/single.ts +0 -93
  22. package/src/array/slice.ts +0 -335
  23. package/src/array/sort.ts +0 -607
  24. package/src/array/splice.ts +0 -106
  25. package/src/array/swap.ts +0 -322
  26. package/src/array/to-map.ts +0 -371
  27. package/src/array/to-record.ts +0 -351
  28. package/src/array/to-set.ts +0 -80
  29. package/src/array/toggle.ts +0 -79
  30. package/src/array/union.ts +0 -72
  31. package/src/array/unique.ts +0 -67
  32. package/src/array/update.ts +0 -75
  33. package/src/beacon.ts +0 -378
  34. package/src/color/constants.ts +0 -137
  35. package/src/color/index.ts +0 -83
  36. package/src/color/instance.ts +0 -162
  37. package/src/color/misc/alpha.ts +0 -56
  38. package/src/color/misc/format.ts +0 -29
  39. package/src/color/misc/get.ts +0 -210
  40. package/src/color/misc/is.ts +0 -221
  41. package/src/color/misc/state.ts +0 -243
  42. package/src/color/models.ts +0 -389
  43. package/src/color/space/hex.ts +0 -184
  44. package/src/color/space/hsl.ts +0 -174
  45. package/src/color/space/hwb.ts +0 -153
  46. package/src/color/space/rgb.ts +0 -240
  47. package/src/function/assert.ts +0 -174
  48. package/src/function/index.ts +0 -2
  49. package/src/function/limit.ts +0 -83
  50. package/src/function/memoize.ts +0 -202
  51. package/src/function/once.ts +0 -200
  52. package/src/function/retry.ts +0 -175
  53. package/src/function/work.ts +0 -1007
  54. package/src/herald.ts +0 -216
  55. package/src/index.ts +0 -68
  56. package/src/internal/array/callbacks.ts +0 -46
  57. package/src/internal/array/chunk.ts +0 -51
  58. package/src/internal/array/compact.ts +0 -56
  59. package/src/internal/array/find.ts +0 -200
  60. package/src/internal/array/group.ts +0 -42
  61. package/src/internal/array/index-of.ts +0 -182
  62. package/src/internal/array/insert.ts +0 -80
  63. package/src/internal/array/overlap.ts +0 -35
  64. package/src/internal/array/sets.ts +0 -74
  65. package/src/internal/array/shuffle.ts +0 -33
  66. package/src/internal/array/update.ts +0 -52
  67. package/src/internal/function/misc.ts +0 -8
  68. package/src/internal/function/timer.ts +0 -168
  69. package/src/internal/is.ts +0 -244
  70. package/src/internal/math/aggregate.ts +0 -164
  71. package/src/internal/math/misc.ts +0 -28
  72. package/src/internal/number.ts +0 -129
  73. package/src/internal/random.ts +0 -49
  74. package/src/internal/result.ts +0 -92
  75. package/src/internal/sized.ts +0 -25
  76. package/src/internal/string.ts +0 -128
  77. package/src/internal/subscription.ts +0 -264
  78. package/src/internal/value/compare.ts +0 -170
  79. package/src/internal/value/equal.ts +0 -465
  80. package/src/internal/value/get.ts +0 -57
  81. package/src/internal/value/handlers.ts +0 -95
  82. package/src/internal/value/has.ts +0 -118
  83. package/src/internal/value/misc.ts +0 -125
  84. package/src/internal/value/partial.ts +0 -46
  85. package/src/internal/value/set.ts +0 -132
  86. package/src/is.ts +0 -182
  87. package/src/logger.ts +0 -230
  88. package/src/math.ts +0 -281
  89. package/src/models.ts +0 -286
  90. package/src/number.ts +0 -1
  91. package/src/promise/delay.ts +0 -62
  92. package/src/promise/helpers.ts +0 -96
  93. package/src/promise/index.ts +0 -300
  94. package/src/promise/misc.ts +0 -96
  95. package/src/promise/models.ts +0 -195
  96. package/src/promise/timed.ts +0 -91
  97. package/src/query.ts +0 -147
  98. package/src/queue.ts +0 -814
  99. package/src/random.ts +0 -125
  100. package/src/result/index.ts +0 -105
  101. package/src/result/match.ts +0 -124
  102. package/src/result/misc.ts +0 -129
  103. package/src/result/models.ts +0 -83
  104. package/src/result/work/flow.ts +0 -488
  105. package/src/result/work/pipe.ts +0 -496
  106. package/src/sized/map.ts +0 -110
  107. package/src/sized/set.ts +0 -107
  108. package/src/string/case.ts +0 -236
  109. package/src/string/fuzzy.ts +0 -444
  110. package/src/string/index.ts +0 -199
  111. package/src/string/match.ts +0 -80
  112. package/src/string/normalize.ts +0 -205
  113. package/src/string/template.ts +0 -161
  114. package/src/value/clone.ts +0 -319
  115. package/src/value/collection.ts +0 -63
  116. package/src/value/diff.ts +0 -232
  117. package/src/value/freeze.ts +0 -322
  118. package/src/value/handle.ts +0 -3
  119. package/src/value/index.ts +0 -5
  120. package/src/value/merge.ts +0 -278
  121. package/src/value/omit.ts +0 -20
  122. package/src/value/pick.ts +0 -20
  123. package/src/value/shake.ts +0 -45
  124. package/src/value/smush.ts +0 -89
  125. package/src/value/transform.ts +0 -153
  126. package/src/value/unsmush.ts +0 -84
@@ -1,196 +0,0 @@
1
- import {findAbsoluteValueOrDefault} from '../internal/array/find';
2
- import type {PlainObject} from '../models';
3
-
4
- // #region Functions
5
-
6
- /**
7
- * Get the first item matching the given value
8
- *
9
- * @param array Array to search in
10
- * @param callback Callback to get an item's value for matching
11
- * @param value Value to match against
12
- * @returns First item that matches the value, or `undefined` if no match is found
13
- *
14
- * @example
15
- * ```typescript
16
- * first(
17
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
18
- * item => item.value,
19
- * 10,
20
- * ); // => {id: 1, value: 10}
21
- * ```
22
- */
23
- export function first<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(
24
- array: Item[],
25
- callback: Callback,
26
- value: ReturnType<Callback>,
27
- ): Item | undefined;
28
-
29
- /**
30
- * Get the first item matching the given value by key
31
- *
32
- * @param array Array to search in
33
- * @param key Key to get an item's value for matching
34
- * @param value Value to match against
35
- * @returns First item that matches the value, or `undefined` if no match is found
36
- *
37
- * @example
38
- * ```typescript
39
- * first(
40
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
41
- * 'value',
42
- * 10,
43
- * ); // => {id: 1, value: 10}
44
- * ```
45
- */
46
- export function first<Item extends PlainObject, ItemKey extends keyof Item>(
47
- array: Item[],
48
- key: ItemKey,
49
- value: Item[ItemKey],
50
- ): Item | undefined;
51
-
52
- /**
53
- * Get the first item matching the filter
54
- *
55
- * @param array Array to search in
56
- * @param filter Filter callback to match items
57
- * @returns First item that matches the filter, or `undefined` if no match is found
58
- *
59
- * @example
60
- * ```typescript
61
- * first(
62
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
63
- * item => item.value === 10,
64
- * ); // => {id: 1, value: 10}
65
- * ```
66
- */
67
- export function first<Item>(
68
- array: Item[],
69
- filter: (item: Item, index: number, array: Item[]) => boolean,
70
- ): Item | undefined;
71
-
72
- /**
73
- * Get the first item from an array
74
- *
75
- * @param array Array to get from
76
- * @returns First item from the array, or `undefined` if the array is empty
77
- *
78
- * @example
79
- * ```typescript
80
- * first(
81
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
82
- * ); // => {id: 1, value: 10}
83
- * ```
84
- */
85
- export function first<Item>(array: Item[]): Item | undefined;
86
-
87
- export function first(array: unknown[], ...parameters: unknown[]): unknown {
88
- return findAbsoluteValueOrDefault(array, parameters, undefined, false, false);
89
- }
90
-
91
- first.default = firstOrDefault;
92
-
93
- /**
94
- * Get the first item matching the given value, or a default value if no match is found
95
- *
96
- * _Available as `firstOrDefault` and `first.default`_
97
- *
98
- * @param array Array to search in
99
- * @param defaultValue Default value to return if no match is found
100
- * @param callback Callback to get an item's value for matching
101
- * @param value Value to match against
102
- * @returns First item that matches the value, or the default value if no match is found
103
- *
104
- * @example
105
- * ```typescript
106
- * firstOrDefault(
107
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
108
- * {id: -1, value: 30},
109
- * item => item.value,
110
- * 30,
111
- * ); // => {id: -1, value: 30}
112
- * ```
113
- */
114
- export function firstOrDefault<
115
- Item,
116
- Callback extends (item: Item, index: number, array: Item[]) => unknown,
117
- >(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
118
-
119
- /**
120
- * Get the first item matching the given value by key, or a default value if no match is found
121
- *
122
- * _Available as `firstOrDefault` and `first.default`_
123
- *
124
- * @param array Array to search in
125
- * @param defaultValue Default value to return if no match is found
126
- * @param key Key to get an item's value for matching
127
- * @param value Value to match against
128
- * @returns First item that matches the value, or the default value if no match is found
129
- *
130
- * @example
131
- * ```typescript
132
- * firstOrDefault(
133
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
134
- * {id: -1, value: 30},
135
- * 'value',
136
- * 30,
137
- * ); // => {id: -1, value: 30}
138
- * ```
139
- */
140
- export function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(
141
- array: Item[],
142
- defaultValue: Item,
143
- key: ItemKey,
144
- value: Item[ItemKey],
145
- ): Item;
146
-
147
- /**
148
- * Get the first item matching the filter, or a default value if no match is found
149
- *
150
- * _Available as `firstOrDefault` and `first.default`_
151
- *
152
- * @param array Array to search in
153
- * @param defaultValue Default value to return if no match is found
154
- * @param filter Filter callback to match items
155
- * @returns First item that matches the filter, or the default value if no match is found
156
- *
157
- * @example
158
- * ```typescript
159
- * firstOrDefault(
160
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
161
- * {id: -1, value: 30},
162
- * item => item.value === 30,
163
- * ); // => {id: -1, value: 30}
164
- * ```
165
- */
166
- export function firstOrDefault<Item>(
167
- array: Item[],
168
- defaultValue: Item,
169
- filter: (item: Item, index: number, array: Item[]) => boolean,
170
- ): Item;
171
-
172
- /**
173
- * Get the first item from an array, or a default value if the array is empty
174
- *
175
- * _Available as `firstOrDefault` and `first.default`_
176
- *
177
- * @param array Array to get from
178
- * @param defaultValue Default value to return if the array is empty
179
- * @returns First item from the array, or the default value if the array is empty
180
- *
181
- * @example
182
- * ```typescript
183
- * firstOrDefault([], {id: -1, value: 30}); // => {id: -1, value: 30}
184
- * ```
185
- */
186
- export function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
187
-
188
- export function firstOrDefault(
189
- array: unknown[],
190
- defaultValue: unknown,
191
- ...parameters: unknown[]
192
- ): unknown {
193
- return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, false);
194
- }
195
-
196
- // #endregion
@@ -1,20 +0,0 @@
1
- import type {NestedArray} from '../models';
2
-
3
- // #region Functions
4
-
5
- /**
6
- * Flatten an array _(using native `flat` and maximum depth)_
7
- *
8
- * @param array Array to flatten
9
- * @returns Flattened array
10
- *
11
- * @example
12
- * ```typescript
13
- * flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
14
- * ```
15
- */
16
- export function flatten<Item>(array: Item[]): NestedArray<Item>[] {
17
- return (Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : []) as NestedArray<Item>[];
18
- }
19
-
20
- // #endregion
package/src/array/from.ts DELETED
@@ -1,129 +0,0 @@
1
- // #region Functions
2
-
3
- /**
4
- * Get an array with a specified length, filled with indices
5
- *
6
- * @param length Length of the array
7
- * @returns Array of indices
8
- *
9
- * @example
10
- * ```typescript
11
- * range(5); // => [0, 1, 2, 3, 4]
12
- * ```
13
- */
14
- export function range(length: number): number[];
15
-
16
- /**
17
- * Get an array of numbers in a specified range
18
- *
19
- * @param start Starting number _(inclusive)_
20
- * @param end Ending number _(exclusive)_
21
- * @returns Array of numbers in range
22
- *
23
- * @example
24
- * ```typescript
25
- * range(2, 5); // => [2, 3, 4]
26
- * ```
27
- */
28
- export function range(start: number, end: number): number[];
29
-
30
- /**
31
- * Get an array of numbers in a specified range with a specified step
32
- *
33
- * @param start Starting number _(inclusive)_
34
- * @param end Ending number _(exclusive)_
35
- * @param step Step between numbers
36
- * @returns Array of numbers in range
37
- *
38
- * @example
39
- * ```typescript
40
- * range(0, 10, 2); // => [0, 2, 4, 6, 8]
41
- * ```
42
- */
43
- export function range(start: number, end: number, step: number): number[];
44
-
45
- export function range(first: number, second?: number, third?: number): number[] {
46
- const start = typeof second === 'number' ? first : 0;
47
- const end = typeof second === 'number' ? second : first;
48
- const step = typeof third === 'number' ? third : 1;
49
-
50
- const values: number[] = [];
51
-
52
- if (step === 0) {
53
- return values;
54
- }
55
-
56
- if (step > 0) {
57
- for (let i = start; i < end; i += step) {
58
- values.push(i);
59
- }
60
- } else {
61
- for (let i = start; i > end; i += step) {
62
- values.push(i);
63
- }
64
- }
65
-
66
- return values;
67
- }
68
-
69
- /**
70
- * Get an array with a specified length, filled with indices
71
- *
72
- * @param length Length of the array
73
- * @returns Array of indices
74
- *
75
- * @example
76
- * ```typescript
77
- * times(5); // => [0, 1, 2, 3, 4]
78
- * ```
79
- */
80
- export function times(length: number): number[];
81
-
82
- /**
83
- * Get an array with a specified length, filled by values from a callback
84
- *
85
- * @param length Length of the array
86
- * @param callback Callback function to generate values
87
- * @returns Array of values generated by the callback
88
- *
89
- * @example
90
- * ```typescript
91
- * times(5, index => index * 2); // => [0, 2, 4, 6, 8]
92
- * ```
93
- */
94
- export function times<Callback extends (index: number) => unknown>(
95
- length: number,
96
- callback: Callback,
97
- ): ReturnType<Callback>[];
98
-
99
- /**
100
- * Get an array with a specified length, filled with a specified value
101
- *
102
- * @param length Length of the array
103
- * @param value Value to fill the array with
104
- * @returns Array filled with the specified value
105
- *
106
- * @example
107
- * ```typescript
108
- * times(5, 'a'); // => ['a', 'a', 'a', 'a', 'a']
109
- * ```
110
- */
111
- export function times<Value>(length: number, value: Value): Value[];
112
-
113
- export function times(length: number, value?: unknown): unknown[] {
114
- if (typeof length !== 'number' || length <= 0) {
115
- return [];
116
- }
117
-
118
- const isFunction = typeof value === 'function';
119
-
120
- const values: unknown[] = [];
121
-
122
- for (let index = 0; index < length; index += 1) {
123
- values.push(isFunction ? (value as (index: number) => unknown)(index) : (value ?? index));
124
- }
125
-
126
- return values;
127
- }
128
-
129
- // #endregion
package/src/array/get.ts DELETED
@@ -1,131 +0,0 @@
1
- import {isNonPlainObject} from '../internal/is';
2
- import type {NumericalKeys, PlainObject} from '../models';
3
-
4
- // #region Functions
5
-
6
- /**
7
- * Get an array from an object, where only values with numerical keys will be included
8
- *
9
- * @param value Object to convert to an array
10
- * @returns Array holding the values of the object's numerical keys
11
- *
12
- * @example
13
- * ```typescript
14
- * getArray({0: 'a', 1: 'b', 2: 'c', d: 'd'}, true); // => ['a', 'b', 'c']
15
- * getArray({a: 'a', b: 'b', c: 'c', d: 'd'}, true); // => []
16
- * ```
17
- */
18
- export function getArray<Value extends PlainObject>(
19
- value: Value,
20
- indiced: true,
21
- ): Value[NumericalKeys<Value>][];
22
-
23
- /**
24
- * Get an array from a map
25
- *
26
- * @param value Map to convert to an array
27
- * @returns Array holding the entries of the map
28
- *
29
- * @example
30
- * ```typescript
31
- * getArray(
32
- * new Map([['a', 1], ['b', 2], ['c', 3]]),
33
- * ); // => [['a', 1], ['b', 2], ['c', 3]]
34
- * ```
35
- */
36
- export function getArray<Key, Value>(map: Map<Key, Value>): [Key, Value][];
37
-
38
- /**
39
- * Get an array from an object
40
- *
41
- * @param value Object to convert to an array
42
- * @returns Array holding the values of the object
43
- *
44
- * @example
45
- * ```typescript
46
- * getArray({0: 'a', 1: 'b', 2: 'c', d: 'd'}); // => ['a', 'b', 'c', 'd']
47
- * getArray({a: 'a', b: 'b', c: 'c', d: 'd'}); // => ['a', 'b', 'c', 'd']
48
- * ```
49
- */
50
- export function getArray<Value extends PlainObject>(
51
- value: Value,
52
- ): [keyof Value, Value[keyof Value]][];
53
-
54
- /**
55
- * Get an array from a set
56
- *
57
- * @param value Set to convert to an array
58
- * @returns Array holding the values of the set
59
- *
60
- * @example
61
- * ```typescript
62
- * getArray(new Set([123, 456, 789])); // => [123, 456, 789]
63
- * ```
64
- */
65
- export function getArray<Value>(set: Set<Value>): Value[];
66
-
67
- /**
68
- * Get an array from a value
69
- *
70
- * @param value Original array
71
- * @returns Original array
72
- *
73
- * @example
74
- * ```typescript
75
- * getArray([123]); // => [123]
76
- * ```
77
- */
78
- export function getArray<Item>(value: Item[]): Item[];
79
-
80
- /**
81
- * Get an array from an unknown value
82
- *
83
- * @param value Value to convert to an array
84
- * @returns Array of value
85
- *
86
- * @example
87
- * ```typescript
88
- * getArray(123); // => [123]
89
- * ```
90
- */
91
- export function getArray<Value>(value: Value): Value[];
92
-
93
- export function getArray(value: unknown, indiced?: unknown): unknown[] {
94
- if (Array.isArray(value)) {
95
- return value;
96
- }
97
-
98
- if (value instanceof Map) {
99
- return [...value.entries()];
100
- }
101
-
102
- if (value instanceof Set) {
103
- return [...value.values()];
104
- }
105
-
106
- if (isNonPlainObject(value)) {
107
- return [value];
108
- }
109
-
110
- if (indiced !== true) {
111
- return Object.entries(value);
112
- }
113
-
114
- const keys = Object.keys(value);
115
- const {length} = keys;
116
-
117
- const array: unknown[] = [];
118
-
119
- for (let index = 0; index < length; index += 1) {
120
- const key = keys[index];
121
- const asNumber = Number.parseInt(key, 10);
122
-
123
- if (!Number.isNaN(asNumber)) {
124
- array[asNumber] = (value as Record<string, unknown>)[key];
125
- }
126
- }
127
-
128
- return array;
129
- }
130
-
131
- // #endregion