@oscarpalmer/atoms 0.192.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 (130) hide show
  1. package/dist/index.d.mts +25 -23
  2. package/dist/index.mjs +30 -31
  3. package/dist/queue.d.mts +25 -23
  4. package/dist/queue.mjs +27 -28
  5. package/package.json +3 -4
  6. package/src/array/difference.ts +0 -73
  7. package/src/array/exists.ts +0 -93
  8. package/src/array/filter.ts +0 -182
  9. package/src/array/find.ts +0 -183
  10. package/src/array/first.ts +0 -196
  11. package/src/array/flatten.ts +0 -20
  12. package/src/array/from.ts +0 -129
  13. package/src/array/get.ts +0 -131
  14. package/src/array/group-by.ts +0 -369
  15. package/src/array/index.ts +0 -26
  16. package/src/array/insert.ts +0 -52
  17. package/src/array/intersection.ts +0 -72
  18. package/src/array/last.ts +0 -194
  19. package/src/array/match.ts +0 -436
  20. package/src/array/move.ts +0 -315
  21. package/src/array/partition.ts +0 -91
  22. package/src/array/push.ts +0 -23
  23. package/src/array/reverse.ts +0 -33
  24. package/src/array/select.ts +0 -260
  25. package/src/array/single.ts +0 -93
  26. package/src/array/slice.ts +0 -335
  27. package/src/array/sort.ts +0 -607
  28. package/src/array/splice.ts +0 -106
  29. package/src/array/swap.ts +0 -322
  30. package/src/array/to-map.ts +0 -371
  31. package/src/array/to-record.ts +0 -351
  32. package/src/array/to-set.ts +0 -80
  33. package/src/array/toggle.ts +0 -79
  34. package/src/array/union.ts +0 -72
  35. package/src/array/unique.ts +0 -67
  36. package/src/array/update.ts +0 -75
  37. package/src/beacon.ts +0 -378
  38. package/src/color/constants.ts +0 -137
  39. package/src/color/index.ts +0 -83
  40. package/src/color/instance.ts +0 -162
  41. package/src/color/misc/alpha.ts +0 -56
  42. package/src/color/misc/format.ts +0 -29
  43. package/src/color/misc/get.ts +0 -210
  44. package/src/color/misc/is.ts +0 -221
  45. package/src/color/misc/state.ts +0 -243
  46. package/src/color/models.ts +0 -389
  47. package/src/color/space/hex.ts +0 -184
  48. package/src/color/space/hsl.ts +0 -174
  49. package/src/color/space/hwb.ts +0 -153
  50. package/src/color/space/rgb.ts +0 -240
  51. package/src/function/assert.ts +0 -174
  52. package/src/function/index.ts +0 -2
  53. package/src/function/limit.ts +0 -83
  54. package/src/function/memoize.ts +0 -202
  55. package/src/function/once.ts +0 -200
  56. package/src/function/retry.ts +0 -175
  57. package/src/function/work.ts +0 -1007
  58. package/src/herald.ts +0 -216
  59. package/src/index.ts +0 -68
  60. package/src/internal/array/callbacks.ts +0 -46
  61. package/src/internal/array/chunk.ts +0 -51
  62. package/src/internal/array/compact.ts +0 -56
  63. package/src/internal/array/find.ts +0 -200
  64. package/src/internal/array/group.ts +0 -42
  65. package/src/internal/array/index-of.ts +0 -182
  66. package/src/internal/array/insert.ts +0 -80
  67. package/src/internal/array/overlap.ts +0 -35
  68. package/src/internal/array/sets.ts +0 -74
  69. package/src/internal/array/shuffle.ts +0 -33
  70. package/src/internal/array/update.ts +0 -52
  71. package/src/internal/function/misc.ts +0 -8
  72. package/src/internal/function/timer.ts +0 -168
  73. package/src/internal/is.ts +0 -244
  74. package/src/internal/math/aggregate.ts +0 -164
  75. package/src/internal/math/misc.ts +0 -28
  76. package/src/internal/number.ts +0 -129
  77. package/src/internal/random.ts +0 -49
  78. package/src/internal/result.ts +0 -92
  79. package/src/internal/sized.ts +0 -25
  80. package/src/internal/string.ts +0 -128
  81. package/src/internal/subscription.ts +0 -264
  82. package/src/internal/value/compare.ts +0 -170
  83. package/src/internal/value/equal.ts +0 -465
  84. package/src/internal/value/get.ts +0 -57
  85. package/src/internal/value/handlers.ts +0 -95
  86. package/src/internal/value/has.ts +0 -118
  87. package/src/internal/value/misc.ts +0 -125
  88. package/src/internal/value/partial.ts +0 -46
  89. package/src/internal/value/set.ts +0 -132
  90. package/src/is.ts +0 -182
  91. package/src/logger.ts +0 -230
  92. package/src/math.ts +0 -281
  93. package/src/models.ts +0 -286
  94. package/src/number.ts +0 -1
  95. package/src/promise/delay.ts +0 -62
  96. package/src/promise/helpers.ts +0 -96
  97. package/src/promise/index.ts +0 -300
  98. package/src/promise/misc.ts +0 -96
  99. package/src/promise/models.ts +0 -195
  100. package/src/promise/timed.ts +0 -91
  101. package/src/query.ts +0 -147
  102. package/src/queue.ts +0 -814
  103. package/src/random.ts +0 -125
  104. package/src/result/index.ts +0 -105
  105. package/src/result/match.ts +0 -124
  106. package/src/result/misc.ts +0 -129
  107. package/src/result/models.ts +0 -83
  108. package/src/result/work/flow.ts +0 -488
  109. package/src/result/work/pipe.ts +0 -496
  110. package/src/sized/map.ts +0 -110
  111. package/src/sized/set.ts +0 -107
  112. package/src/string/case.ts +0 -236
  113. package/src/string/fuzzy.ts +0 -444
  114. package/src/string/index.ts +0 -199
  115. package/src/string/match.ts +0 -80
  116. package/src/string/normalize.ts +0 -205
  117. package/src/string/template.ts +0 -161
  118. package/src/value/clone.ts +0 -319
  119. package/src/value/collection.ts +0 -63
  120. package/src/value/diff.ts +0 -232
  121. package/src/value/freeze.ts +0 -322
  122. package/src/value/handle.ts +0 -3
  123. package/src/value/index.ts +0 -5
  124. package/src/value/merge.ts +0 -278
  125. package/src/value/omit.ts +0 -20
  126. package/src/value/pick.ts +0 -20
  127. package/src/value/shake.ts +0 -45
  128. package/src/value/smush.ts +0 -89
  129. package/src/value/transform.ts +0 -153
  130. package/src/value/unsmush.ts +0 -84
@@ -1,89 +0,0 @@
1
- import {isArrayOrPlainObject} from '../internal/is';
2
- import {join} from '../internal/string';
3
- import type {
4
- ArrayOrPlainObject,
5
- NestedKeys,
6
- NestedValue,
7
- PlainObject,
8
- Simplify,
9
- ToString,
10
- } from '../models';
11
-
12
- // #region Types
13
-
14
- /**
15
- * A smushed object, with all nested objects flattened into a single level, using dot notation keys
16
- */
17
- export type Smushed<Value extends PlainObject> = Simplify<{
18
- [NestedKey in NestedKeys<Value>]: NestedValue<Value, ToString<NestedKey>>;
19
- }>;
20
-
21
- // #endregion
22
-
23
- // #region Functions
24
-
25
- function flattenObject(
26
- value: ArrayOrPlainObject,
27
- depth: number,
28
- smushed: WeakMap<WeakKey, PlainObject>,
29
- prefix?: string,
30
- ): PlainObject {
31
- if (depth >= MAX_DEPTH) {
32
- return {};
33
- }
34
-
35
- if (smushed.has(value)) {
36
- return smushed.get(value) as never;
37
- }
38
-
39
- const keys = Object.keys(value);
40
- const {length} = keys;
41
- const flattened = {} as Record<string, unknown>;
42
-
43
- for (let index = 0; index < length; index += 1) {
44
- const key = keys[index];
45
- const val = value[key as never];
46
-
47
- if (isArrayOrPlainObject(val)) {
48
- const prefixedKey = join([prefix, key], '.');
49
-
50
- flattened[prefixedKey] = Array.isArray(val) ? val.slice() : {...val};
51
-
52
- const nested = flattenObject(val, depth + 1, smushed, prefixedKey);
53
- const nestedKeys = Object.keys(nested);
54
- const nestedLength = nestedKeys.length;
55
-
56
- for (let nestedIndex = 0; nestedIndex < nestedLength; nestedIndex += 1) {
57
- const nestedKey = nestedKeys[nestedIndex];
58
-
59
- flattened[nestedKey] = nested[nestedKey];
60
- }
61
- } else {
62
- flattened[join([prefix, key], '.')] = val;
63
- }
64
- }
65
-
66
- smushed.set(value, flattened);
67
-
68
- return flattened as never;
69
- }
70
-
71
- /**
72
- * Smush an object into a flat object that uses dot notation keys
73
- *
74
- * @param value Object to smush
75
- * @returns Smushed object with dot notation keys
76
- */
77
- export function smush<Value extends PlainObject>(value: Value): Smushed<Value> {
78
- return typeof value === 'object' && value !== null
79
- ? (flattenObject(value, 0, new WeakMap()) as never)
80
- : ({} as never);
81
- }
82
-
83
- // #endregion
84
-
85
- // #region Variables
86
-
87
- const MAX_DEPTH = 100;
88
-
89
- // #endregion
@@ -1,153 +0,0 @@
1
- import {isNonPlainObject} from '../internal/is';
2
- import type {GenericCallback, PlainObject} from '../models';
3
-
4
- // #region Types
5
-
6
- /**
7
- * A callback transform an object's properties
8
- */
9
- type TransformCallback<Value extends PlainObject, Key extends keyof Value> = (
10
- key: Key,
11
- value: Value[Key],
12
- ) => Value[Key];
13
-
14
- /**
15
- * A collection of keyed callbacks to transform an object's properties
16
- */
17
- type TransformCallbacks<Value extends PlainObject> = Partial<{
18
- [Key in keyof Value]: (value: Value[Key]) => Value[Key];
19
- }>;
20
-
21
- /**
22
- * A transformer function for an object, with predefined callbacks for transforming its properties
23
- */
24
- export type Transformer<Value extends PlainObject> = {
25
- (value: Value): Value;
26
- };
27
-
28
- // #endregion
29
-
30
- // #region Functions
31
-
32
- function getTransformer<Value extends PlainObject, Key extends keyof Value>(
33
- input: unknown,
34
- ): TransformCallback<Value, Key> | TransformCallbacks<Value> | undefined {
35
- if (typeof input === 'function') {
36
- return input as GenericCallback;
37
- }
38
-
39
- if (isNonPlainObject(input)) {
40
- return;
41
- }
42
-
43
- const keys = Object.keys(input) as Key[];
44
- const {length} = keys;
45
-
46
- const transformer: Partial<TransformCallbacks<Value>> = {};
47
-
48
- for (let index = 0; index < length; index += 1) {
49
- const key = keys[index];
50
- const value = input[key];
51
-
52
- if (typeof value === 'function') {
53
- transformer[key] = value;
54
- }
55
- }
56
-
57
- if (Object.keys(transformer).length > 0) {
58
- return transformer;
59
- }
60
- }
61
-
62
- /**
63
- * Initialize a transformer for an object with a transformer function
64
- *
65
- * _Available as `initializeTransformer` and `transform.initialize`_
66
- *
67
- * @param transform Transformer function
68
- * @returns Transformer
69
- */
70
- export function initializeTransformer<Value extends PlainObject>(
71
- transform: TransformCallback<Value, keyof Value>,
72
- ): Transformer<Value>;
73
-
74
- /**
75
- * Initialize a transformer for an object with transformer functions
76
- *
77
- * _Available as `initializeTransformer` and `transform.initialize`_
78
- *
79
- * @param transformers Keyed transformer functions
80
- * @returns Transformer
81
- */
82
- export function initializeTransformer<Value extends PlainObject>(
83
- transformers: TransformCallbacks<Value>,
84
- ): Transformer<Value>;
85
-
86
- export function initializeTransformer<Value extends PlainObject>(
87
- transform: unknown,
88
- ): Transformer<Value> {
89
- const transformer = getTransformer<Value, keyof Value>(transform);
90
-
91
- return value => transformValue(value, transformer);
92
- }
93
-
94
- /**
95
- * Transform and objects properties using a transformer function
96
- *
97
- * @param value Object to transform
98
- * @param transform Transformer function
99
- * @returns Transformed object
100
- */
101
- export function transform<Value extends PlainObject, Key extends keyof Value>(
102
- value: Value,
103
- transform: TransformCallback<Value, Key>,
104
- ): Value;
105
-
106
- /**
107
- * Transform and objects properties using a transformer object
108
- *
109
- * @param value Object to transform
110
- * @param transformers Keyed transformer functions
111
- * @returns Transformed object
112
- */
113
- export function transform<Value extends PlainObject>(
114
- value: Value,
115
- transformers: TransformCallbacks<Value>,
116
- ): Value;
117
-
118
- export function transform<Value extends PlainObject>(value: Value, transform: unknown): Value {
119
- return transformValue(value, getTransformer(transform));
120
- }
121
-
122
- transform.initialize = initializeTransformer;
123
-
124
- function transformValue<Value extends PlainObject, Key extends keyof Value>(
125
- value: Value,
126
- transformer?: TransformCallback<Value, Key> | TransformCallbacks<Value>,
127
- ): Value {
128
- if (isNonPlainObject(value)) {
129
- return {} as Value;
130
- }
131
-
132
- if (transformer == null) {
133
- return value;
134
- }
135
-
136
- const keys = Object.keys(value) as Key[];
137
- const {length} = keys;
138
-
139
- for (let index = 0; index < length; index += 1) {
140
- const key = keys[index];
141
- const val = value[key];
142
-
143
- if (typeof transformer === 'function') {
144
- value[key] = transformer(key, val) as Value[Key];
145
- } else {
146
- value[key] = (transformer[key]?.(val) ?? val) as Value[Key];
147
- }
148
- }
149
-
150
- return value;
151
- }
152
-
153
- // #endregion
@@ -1,84 +0,0 @@
1
- import {isArrayOrPlainObject} from '../internal/is';
2
- import {setValue} from '../internal/value/set';
3
- import type {PlainObject, Simplify, UnionToIntersection} from '../models';
4
-
5
- // #region Types
6
-
7
- /**
8
- * Thanks, type-fest!
9
- */
10
- type KeysOfUnion<ObjectType> = keyof UnionToIntersection<
11
- ObjectType extends unknown ? Record<keyof ObjectType, never> : never
12
- >;
13
-
14
- type OrderedKey = {
15
- order: number;
16
- value: string;
17
- };
18
-
19
- /**
20
- * An unsmushed object, with all dot notation keys turned into nested keys
21
- */
22
- export type Unsmushed<Value extends PlainObject> = Simplify<
23
- Omit<
24
- {
25
- [UnionKey in KeysOfUnion<Value>]: Value[UnionKey];
26
- },
27
- `${string}.${string}`
28
- >
29
- >;
30
-
31
- // #endregion
32
-
33
- // #region Functions
34
-
35
- function getKeys(value: PlainObject): OrderedKey[] {
36
- const keys = Object.keys(value);
37
- const {length} = keys;
38
-
39
- const orderedKeys: OrderedKey[] = [];
40
-
41
- for (let index = 0; index < length; index += 1) {
42
- const key = keys[index];
43
-
44
- orderedKeys.push({
45
- order: key.split('.').length,
46
- value: key,
47
- });
48
- }
49
-
50
- return orderedKeys.sort((first, second) => first.order - second.order);
51
- }
52
-
53
- /**
54
- * Unsmush a smushed object _(turning dot notation keys into nested keys)_
55
- *
56
- * @param value Object to unsmush
57
- * @returns Unsmushed object with nested keys
58
- */
59
- export function unsmush<Value extends PlainObject>(value: Value): Unsmushed<Value> {
60
- if (typeof value !== 'object' || value === null) {
61
- return {} as never;
62
- }
63
-
64
- const keys = getKeys(value);
65
- const {length} = keys;
66
- const unsmushed: PlainObject = {};
67
-
68
- for (let index = 0; index < length; index += 1) {
69
- const key = keys[index].value;
70
- const val = value[key];
71
-
72
- let next = val;
73
-
74
- if (isArrayOrPlainObject(val)) {
75
- next = Array.isArray(val) ? val.slice() : {...val};
76
- }
77
-
78
- setValue(unsmushed, key, next);
79
- }
80
-
81
- return unsmushed as never;
82
- }
83
-
84
- // #endregion