@oscarpalmer/atoms 0.78.0 → 0.80.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 (113) hide show
  1. package/dist/array/sort.cjs +5 -10
  2. package/dist/array/sort.js +5 -10
  3. package/dist/colour/base.cjs +27 -2
  4. package/dist/colour/base.js +27 -2
  5. package/dist/colour/functions.cjs +1 -1
  6. package/dist/colour/functions.js +1 -1
  7. package/dist/colour/hsl.cjs +2 -12
  8. package/dist/colour/hsl.js +2 -12
  9. package/dist/colour/index.cjs +5 -0
  10. package/dist/colour/index.js +6 -1
  11. package/dist/colour/rgb.cjs +2 -8
  12. package/dist/colour/rgb.js +2 -8
  13. package/dist/index.cjs +5 -0
  14. package/dist/index.js +5 -0
  15. package/dist/internal/array/find.cjs +6 -7
  16. package/dist/internal/array/find.js +6 -7
  17. package/dist/value/equal.cjs +4 -1
  18. package/dist/value/equal.js +4 -1
  19. package/package.json +15 -8
  20. package/src/array/chunk.ts +1 -1
  21. package/src/array/count.ts +2 -2
  22. package/src/array/exists.ts +2 -2
  23. package/src/array/filter.ts +2 -2
  24. package/src/array/find.ts +2 -2
  25. package/src/array/group-by.ts +2 -2
  26. package/src/array/index-of.ts +2 -2
  27. package/src/array/index.ts +3 -2
  28. package/src/array/insert.ts +2 -2
  29. package/src/array/models.ts +1 -1
  30. package/src/array/shuffle.ts +1 -1
  31. package/src/array/sort.ts +13 -20
  32. package/src/array/splice.ts +1 -1
  33. package/src/array/to-map.ts +2 -2
  34. package/src/array/to-record.ts +60 -60
  35. package/src/array/unique.ts +5 -5
  36. package/src/colour/base.ts +48 -12
  37. package/src/colour/functions.ts +4 -4
  38. package/src/colour/hex.ts +3 -3
  39. package/src/colour/hsl.ts +6 -18
  40. package/src/colour/index.ts +2 -1
  41. package/src/colour/is.ts +4 -7
  42. package/src/colour/rgb.ts +6 -14
  43. package/src/emitter.ts +1 -1
  44. package/src/function.ts +2 -2
  45. package/src/index.ts +16 -16
  46. package/src/internal/array/callbacks.ts +2 -2
  47. package/src/internal/array/find.ts +10 -11
  48. package/src/internal/value/handle.ts +1 -1
  49. package/src/is.ts +2 -2
  50. package/src/logger.ts +1 -1
  51. package/src/query.ts +4 -4
  52. package/src/random.ts +1 -1
  53. package/src/sized.ts +1 -1
  54. package/src/string/case.ts +1 -1
  55. package/src/string/index.ts +2 -1
  56. package/src/string/template.ts +3 -3
  57. package/src/value/clone.ts +3 -3
  58. package/src/value/compare.ts +3 -3
  59. package/src/value/diff.ts +4 -4
  60. package/src/value/equal.ts +6 -3
  61. package/src/value/get.ts +2 -2
  62. package/src/value/index.ts +2 -1
  63. package/src/value/merge.ts +2 -2
  64. package/src/value/set.ts +2 -2
  65. package/src/value/smush.ts +3 -3
  66. package/src/value/unsmush.ts +3 -3
  67. package/types/array/count.d.ts +1 -1
  68. package/types/array/exists.d.ts +1 -1
  69. package/types/array/filter.d.ts +1 -1
  70. package/types/array/find.d.ts +1 -1
  71. package/types/array/group-by.d.ts +1 -1
  72. package/types/array/index-of.d.ts +1 -1
  73. package/types/array/index.d.ts +1 -1
  74. package/types/array/insert.d.ts +1 -1
  75. package/types/array/models.d.ts +1 -1
  76. package/types/array/sort.d.ts +2 -2
  77. package/types/array/to-map.d.ts +1 -1
  78. package/types/array/to-record.d.ts +1 -1
  79. package/types/array/unique.d.ts +1 -1
  80. package/types/colour/base.d.cts +9 -1
  81. package/types/colour/base.d.ts +12 -2
  82. package/types/colour/functions.d.cts +9 -1
  83. package/types/colour/functions.d.ts +3 -3
  84. package/types/colour/hex.d.cts +9 -1
  85. package/types/colour/hex.d.ts +2 -2
  86. package/types/colour/hsl.d.cts +9 -1
  87. package/types/colour/hsl.d.ts +3 -3
  88. package/types/colour/index.d.cts +27 -1
  89. package/types/colour/index.d.ts +2 -1
  90. package/types/colour/is.d.cts +10 -2
  91. package/types/colour/is.d.ts +4 -4
  92. package/types/colour/rgb.d.cts +9 -1
  93. package/types/colour/rgb.d.ts +3 -3
  94. package/types/function.d.ts +1 -1
  95. package/types/index.d.cts +37 -9
  96. package/types/index.d.ts +16 -16
  97. package/types/internal/array/callbacks.d.ts +1 -1
  98. package/types/internal/array/find.d.ts +1 -1
  99. package/types/internal/value/handle.d.ts +1 -1
  100. package/types/is.d.ts +1 -1
  101. package/types/models.d.cts +10 -3
  102. package/types/query.d.ts +1 -1
  103. package/types/string/template.d.ts +1 -1
  104. package/types/value/get.d.cts +10 -3
  105. package/types/value/get.d.ts +1 -1
  106. package/types/value/index.d.cts +10 -3
  107. package/types/value/index.d.ts +1 -1
  108. package/types/value/merge.d.ts +1 -1
  109. package/types/value/set.d.cts +2 -1
  110. package/types/value/set.d.ts +1 -1
  111. package/types/value/smush.d.cts +10 -3
  112. package/types/value/smush.d.ts +1 -1
  113. package/types/value/unsmush.d.ts +1 -1
package/types/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- export * from '~/array/index';
2
- export * from '~/colour/index';
3
- export * from '~/emitter';
4
- export * from '~/function';
5
- export * from '~/is';
6
- export * from '~/logger';
7
- export * from '~/math';
8
- export * from '~/models';
9
- export * from '~/number';
10
- export * from '~/query';
11
- export * from '~/queue';
12
- export * from '~/random';
13
- export * from '~/sized';
14
- export * from '~/string/index';
15
- export * from '~/touch';
16
- export * from '~/value/index';
1
+ export * from './array/index';
2
+ export * from './colour/index';
3
+ export * from './emitter';
4
+ export * from './function';
5
+ export * from './is';
6
+ export * from './logger';
7
+ export * from './math';
8
+ export * from './models';
9
+ export * from './number';
10
+ export * from './query';
11
+ export * from './queue';
12
+ export * from './random';
13
+ export * from './sized';
14
+ export * from './string/index';
15
+ export * from './touch';
16
+ export * from './value/index';
@@ -1,2 +1,2 @@
1
- import type { Callbacks } from '~/array/models';
1
+ import type { Callbacks } from '../../array/models';
2
2
  export declare function getCallbacks(bool?: unknown, key?: unknown, value?: unknown): Callbacks | undefined;
@@ -1,3 +1,3 @@
1
- import type { FindType } from '~/array/models';
1
+ import type { FindType } from '../../array/models';
2
2
  export declare function findValue(type: FindType, array: unknown[], parameters: unknown[]): unknown;
3
3
  export declare function findValues(type: 'all' | 'unique', array: unknown[], parameters: unknown[]): unknown[];
@@ -1,2 +1,2 @@
1
- import type { ArrayOrPlainObject } from '~/models';
1
+ import type { ArrayOrPlainObject } from '../../models';
2
2
  export declare function handleValue(data: ArrayOrPlainObject, path: string, value: unknown, get: boolean, ignoreCase: boolean): unknown;
package/types/is.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ArrayOrPlainObject, Key, PlainObject, Primitive } from '~/models';
1
+ import type { ArrayOrPlainObject, Key, PlainObject, Primitive } from './models';
2
2
  /**
3
3
  * Is the value an array or a record?
4
4
  */
@@ -176,6 +176,7 @@ export type StringDigit =
176
176
  | '7'
177
177
  | '8'
178
178
  | '9';
179
+ type NoInfer$1<T> = T extends infer U ? U : never;
179
180
  /**
180
181
  Returns a boolean for whether the given type is `any`.
181
182
 
@@ -204,7 +205,7 @@ const anyA = get(anyObject, 'a');
204
205
  @category Type Guard
205
206
  @category Utilities
206
207
  */
207
- export type IsAny<T> = 0 extends 1 & T ? true : false;
208
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
208
209
  export type Numeric = number | bigint;
209
210
  export type Zero = 0 | 0n;
210
211
  /**
@@ -1213,8 +1214,14 @@ export type PropertyOf<
1213
1214
  ? undefined
1214
1215
  : Key extends keyof BaseType
1215
1216
  ? StrictPropertyOf<BaseType, Key, Options>
1216
- : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1217
- ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1217
+ : BaseType extends readonly unknown[]
1218
+ ? Key extends `${number}`
1219
+ ? number extends BaseType['length']
1220
+ ? Strictify<BaseType[number], Options>
1221
+ : Key extends keyof BaseType
1222
+ ? Strictify<BaseType[Key & keyof BaseType], Options>
1223
+ : unknown
1224
+ : unknown
1218
1225
  : BaseType extends {
1219
1226
  [n: number]: infer Item;
1220
1227
  length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
package/types/query.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PlainObject } from '~/models';
1
+ import type { PlainObject } from './models';
2
2
  /**
3
3
  * Convert a query string to a plain _(nested)_ object
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { PlainObject } from '~/models';
1
+ import type { PlainObject } from '../models';
2
2
  type Options = {
3
3
  /**
4
4
  * Ignore case when searching for variables?
@@ -176,6 +176,7 @@ export type StringDigit =
176
176
  | '7'
177
177
  | '8'
178
178
  | '9';
179
+ type NoInfer$1<T> = T extends infer U ? U : never;
179
180
  /**
180
181
  Returns a boolean for whether the given type is `any`.
181
182
 
@@ -204,7 +205,7 @@ const anyA = get(anyObject, 'a');
204
205
  @category Type Guard
205
206
  @category Utilities
206
207
  */
207
- export type IsAny<T> = 0 extends 1 & T ? true : false;
208
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
208
209
  export type Numeric = number | bigint;
209
210
  export type Zero = 0 | 0n;
210
211
  /**
@@ -1213,8 +1214,14 @@ export type PropertyOf<
1213
1214
  ? undefined
1214
1215
  : Key extends keyof BaseType
1215
1216
  ? StrictPropertyOf<BaseType, Key, Options>
1216
- : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1217
- ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1217
+ : BaseType extends readonly unknown[]
1218
+ ? Key extends `${number}`
1219
+ ? number extends BaseType['length']
1220
+ ? Strictify<BaseType[number], Options>
1221
+ : Key extends keyof BaseType
1222
+ ? Strictify<BaseType[Key & keyof BaseType], Options>
1223
+ : unknown
1224
+ : unknown
1218
1225
  : BaseType extends {
1219
1226
  [n: number]: infer Item;
1220
1227
  length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
@@ -1,5 +1,5 @@
1
1
  import type { ToString } from 'type-fest/source/internal/string';
2
- import type { ArrayOrPlainObject, Get, Paths } from '~/models';
2
+ import type { ArrayOrPlainObject, Get, Paths } from '../models';
3
3
  /**
4
4
  * - Get the value from an object using a known path
5
5
  * - You can retrieve a nested value by using dot notation, e.g., `foo.bar.baz`
@@ -276,6 +276,7 @@ export type StringDigit =
276
276
  | '7'
277
277
  | '8'
278
278
  | '9';
279
+ type NoInfer$1<T> = T extends infer U ? U : never;
279
280
  /**
280
281
  Returns a boolean for whether the given type is `any`.
281
282
 
@@ -304,7 +305,7 @@ const anyA = get(anyObject, 'a');
304
305
  @category Type Guard
305
306
  @category Utilities
306
307
  */
307
- export type IsAny<T> = 0 extends 1 & T ? true : false;
308
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
308
309
  export type Numeric = number | bigint;
309
310
  export type Zero = 0 | 0n;
310
311
  /**
@@ -1313,8 +1314,14 @@ export type PropertyOf<
1313
1314
  ? undefined
1314
1315
  : Key extends keyof BaseType
1315
1316
  ? StrictPropertyOf<BaseType, Key, Options>
1316
- : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1317
- ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1317
+ : BaseType extends readonly unknown[]
1318
+ ? Key extends `${number}`
1319
+ ? number extends BaseType['length']
1320
+ ? Strictify<BaseType[number], Options>
1321
+ : Key extends keyof BaseType
1322
+ ? Strictify<BaseType[Key & keyof BaseType], Options>
1323
+ : unknown
1324
+ : unknown
1318
1325
  : BaseType extends {
1319
1326
  [n: number]: infer Item;
1320
1327
  length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
@@ -1,4 +1,4 @@
1
- import type { PlainObject } from '~/models';
1
+ import type { PlainObject } from '../models';
2
2
  /**
3
3
  * Create a new object with only the specified keys
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ArrayOrPlainObject } from '~/models';
1
+ import type { ArrayOrPlainObject } from '../models';
2
2
  type MergeOptions = {
3
3
  /**
4
4
  * - Skip nullable values when merging arrays?
@@ -165,6 +165,7 @@ export type VariablePartOfArray<T extends UnknownArray> = T extends unknown
165
165
  ? U
166
166
  : []
167
167
  : never; // Should never happen
168
+ type NoInfer$1<T> = T extends infer U ? U : never;
168
169
  /**
169
170
  Returns a boolean for whether the given type is `any`.
170
171
 
@@ -193,7 +194,7 @@ const anyA = get(anyObject, 'a');
193
194
  @category Type Guard
194
195
  @category Utilities
195
196
  */
196
- export type IsAny<T> = 0 extends 1 & T ? true : false;
197
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
197
198
  export type Numeric = number | bigint;
198
199
  export type Zero = 0 | 0n;
199
200
  /**
@@ -1,4 +1,4 @@
1
- import type { ArrayOrPlainObject, Paths } from '~/models';
1
+ import type { ArrayOrPlainObject, Paths } from '../models';
2
2
  /**
3
3
  * - Set the value in an object using a known path
4
4
  * - You can set a nested value by using dot notation, e.g., `foo.bar.baz`
@@ -236,6 +236,7 @@ export type StringDigit =
236
236
  | '7'
237
237
  | '8'
238
238
  | '9';
239
+ type NoInfer$1<T> = T extends infer U ? U : never;
239
240
  /**
240
241
  Returns a boolean for whether the given type is `any`.
241
242
 
@@ -264,7 +265,7 @@ const anyA = get(anyObject, 'a');
264
265
  @category Type Guard
265
266
  @category Utilities
266
267
  */
267
- export type IsAny<T> = 0 extends 1 & T ? true : false;
268
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
268
269
  export type Numeric = number | bigint;
269
270
  export type Zero = 0 | 0n;
270
271
  /**
@@ -1273,8 +1274,14 @@ export type PropertyOf<
1273
1274
  ? undefined
1274
1275
  : Key extends keyof BaseType
1275
1276
  ? StrictPropertyOf<BaseType, Key, Options>
1276
- : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1277
- ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1277
+ : BaseType extends readonly unknown[]
1278
+ ? Key extends `${number}`
1279
+ ? number extends BaseType['length']
1280
+ ? Strictify<BaseType[number], Options>
1281
+ : Key extends keyof BaseType
1282
+ ? Strictify<BaseType[Key & keyof BaseType], Options>
1283
+ : unknown
1284
+ : unknown
1278
1285
  : BaseType extends {
1279
1286
  [n: number]: infer Item;
1280
1287
  length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
@@ -1,6 +1,6 @@
1
1
  import type { Get, Paths, Simplify } from 'type-fest';
2
2
  import type { ToString } from 'type-fest/source/internal/string';
3
- import type { PlainObject } from '~/models';
3
+ import type { PlainObject } from '../models';
4
4
  type Smushed<Value> = Simplify<{
5
5
  [Key in Paths<Value>]: Get<Value, ToString<Key>>;
6
6
  }>;
@@ -1,5 +1,5 @@
1
1
  import type { KeysOfUnion, Simplify } from 'type-fest';
2
- import type { PlainObject } from '~/models';
2
+ import type { PlainObject } from '../models';
3
3
  type Unsmushed<Value extends PlainObject> = Simplify<Omit<{
4
4
  [Key in KeysOfUnion<Value>]: Value[Key];
5
5
  }, `${string}.${string}`>>;