@oscarpalmer/atoms 0.77.0 → 0.77.2
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.
- package/dist/js/array/chunk.cjs +1 -1
- package/dist/js/array/chunk.js +1 -1
- package/dist/js/value/equal.cjs +4 -1
- package/dist/js/value/equal.js +4 -1
- package/package.json +1 -1
- package/src/js/array/chunk.ts +1 -1
- package/src/js/array/count.ts +6 -6
- package/src/js/array/exists.ts +6 -6
- package/src/js/array/filter.ts +6 -6
- package/src/js/array/find.ts +6 -6
- package/src/js/array/group-by.ts +67 -55
- package/src/js/array/index-of.ts +6 -6
- package/src/js/array/sort.ts +20 -0
- package/src/js/array/to-map.ts +55 -47
- package/src/js/array/to-record.ts +61 -57
- package/src/js/array/unique.ts +6 -6
- package/src/js/internal/value/handle.ts +5 -5
- package/src/js/value/clone.ts +3 -1
- package/src/js/value/equal.ts +4 -1
- package/src/js/value/get.ts +9 -9
- package/src/js/value/set.ts +10 -11
- package/types/array/count.d.cts +34 -2
- package/types/array/count.d.ts +3 -3
- package/types/array/exists.d.cts +34 -2
- package/types/array/exists.d.ts +3 -3
- package/types/array/filter.d.cts +34 -2
- package/types/array/filter.d.ts +3 -3
- package/types/array/find.d.cts +34 -2
- package/types/array/find.d.ts +3 -3
- package/types/array/group-by.d.cts +44 -12
- package/types/array/group-by.d.ts +14 -14
- package/types/array/index-of.d.cts +34 -2
- package/types/array/index-of.d.ts +3 -3
- package/types/array/index.d.cts +88 -46
- package/types/array/sort.d.cts +42 -0
- package/types/array/sort.d.ts +11 -1
- package/types/array/to-map.d.cts +42 -10
- package/types/array/to-map.d.ts +13 -13
- package/types/array/to-record.d.cts +44 -12
- package/types/array/to-record.d.ts +13 -13
- package/types/array/unique.d.cts +34 -2
- package/types/array/unique.d.ts +3 -3
- package/types/index.d.cts +1034 -317
- package/types/internal/value/handle.d.cts +27 -2
- package/types/internal/value/handle.d.ts +2 -2
- package/types/models.d.cts +467 -210
- package/types/value/clone.d.cts +1 -1
- package/types/value/clone.d.ts +1 -1
- package/types/value/get.d.cts +470 -211
- package/types/value/get.d.ts +3 -3
- package/types/value/index.d.cts +515 -224
- package/types/value/set.d.cts +357 -170
- package/types/value/set.d.ts +3 -3
- package/types/value/smush.d.cts +463 -209
|
@@ -1,7 +1,39 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
Represents an object with `unknown` value. You probably want this instead of `{}`.
|
|
5
|
+
|
|
6
|
+
Use case: You have an object whose keys and values are unknown to you.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {UnknownRecord} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
function toJson(object: UnknownRecord) {
|
|
13
|
+
return JSON.stringify(object);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toJson({hello: 'world'});
|
|
17
|
+
//=> '{"hello":"world"}'
|
|
18
|
+
|
|
19
|
+
function isObject(value: unknown): value is UnknownRecord {
|
|
20
|
+
return typeof value === 'object' && value !== null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
isObject({hello: 'world'});
|
|
24
|
+
//=> true
|
|
25
|
+
|
|
26
|
+
isObject('hello');
|
|
27
|
+
//=> false
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
@category Type
|
|
31
|
+
@category Object
|
|
32
|
+
*/
|
|
33
|
+
export type UnknownRecord = Record<PropertyKey, unknown>;
|
|
3
34
|
export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
|
|
4
35
|
export type Key = number | string;
|
|
36
|
+
export type PlainObject = UnknownRecord;
|
|
5
37
|
/**
|
|
6
38
|
* Create a record from an array of items _(using their indices as keys)_
|
|
7
39
|
*/
|
|
@@ -9,50 +41,50 @@ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
|
9
41
|
/**
|
|
10
42
|
* Create a record from an array of items using a specific key
|
|
11
43
|
*/
|
|
12
|
-
export declare function toRecord<Item,
|
|
44
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Record<KeyedValue<Item, ItemKey>, Item>;
|
|
13
45
|
/**
|
|
14
46
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
15
47
|
*/
|
|
16
|
-
export declare function toRecord<Item,
|
|
48
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, arrays: true): Record<KeyedValue<Item, ItemKey>, Item[]>;
|
|
17
49
|
/**
|
|
18
50
|
* Create a record from an array of items using a specific key
|
|
19
51
|
*/
|
|
20
|
-
export declare function toRecord<Item,
|
|
52
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey): Record<ReturnType<ItemKey>, Item>;
|
|
21
53
|
/**
|
|
22
54
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
23
55
|
*/
|
|
24
|
-
export declare function toRecord<Item,
|
|
56
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey, arrays: true): Record<ReturnType<ItemKey>, Item[]>;
|
|
25
57
|
/**
|
|
26
58
|
* Create a record from an array of items using a specific key and value
|
|
27
59
|
*/
|
|
28
|
-
export declare function toRecord<Item,
|
|
60
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
|
|
29
61
|
/**
|
|
30
62
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
31
63
|
*/
|
|
32
|
-
export declare function toRecord<Item,
|
|
64
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
|
|
33
65
|
/**
|
|
34
66
|
* Create a record from an array of items using a specific key and value
|
|
35
67
|
*/
|
|
36
|
-
export declare function toRecord<Item,
|
|
68
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
|
|
37
69
|
/**
|
|
38
70
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
39
71
|
*/
|
|
40
|
-
export declare function toRecord<Item,
|
|
72
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
|
|
41
73
|
/**
|
|
42
74
|
* Create a record from an array of items using a specific key and value
|
|
43
75
|
*/
|
|
44
|
-
export declare function toRecord<Item,
|
|
76
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
|
|
45
77
|
/**
|
|
46
78
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
47
79
|
*/
|
|
48
|
-
export declare function toRecord<Item,
|
|
80
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
|
|
49
81
|
/**
|
|
50
82
|
* Create a record from an array of items using a specific key and value
|
|
51
83
|
*/
|
|
52
|
-
export declare function toRecord<Item,
|
|
84
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue): Record<ReturnType<ItemKey>, ReturnType<ItemValue>>;
|
|
53
85
|
/**
|
|
54
86
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
55
87
|
*/
|
|
56
|
-
export declare function toRecord<Item,
|
|
88
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<ReturnType<ItemKey>, Array<ReturnType<ItemValue>>>;
|
|
57
89
|
|
|
58
90
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KeyedValue,
|
|
1
|
+
import type { Key, KeyedValue, PlainObject } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Create a record from an array of items _(using their indices as keys)_
|
|
4
4
|
*/
|
|
@@ -6,48 +6,48 @@ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a record from an array of items using a specific key
|
|
8
8
|
*/
|
|
9
|
-
export declare function toRecord<Item,
|
|
9
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Record<KeyedValue<Item, ItemKey>, Item>;
|
|
10
10
|
/**
|
|
11
11
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
12
12
|
*/
|
|
13
|
-
export declare function toRecord<Item,
|
|
13
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, arrays: true): Record<KeyedValue<Item, ItemKey>, Item[]>;
|
|
14
14
|
/**
|
|
15
15
|
* Create a record from an array of items using a specific key
|
|
16
16
|
*/
|
|
17
|
-
export declare function toRecord<Item,
|
|
17
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey): Record<ReturnType<ItemKey>, Item>;
|
|
18
18
|
/**
|
|
19
19
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
20
20
|
*/
|
|
21
|
-
export declare function toRecord<Item,
|
|
21
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey, arrays: true): Record<ReturnType<ItemKey>, Item[]>;
|
|
22
22
|
/**
|
|
23
23
|
* Create a record from an array of items using a specific key and value
|
|
24
24
|
*/
|
|
25
|
-
export declare function toRecord<Item,
|
|
25
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
|
|
26
26
|
/**
|
|
27
27
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
28
28
|
*/
|
|
29
|
-
export declare function toRecord<Item,
|
|
29
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
|
|
30
30
|
/**
|
|
31
31
|
* Create a record from an array of items using a specific key and value
|
|
32
32
|
*/
|
|
33
|
-
export declare function toRecord<Item,
|
|
33
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
|
|
34
34
|
/**
|
|
35
35
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
36
36
|
*/
|
|
37
|
-
export declare function toRecord<Item,
|
|
37
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
|
|
38
38
|
/**
|
|
39
39
|
* Create a record from an array of items using a specific key and value
|
|
40
40
|
*/
|
|
41
|
-
export declare function toRecord<Item,
|
|
41
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
|
|
42
42
|
/**
|
|
43
43
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
44
44
|
*/
|
|
45
|
-
export declare function toRecord<Item,
|
|
45
|
+
export declare function toRecord<Item extends PlainObject, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
|
|
46
46
|
/**
|
|
47
47
|
* Create a record from an array of items using a specific key and value
|
|
48
48
|
*/
|
|
49
|
-
export declare function toRecord<Item,
|
|
49
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue): Record<ReturnType<ItemKey>, ReturnType<ItemValue>>;
|
|
50
50
|
/**
|
|
51
51
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
52
52
|
*/
|
|
53
|
-
export declare function toRecord<Item,
|
|
53
|
+
export declare function toRecord<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ItemValue, arrays: true): Record<ReturnType<ItemKey>, Array<ReturnType<ItemValue>>>;
|
package/types/array/unique.d.cts
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
Represents an object with `unknown` value. You probably want this instead of `{}`.
|
|
5
|
+
|
|
6
|
+
Use case: You have an object whose keys and values are unknown to you.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {UnknownRecord} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
function toJson(object: UnknownRecord) {
|
|
13
|
+
return JSON.stringify(object);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toJson({hello: 'world'});
|
|
17
|
+
//=> '{"hello":"world"}'
|
|
18
|
+
|
|
19
|
+
function isObject(value: unknown): value is UnknownRecord {
|
|
20
|
+
return typeof value === 'object' && value !== null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
isObject({hello: 'world'});
|
|
24
|
+
//=> true
|
|
25
|
+
|
|
26
|
+
isObject('hello');
|
|
27
|
+
//=> false
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
@category Type
|
|
31
|
+
@category Object
|
|
32
|
+
*/
|
|
33
|
+
export type UnknownRecord = Record<PropertyKey, unknown>;
|
|
3
34
|
export type Key = number | string;
|
|
35
|
+
export type PlainObject = UnknownRecord;
|
|
4
36
|
/**
|
|
5
37
|
* Get an array of unique items
|
|
6
38
|
*/
|
|
@@ -9,11 +41,11 @@ export declare function unique<Item>(array: Item[]): Item[];
|
|
|
9
41
|
* - Get an array of unique items
|
|
10
42
|
* - Use `key` to find a comparison value for an item
|
|
11
43
|
*/
|
|
12
|
-
export declare function unique<Item,
|
|
44
|
+
export declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
|
|
13
45
|
/**
|
|
14
46
|
* - Get an array of unique items
|
|
15
47
|
* - Use `key` to find a comparison value for an item
|
|
16
48
|
*/
|
|
17
|
-
export declare function unique<Item,
|
|
49
|
+
export declare function unique<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey): Item[];
|
|
18
50
|
|
|
19
51
|
export {};
|
package/types/array/unique.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Key
|
|
1
|
+
import type { Key, PlainObject } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Get an array of unique items
|
|
4
4
|
*/
|
|
@@ -7,9 +7,9 @@ export declare function unique<Item>(array: Item[]): Item[];
|
|
|
7
7
|
* - Get an array of unique items
|
|
8
8
|
* - Use `key` to find a comparison value for an item
|
|
9
9
|
*/
|
|
10
|
-
export declare function unique<Item,
|
|
10
|
+
export declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
|
|
11
11
|
/**
|
|
12
12
|
* - Get an array of unique items
|
|
13
13
|
* - Use `key` to find a comparison value for an item
|
|
14
14
|
*/
|
|
15
|
-
export declare function unique<Item,
|
|
15
|
+
export declare function unique<Item, ItemKey extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: ItemKey): Item[];
|