@ts-fns/stdlib 0.1.0 → 0.2.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.
- package/dist/array/index.cjs +230 -33
- package/dist/array/index.cjs.map +1 -1
- package/dist/array/index.d.cts +434 -32
- package/dist/array/index.d.cts.map +1 -1
- package/dist/array/index.d.mts +434 -32
- package/dist/array/index.d.mts.map +1 -1
- package/dist/array/index.mjs +216 -18
- package/dist/array/index.mjs.map +1 -1
- package/dist/function/index.cjs +4 -2
- package/dist/function/index.d.cts +128 -13
- package/dist/function/index.d.cts.map +1 -1
- package/dist/function/index.d.mts +128 -13
- package/dist/function/index.d.mts.map +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/{function-DnI2v0p3.mjs → function-CYHPhQCQ.mjs} +84 -6
- package/dist/function-CYHPhQCQ.mjs.map +1 -0
- package/dist/{function-CB82a2GS.cjs → function-DYPifnmg.cjs} +95 -5
- package/dist/function-DYPifnmg.cjs.map +1 -0
- package/dist/{get-yrs1Kqho.cjs → get-1kqkxPFX.cjs} +20 -8
- package/dist/get-1kqkxPFX.cjs.map +1 -0
- package/dist/{get-CWL_cu6G.mjs → get-Dv6ejLZg.mjs} +21 -3
- package/dist/get-Dv6ejLZg.mjs.map +1 -0
- package/dist/guard/index.cjs +5 -12
- package/dist/guard/index.cjs.map +1 -1
- package/dist/guard/index.d.cts +18 -17
- package/dist/guard/index.d.cts.map +1 -1
- package/dist/guard/index.d.mts +18 -17
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +4 -12
- package/dist/guard/index.mjs.map +1 -1
- package/dist/index-MbdqaUt1.d.cts +54 -0
- package/dist/index-MbdqaUt1.d.cts.map +1 -0
- package/dist/index-k-paNOu4.d.mts +54 -0
- package/dist/index-k-paNOu4.d.mts.map +1 -0
- package/dist/iterator/index.cjs +72 -26
- package/dist/iterator/index.cjs.map +1 -1
- package/dist/iterator/index.d.cts +157 -5
- package/dist/iterator/index.d.cts.map +1 -1
- package/dist/iterator/index.d.mts +157 -5
- package/dist/iterator/index.d.mts.map +1 -1
- package/dist/iterator/index.mjs +66 -24
- package/dist/iterator/index.mjs.map +1 -1
- package/dist/lens/index.cjs +3 -3
- package/dist/lens/index.cjs.map +1 -1
- package/dist/lens/index.mjs +3 -3
- package/dist/lens/index.mjs.map +1 -1
- package/dist/map/index.cjs +88 -1
- package/dist/map/index.cjs.map +1 -1
- package/dist/map/index.d.cts +130 -2
- package/dist/map/index.d.cts.map +1 -1
- package/dist/map/index.d.mts +130 -2
- package/dist/map/index.d.mts.map +1 -1
- package/dist/map/index.mjs +86 -2
- package/dist/map/index.mjs.map +1 -1
- package/dist/number/index.cjs +91 -18
- package/dist/number/index.cjs.map +1 -1
- package/dist/number/index.d.cts +134 -19
- package/dist/number/index.d.cts.map +1 -1
- package/dist/number/index.d.mts +134 -19
- package/dist/number/index.d.mts.map +1 -1
- package/dist/number/index.mjs +91 -18
- package/dist/number/index.mjs.map +1 -1
- package/dist/object/index.cjs +111 -7
- package/dist/object/index.cjs.map +1 -1
- package/dist/object/index.d.cts +186 -26
- package/dist/object/index.d.cts.map +1 -1
- package/dist/object/index.d.mts +186 -26
- package/dist/object/index.d.mts.map +1 -1
- package/dist/object/index.mjs +111 -7
- package/dist/object/index.mjs.map +1 -1
- package/dist/orNull-CJNrTjhQ.cjs +45 -0
- package/dist/orNull-CJNrTjhQ.cjs.map +1 -0
- package/dist/orNull-EeXiCxD4.mjs +34 -0
- package/dist/orNull-EeXiCxD4.mjs.map +1 -0
- package/dist/order/index.cjs +22 -1
- package/dist/order/index.cjs.map +1 -1
- package/dist/order/index.d.cts +2 -2
- package/dist/order/index.d.mts +2 -2
- package/dist/order/index.mjs +22 -1
- package/dist/order/index.mjs.map +1 -1
- package/dist/{order.constants-BWSCg3C7.d.cts → order.constants-DpGY-EDp.d.cts} +4 -1
- package/dist/order.constants-DpGY-EDp.d.cts.map +1 -0
- package/dist/{order.constants-BWSCg3C7.d.mts → order.constants-DpGY-EDp.d.mts} +4 -1
- package/dist/order.constants-DpGY-EDp.d.mts.map +1 -0
- package/dist/purry-DXnhXie9.mjs +22 -0
- package/dist/purry-DXnhXie9.mjs.map +1 -0
- package/dist/purry-Dqp_F64t.cjs +27 -0
- package/dist/purry-Dqp_F64t.cjs.map +1 -0
- package/dist/set/index.cjs +59 -1
- package/dist/set/index.cjs.map +1 -1
- package/dist/set/index.d.cts +151 -2
- package/dist/set/index.d.cts.map +1 -1
- package/dist/set/index.d.mts +151 -2
- package/dist/set/index.d.mts.map +1 -1
- package/dist/set/index.mjs +59 -2
- package/dist/set/index.mjs.map +1 -1
- package/dist/string/index.cjs +289 -15
- package/dist/string/index.cjs.map +1 -1
- package/dist/string/index.d.cts +406 -1
- package/dist/string/index.d.cts.map +1 -1
- package/dist/string/index.d.mts +406 -1
- package/dist/string/index.d.mts.map +1 -1
- package/dist/string/index.mjs +271 -4
- package/dist/string/index.mjs.map +1 -1
- package/dist/tuple/index.cjs +20 -21
- package/dist/tuple/index.cjs.map +1 -1
- package/dist/tuple/index.d.cts +27 -58
- package/dist/tuple/index.d.cts.map +1 -1
- package/dist/tuple/index.d.mts +27 -58
- package/dist/tuple/index.d.mts.map +1 -1
- package/dist/tuple/index.mjs +20 -22
- package/dist/tuple/index.mjs.map +1 -1
- package/package.json +5 -6
- package/dist/function-CB82a2GS.cjs.map +0 -1
- package/dist/function-DnI2v0p3.mjs.map +0 -1
- package/dist/get-CWL_cu6G.mjs.map +0 -1
- package/dist/get-yrs1Kqho.cjs.map +0 -1
- package/dist/index-BJlKyBJH.d.cts +0 -18
- package/dist/index-BJlKyBJH.d.cts.map +0 -1
- package/dist/index-DGrnGMDt.d.mts +0 -18
- package/dist/index-DGrnGMDt.d.mts.map +0 -1
- package/dist/isNotNil-DrF-ohem.cjs +0 -28
- package/dist/isNotNil-DrF-ohem.cjs.map +0 -1
- package/dist/isNotNil-R5f1hC53.mjs +0 -23
- package/dist/isNotNil-R5f1hC53.mjs.map +0 -1
- package/dist/orThrow-V91Jw2lF.mjs +0 -15
- package/dist/orThrow-V91Jw2lF.mjs.map +0 -1
- package/dist/orThrow-ejzcQYAI.cjs +0 -20
- package/dist/orThrow-ejzcQYAI.cjs.map +0 -1
- package/dist/order.constants-BWSCg3C7.d.cts.map +0 -1
- package/dist/order.constants-BWSCg3C7.d.mts.map +0 -1
- package/dist/purry-B2_0DGLV.cjs +0 -28
- package/dist/purry-B2_0DGLV.cjs.map +0 -1
- package/dist/purry-BOWmqwDB.mjs +0 -23
- package/dist/purry-BOWmqwDB.mjs.map +0 -1
package/dist/map/index.cjs
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_purry = require("../purry-
|
|
2
|
+
const require_purry = require("../purry-Dqp_F64t.cjs");
|
|
3
|
+
const require_errors = require("../errors-O-d_Vemi.cjs");
|
|
4
|
+
//#region src/map/_globalAliases.ts
|
|
5
|
+
/**
|
|
6
|
+
* Alias of the built-in map constructor. `new Map() === new Map.Ctor()`
|
|
7
|
+
* @function
|
|
8
|
+
*/
|
|
9
|
+
const Ctor = Map;
|
|
10
|
+
//#endregion
|
|
3
11
|
//#region src/map/clear.ts
|
|
12
|
+
/**
|
|
13
|
+
* Removes all entries from a map and returns the same map.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* clear(new Map([['a', 1], ['b', 2]])); // Map(0) {}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
4
20
|
function clear(data) {
|
|
5
21
|
data.clear();
|
|
6
22
|
return data;
|
|
7
23
|
}
|
|
8
24
|
//#endregion
|
|
9
25
|
//#region src/map/entries.ts
|
|
26
|
+
/**
|
|
27
|
+
* Returns an iterator of a map's key-value pairs.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* [...entries(new Map([['a', 1], ['b', 2]]))]; // [['a', 1], ['b', 2]]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
10
34
|
function entries(data) {
|
|
11
35
|
return data.entries();
|
|
12
36
|
}
|
|
@@ -21,9 +45,25 @@ function forEach(...args) {
|
|
|
21
45
|
}
|
|
22
46
|
//#endregion
|
|
23
47
|
//#region src/map/from.ts
|
|
48
|
+
/**
|
|
49
|
+
* Creates a map from an iterable of key-value pairs.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* from([['a', 1], ['b', 2]]); // Map { 'a' => 1, 'b' => 2 }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
24
56
|
function from(iterable) {
|
|
25
57
|
return new Map(iterable);
|
|
26
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates an empty map.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* empty(); // Map(0) {}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
27
67
|
function empty() {
|
|
28
68
|
return /* @__PURE__ */ new Map();
|
|
29
69
|
}
|
|
@@ -36,6 +76,34 @@ function get(...args) {
|
|
|
36
76
|
return require_purry.purry(getImplementation, args);
|
|
37
77
|
}
|
|
38
78
|
//#endregion
|
|
79
|
+
//#region src/map/getOrInsert.ts
|
|
80
|
+
/**
|
|
81
|
+
* Inserts a default value when a key is absent and returns the same map.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const map = new Map<string, number>();
|
|
86
|
+
* getOrInsert(map, 'a', 1); // Map { 'a' => 1 }
|
|
87
|
+
* getOrInsert(map, 'a', 2); // Map { 'a' => 1 }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function getOrInsert(map, key, defaultValue) {
|
|
91
|
+
throw new require_errors.NotYetImplementedError("M.getOrInsert not yet implemented");
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Inserts a computed value when a key is absent and returns the same map.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const map = new Map<string, number>();
|
|
99
|
+
* getOrInsertComputed(map, 'a', () => 1); // Map { 'a' => 1 }
|
|
100
|
+
* getOrInsertComputed(map, 'a', () => 2); // Map { 'a' => 1 }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
function getOrInsertComputed(map, key, callback) {
|
|
104
|
+
throw new require_errors.NotYetImplementedError("M.getOrInsertComputed not yet implemented");
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
39
107
|
//#region src/map/groupBy.ts
|
|
40
108
|
function groupByImplementation(items, keySelector) {
|
|
41
109
|
return Map.groupBy(items, keySelector);
|
|
@@ -45,6 +113,14 @@ function groupBy(...args) {
|
|
|
45
113
|
}
|
|
46
114
|
//#endregion
|
|
47
115
|
//#region src/map/keys.ts
|
|
116
|
+
/**
|
|
117
|
+
* Returns an iterator of a map's keys.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* [...keys(new Map([['a', 1], ['b', 2]]))]; // ['a', 'b']
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
48
124
|
function keys(data) {
|
|
49
125
|
return data.keys();
|
|
50
126
|
}
|
|
@@ -67,16 +143,27 @@ function set(...args) {
|
|
|
67
143
|
}
|
|
68
144
|
//#endregion
|
|
69
145
|
//#region src/map/values.ts
|
|
146
|
+
/**
|
|
147
|
+
* Returns an iterator of a map's values.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* [...values(new Map([['a', 1], ['b', 2]]))]; // [1, 2]
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
70
154
|
function values(data) {
|
|
71
155
|
return data.values();
|
|
72
156
|
}
|
|
73
157
|
//#endregion
|
|
158
|
+
exports.Ctor = Ctor;
|
|
74
159
|
exports.clear = clear;
|
|
75
160
|
exports.empty = empty;
|
|
76
161
|
exports.entries = entries;
|
|
77
162
|
exports.forEach = forEach;
|
|
78
163
|
exports.from = from;
|
|
79
164
|
exports.get = get;
|
|
165
|
+
exports.getOrInsert = getOrInsert;
|
|
166
|
+
exports.getOrInsertComputed = getOrInsertComputed;
|
|
80
167
|
exports.groupBy = groupBy;
|
|
81
168
|
exports.keys = keys;
|
|
82
169
|
exports.remove = remove;
|
package/dist/map/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["purry","purry","purry","purry","purry"],"sources":["../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/groupBy.ts","../../src/map/keys.ts","../../src/map/remove.ts","../../src/map/set.ts","../../src/map/values.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["purry","purry","NotYetImplementedError","purry","purry","purry"],"sources":["../../src/map/_globalAliases.ts","../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/getOrInsert.ts","../../src/map/groupBy.ts","../../src/map/keys.ts","../../src/map/remove.ts","../../src/map/set.ts","../../src/map/values.ts"],"sourcesContent":["/**\n * Alias of the built-in map constructor. `new Map() === new Map.Ctor()`\n * @function\n */\nexport const Ctor = Map;\n","/**\n * Removes all entries from a map and returns the same map.\n *\n * @example\n * ```ts\n * clear(new Map([['a', 1], ['b', 2]])); // Map(0) {}\n * ```\n */\nexport function clear<K, V>(data: Map<K, V>): Map<K, V> {\n data.clear();\n return data;\n}\n","/**\n * Returns an iterator of a map's key-value pairs.\n *\n * @example\n * ```ts\n * [...entries(new Map([['a', 1], ['b', 2]]))]; // [['a', 1], ['b', 2]]\n * ```\n */\nexport function entries<K, V>(data: Map<K, V>): MapIterator<[K, V]> {\n return data.entries();\n}\n","import { purry } from '../function/purry';\n\nfunction forEachImplementation<K, V>(\n data: Map<K, V>,\n callbackfn: (value: V, key: K, map: Map<K, V>) => void,\n): Map<K, V> {\n data.forEach(callbackfn);\n return data;\n}\n\n/**\n * Runs a callback for each map entry and returns the same map.\n *\n * @example\n * ```ts\n * const map = new Map([['a', 1], ['b', 2]]);\n * forEach(map, (value, key) => console.log(key, value)); // map\n * forEach((value, key) => console.log(key, value))(map); // map\n * ```\n */\nexport function forEach<K, V>(callbackfn: (value: V, key: K, set: Map<K, V>) => void): (data: Map<K, V>) => Map<K, V>;\nexport function forEach<K, V>(data: Map<K, V>, callbackfn: (value: V, key: K, set: Map<K, V>) => void): Map<K, V>;\nexport function forEach(...args: readonly unknown[]): unknown {\n return purry(forEachImplementation, args);\n}\n","/**\n * Creates a map from an iterable of key-value pairs.\n *\n * @example\n * ```ts\n * from([['a', 1], ['b', 2]]); // Map { 'a' => 1, 'b' => 2 }\n * ```\n */\nexport function from<K, V>(iterable: Iterable<[K, V]> | readonly (readonly [K, V])[]): Map<K, V> {\n return new Map(iterable);\n}\n\n/**\n * Creates an empty map.\n *\n * @example\n * ```ts\n * empty(); // Map(0) {}\n * ```\n */\nexport function empty<K, V>(): Map<K, V> {\n return new Map();\n}\n","import { purry } from '../function/purry';\n\nfunction getImplementation<K, V>(data: Map<K, V>, key: K): V | undefined {\n return data.get(key);\n}\n\n/**\n * Returns the value associated with a key, or `undefined` when the key is absent.\n *\n * @example\n * ```ts\n * const map = new Map([['a', 1]]);\n * get(map, 'a'); // 1\n * get(map, 'b'); // undefined\n * get('a')(map); // 1\n * ```\n */\nexport function get<K>(key: K): <V>(data: Map<K, V>) => V | undefined;\nexport function get<K, V>(data: Map<K, V>, key: K): V | undefined;\nexport function get(...args: readonly unknown[]): unknown {\n return purry(getImplementation, args);\n}\n","import { NotYetImplementedError } from '../errors';\n\n/**\n * Inserts a default value when a key is absent and returns the same map.\n *\n * @example\n * ```ts\n * const map = new Map<string, number>();\n * getOrInsert(map, 'a', 1); // Map { 'a' => 1 }\n * getOrInsert(map, 'a', 2); // Map { 'a' => 1 }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function getOrInsert<K, V>(map: Map<K, V>, key: K, defaultValue: V): Map<K, V> {\n throw new NotYetImplementedError('M.getOrInsert not yet implemented');\n}\n\n/**\n * Inserts a computed value when a key is absent and returns the same map.\n *\n * @example\n * ```ts\n * const map = new Map<string, number>();\n * getOrInsertComputed(map, 'a', () => 1); // Map { 'a' => 1 }\n * getOrInsertComputed(map, 'a', () => 2); // Map { 'a' => 1 }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function getOrInsertComputed<K, V>(map: Map<K, V>, key: K, callback: (key: K) => V): Map<K, V> {\n throw new NotYetImplementedError('M.getOrInsertComputed not yet implemented');\n}\n","import { purry } from '../function/purry';\n\nfunction groupByImplementation<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]> {\n return Map.groupBy(items, keySelector);\n}\n\n/**\n * Groups iterable items into a map keyed by a selector function.\n *\n * @example\n * ```ts\n * groupBy(\n * [{ id: 1 }, { id: 2 }, { id: 1 }],\n * item => item.id,\n * ); // Map { 1 => [{ id: 1 }, { id: 1 }], 2 => [{ id: 2 }] }\n * groupBy(item => item.id)([{ id: 1 }, { id: 2 }]); // Map { 1 => [...], 2 => [...] }\n * ```\n */\nexport function groupBy<K, T>(keySelector: (item: T, index: number) => K): (items: Iterable<T>) => Map<K, T[]>;\nexport function groupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]>;\nexport function groupBy(...args: readonly unknown[]): unknown {\n return purry(groupByImplementation, args);\n}\n","/**\n * Returns an iterator of a map's keys.\n *\n * @example\n * ```ts\n * [...keys(new Map([['a', 1], ['b', 2]]))]; // ['a', 'b']\n * ```\n */\nexport function keys<K, V>(data: Map<K, V>): MapIterator<K> {\n return data.keys();\n}\n","import { purry } from '../function/purry';\n\nfunction removeImplementation<K, V>(data: Map<K, V>, key: K): Map<K, V> {\n data.delete(key);\n return data;\n}\n\n/**\n * Removes an entry by key and returns the same map.\n *\n * @example\n * ```ts\n * const map = new Map([['a', 1], ['b', 2]]);\n * remove(map, 'a'); // Map { 'b' => 2 }\n * remove('b')(map); // Map(0) {}\n * ```\n */\nexport function remove<K>(key: K): <V>(data: Map<K, V>) => Map<K, V>;\nexport function remove<K, V>(data: Map<K, V>, key: K): Map<K, V>;\nexport function remove(...args: readonly unknown[]): unknown {\n return purry(removeImplementation, args);\n}\n","import { purry } from '../function/purry';\n\nfunction setImplementation<K, V>(data: Map<K, V>, key: K, value: V): Map<K, V> {\n return data.set(key, value);\n}\n\n/**\n * Sets a key-value pair and returns the same map.\n *\n * @example\n * ```ts\n * set(new Map(), 'a', 1); // Map { 'a' => 1 }\n * set('b', 2)(new Map([['a', 1]])); // Map { 'a' => 1, 'b' => 2 }\n * ```\n */\nexport function set<K, V>(key: K, value: V): (data: Map<K, V>) => Map<K, V>;\nexport function set<K, V>(data: Map<K, V>, key: K, value: V): Map<K, V>;\nexport function set(...args: readonly unknown[]): unknown {\n return purry(setImplementation, args);\n}\n","/**\n * Returns an iterator of a map's values.\n *\n * @example\n * ```ts\n * [...values(new Map([['a', 1], ['b', 2]]))]; // [1, 2]\n * ```\n */\nexport function values<K, V>(data: Map<K, V>): MapIterator<V> {\n return data.values();\n}\n"],"mappings":";;;;;;;;AAIA,MAAa,OAAO;;;;;;;;;;;ACIpB,SAAgB,MAAY,MAA4B;CACtD,KAAK,MAAM;CACX,OAAO;AACT;;;;;;;;;;;ACHA,SAAgB,QAAc,MAAsC;CAClE,OAAO,KAAK,QAAQ;AACtB;;;ACRA,SAAS,sBACP,MACA,YACW;CACX,KAAK,QAAQ,UAAU;CACvB,OAAO;AACT;AAcA,SAAgB,QAAQ,GAAG,MAAmC;CAC5D,OAAOA,cAAAA,MAAM,uBAAuB,IAAI;AAC1C;;;;;;;;;;;AChBA,SAAgB,KAAW,UAAsE;CAC/F,OAAO,IAAI,IAAI,QAAQ;AACzB;;;;;;;;;AAUA,SAAgB,QAAyB;CACvC,uBAAO,IAAI,IAAI;AACjB;;;ACpBA,SAAS,kBAAwB,MAAiB,KAAuB;CACvE,OAAO,KAAK,IAAI,GAAG;AACrB;AAeA,SAAgB,IAAI,GAAG,MAAmC;CACxD,OAAOC,cAAAA,MAAM,mBAAmB,IAAI;AACtC;;;;;;;;;;;;;ACRA,SAAgB,YAAkB,KAAgB,KAAQ,cAA4B;CACpF,MAAM,IAAIC,eAAAA,uBAAuB,mCAAmC;AACtE;;;;;;;;;;;AAaA,SAAgB,oBAA0B,KAAgB,KAAQ,UAAoC;CACpG,MAAM,IAAIA,eAAAA,uBAAuB,2CAA2C;AAC9E;;;AC5BA,SAAS,sBAA4B,OAAoB,aAAyD;CAChH,OAAO,IAAI,QAAQ,OAAO,WAAW;AACvC;AAgBA,SAAgB,QAAQ,GAAG,MAAmC;CAC5D,OAAOC,cAAAA,MAAM,uBAAuB,IAAI;AAC1C;;;;;;;;;;;ACdA,SAAgB,KAAW,MAAiC;CAC1D,OAAO,KAAK,KAAK;AACnB;;;ACRA,SAAS,qBAA2B,MAAiB,KAAmB;CACtE,KAAK,OAAO,GAAG;CACf,OAAO;AACT;AAcA,SAAgB,OAAO,GAAG,MAAmC;CAC3D,OAAOC,cAAAA,MAAM,sBAAsB,IAAI;AACzC;;;ACnBA,SAAS,kBAAwB,MAAiB,KAAQ,OAAqB;CAC7E,OAAO,KAAK,IAAI,KAAK,KAAK;AAC5B;AAaA,SAAgB,IAAI,GAAG,MAAmC;CACxD,OAAOC,cAAAA,MAAM,mBAAmB,IAAI;AACtC;;;;;;;;;;;ACXA,SAAgB,OAAa,MAAiC;CAC5D,OAAO,KAAK,OAAO;AACrB"}
|
package/dist/map/index.d.cts
CHANGED
|
@@ -1,41 +1,169 @@
|
|
|
1
|
+
//#region src/map/_globalAliases.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Alias of the built-in map constructor. `new Map() === new Map.Ctor()`
|
|
4
|
+
* @function
|
|
5
|
+
*/
|
|
6
|
+
declare const Ctor: MapConstructor;
|
|
7
|
+
//#endregion
|
|
1
8
|
//#region src/map/clear.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Removes all entries from a map and returns the same map.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* clear(new Map([['a', 1], ['b', 2]])); // Map(0) {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
declare function clear<K, V>(data: Map<K, V>): Map<K, V>;
|
|
3
18
|
//#endregion
|
|
4
19
|
//#region src/map/entries.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* Returns an iterator of a map's key-value pairs.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* [...entries(new Map([['a', 1], ['b', 2]]))]; // [['a', 1], ['b', 2]]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
5
28
|
declare function entries<K, V>(data: Map<K, V>): MapIterator<[K, V]>;
|
|
6
29
|
//#endregion
|
|
7
30
|
//#region src/map/forEach.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* Runs a callback for each map entry and returns the same map.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const map = new Map([['a', 1], ['b', 2]]);
|
|
37
|
+
* forEach(map, (value, key) => console.log(key, value)); // map
|
|
38
|
+
* forEach((value, key) => console.log(key, value))(map); // map
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
8
41
|
declare function forEach<K, V>(callbackfn: (value: V, key: K, set: Map<K, V>) => void): (data: Map<K, V>) => Map<K, V>;
|
|
9
42
|
declare function forEach<K, V>(data: Map<K, V>, callbackfn: (value: V, key: K, set: Map<K, V>) => void): Map<K, V>;
|
|
10
43
|
//#endregion
|
|
11
44
|
//#region src/map/from.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Creates a map from an iterable of key-value pairs.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* from([['a', 1], ['b', 2]]); // Map { 'a' => 1, 'b' => 2 }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
12
53
|
declare function from<K, V>(iterable: Iterable<[K, V]> | readonly (readonly [K, V])[]): Map<K, V>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an empty map.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* empty(); // Map(0) {}
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
13
62
|
declare function empty<K, V>(): Map<K, V>;
|
|
14
63
|
//#endregion
|
|
15
64
|
//#region src/map/get.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* Returns the value associated with a key, or `undefined` when the key is absent.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const map = new Map([['a', 1]]);
|
|
71
|
+
* get(map, 'a'); // 1
|
|
72
|
+
* get(map, 'b'); // undefined
|
|
73
|
+
* get('a')(map); // 1
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
16
76
|
declare function get<K>(key: K): <V>(data: Map<K, V>) => V | undefined;
|
|
17
77
|
declare function get<K, V>(data: Map<K, V>, key: K): V | undefined;
|
|
18
78
|
//#endregion
|
|
79
|
+
//#region src/map/getOrInsert.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Inserts a default value when a key is absent and returns the same map.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const map = new Map<string, number>();
|
|
86
|
+
* getOrInsert(map, 'a', 1); // Map { 'a' => 1 }
|
|
87
|
+
* getOrInsert(map, 'a', 2); // Map { 'a' => 1 }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function getOrInsert<K, V>(map: Map<K, V>, key: K, defaultValue: V): Map<K, V>;
|
|
91
|
+
/**
|
|
92
|
+
* Inserts a computed value when a key is absent and returns the same map.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const map = new Map<string, number>();
|
|
97
|
+
* getOrInsertComputed(map, 'a', () => 1); // Map { 'a' => 1 }
|
|
98
|
+
* getOrInsertComputed(map, 'a', () => 2); // Map { 'a' => 1 }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function getOrInsertComputed<K, V>(map: Map<K, V>, key: K, callback: (key: K) => V): Map<K, V>;
|
|
102
|
+
//#endregion
|
|
19
103
|
//#region src/map/groupBy.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Groups iterable items into a map keyed by a selector function.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* groupBy(
|
|
110
|
+
* [{ id: 1 }, { id: 2 }, { id: 1 }],
|
|
111
|
+
* item => item.id,
|
|
112
|
+
* ); // Map { 1 => [{ id: 1 }, { id: 1 }], 2 => [{ id: 2 }] }
|
|
113
|
+
* groupBy(item => item.id)([{ id: 1 }, { id: 2 }]); // Map { 1 => [...], 2 => [...] }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
20
116
|
declare function groupBy<K, T>(keySelector: (item: T, index: number) => K): (items: Iterable<T>) => Map<K, T[]>;
|
|
21
117
|
declare function groupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]>;
|
|
22
118
|
//#endregion
|
|
23
119
|
//#region src/map/keys.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Returns an iterator of a map's keys.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* [...keys(new Map([['a', 1], ['b', 2]]))]; // ['a', 'b']
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
24
128
|
declare function keys<K, V>(data: Map<K, V>): MapIterator<K>;
|
|
25
129
|
//#endregion
|
|
26
130
|
//#region src/map/remove.d.ts
|
|
27
131
|
/**
|
|
28
|
-
*
|
|
132
|
+
* Removes an entry by key and returns the same map.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const map = new Map([['a', 1], ['b', 2]]);
|
|
137
|
+
* remove(map, 'a'); // Map { 'b' => 2 }
|
|
138
|
+
* remove('b')(map); // Map(0) {}
|
|
139
|
+
* ```
|
|
29
140
|
*/
|
|
30
141
|
declare function remove<K>(key: K): <V>(data: Map<K, V>) => Map<K, V>;
|
|
31
142
|
declare function remove<K, V>(data: Map<K, V>, key: K): Map<K, V>;
|
|
32
143
|
//#endregion
|
|
33
144
|
//#region src/map/set.d.ts
|
|
145
|
+
/**
|
|
146
|
+
* Sets a key-value pair and returns the same map.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* set(new Map(), 'a', 1); // Map { 'a' => 1 }
|
|
151
|
+
* set('b', 2)(new Map([['a', 1]])); // Map { 'a' => 1, 'b' => 2 }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
34
154
|
declare function set<K, V>(key: K, value: V): (data: Map<K, V>) => Map<K, V>;
|
|
35
155
|
declare function set<K, V>(data: Map<K, V>, key: K, value: V): Map<K, V>;
|
|
36
156
|
//#endregion
|
|
37
157
|
//#region src/map/values.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Returns an iterator of a map's values.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* [...values(new Map([['a', 1], ['b', 2]]))]; // [1, 2]
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
38
166
|
declare function values<K, V>(data: Map<K, V>): MapIterator<V>;
|
|
39
167
|
//#endregion
|
|
40
|
-
export { clear, empty, entries, forEach, from, get, groupBy, keys, remove, set, values };
|
|
168
|
+
export { Ctor, clear, empty, entries, forEach, from, get, getOrInsert, getOrInsertComputed, groupBy, keys, remove, set, values };
|
|
41
169
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/map/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/groupBy.ts","../../src/map/keys.ts","../../src/map/remove.ts","../../src/map/set.ts","../../src/map/values.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/map/_globalAliases.ts","../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/getOrInsert.ts","../../src/map/groupBy.ts","../../src/map/keys.ts","../../src/map/remove.ts","../../src/map/set.ts","../../src/map/values.ts"],"mappings":";;AAIA;;;cAAa,IAAA,EAAI,cAAM;;;;AAAvB;;;;AAAuB;;;iBCIP,KAAA,OAAY,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,IAAK,GAAA,CAAI,CAAA,EAAG,CAAA;;;;ADJrD;;;;AAAuB;;;iBEIP,OAAA,OAAc,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,IAAK,WAAA,EAAa,CAAA,EAAG,CAAA;;;;AFJhE;;;;AAAuB;;;;ACIvB;iBEYgB,OAAA,OAAc,UAAA,GAAa,KAAA,EAAO,CAAA,EAAG,GAAA,EAAK,CAAA,EAAG,GAAA,EAAK,GAAA,CAAI,CAAA,EAAG,CAAA,cAAe,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,MAAO,GAAA,CAAI,CAAA,EAAG,CAAA;AAAA,iBACnG,OAAA,OAAc,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,GAAI,UAAA,GAAa,KAAA,EAAO,CAAA,EAAG,GAAA,EAAK,CAAA,EAAG,GAAA,EAAK,GAAA,CAAI,CAAA,EAAG,CAAA,aAAc,GAAA,CAAI,CAAA,EAAG,CAAA;;;;AHjB/G;;;;AAAuB;;;iBIIP,IAAA,OAAW,QAAA,EAAU,QAAA,EAAU,CAAA,EAAG,CAAA,y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U,GAAA,EAAK,CAAA,OAAQ,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,MAAO,GAAA,CAAI,CAAA,EAAG,CAAA;AAAA,iBAClD,MAAA,OAAa,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,GAAI,GAAA,EAAK,CAAA,GAAI,GAAA,CAAI,CAAA,EAAG,CAAA;;;;ATd9D;;;;AAAuB;;;;iBUWP,GAAA,OAAU,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,CAAA,IAAK,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,MAAO,GAAA,CAAI,CAAA,EAAG,CAAA;AAAA,iBACzD,GAAA,OAAU,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,GAAI,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA,EAAG,CAAA;;;;AVZrE;;;;AAAuB;;;iBWIP,MAAA,OAAa,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,IAAK,WAAA,CAAY,CAAA"}
|
package/dist/map/index.d.mts
CHANGED
|
@@ -1,41 +1,169 @@
|
|
|
1
|
+
//#region src/map/_globalAliases.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Alias of the built-in map constructor. `new Map() === new Map.Ctor()`
|
|
4
|
+
* @function
|
|
5
|
+
*/
|
|
6
|
+
declare const Ctor: MapConstructor;
|
|
7
|
+
//#endregion
|
|
1
8
|
//#region src/map/clear.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Removes all entries from a map and returns the same map.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* clear(new Map([['a', 1], ['b', 2]])); // Map(0) {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
declare function clear<K, V>(data: Map<K, V>): Map<K, V>;
|
|
3
18
|
//#endregion
|
|
4
19
|
//#region src/map/entries.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* Returns an iterator of a map's key-value pairs.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* [...entries(new Map([['a', 1], ['b', 2]]))]; // [['a', 1], ['b', 2]]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
5
28
|
declare function entries<K, V>(data: Map<K, V>): MapIterator<[K, V]>;
|
|
6
29
|
//#endregion
|
|
7
30
|
//#region src/map/forEach.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* Runs a callback for each map entry and returns the same map.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const map = new Map([['a', 1], ['b', 2]]);
|
|
37
|
+
* forEach(map, (value, key) => console.log(key, value)); // map
|
|
38
|
+
* forEach((value, key) => console.log(key, value))(map); // map
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
8
41
|
declare function forEach<K, V>(callbackfn: (value: V, key: K, set: Map<K, V>) => void): (data: Map<K, V>) => Map<K, V>;
|
|
9
42
|
declare function forEach<K, V>(data: Map<K, V>, callbackfn: (value: V, key: K, set: Map<K, V>) => void): Map<K, V>;
|
|
10
43
|
//#endregion
|
|
11
44
|
//#region src/map/from.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Creates a map from an iterable of key-value pairs.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* from([['a', 1], ['b', 2]]); // Map { 'a' => 1, 'b' => 2 }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
12
53
|
declare function from<K, V>(iterable: Iterable<[K, V]> | readonly (readonly [K, V])[]): Map<K, V>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an empty map.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* empty(); // Map(0) {}
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
13
62
|
declare function empty<K, V>(): Map<K, V>;
|
|
14
63
|
//#endregion
|
|
15
64
|
//#region src/map/get.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* Returns the value associated with a key, or `undefined` when the key is absent.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const map = new Map([['a', 1]]);
|
|
71
|
+
* get(map, 'a'); // 1
|
|
72
|
+
* get(map, 'b'); // undefined
|
|
73
|
+
* get('a')(map); // 1
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
16
76
|
declare function get<K>(key: K): <V>(data: Map<K, V>) => V | undefined;
|
|
17
77
|
declare function get<K, V>(data: Map<K, V>, key: K): V | undefined;
|
|
18
78
|
//#endregion
|
|
79
|
+
//#region src/map/getOrInsert.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Inserts a default value when a key is absent and returns the same map.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const map = new Map<string, number>();
|
|
86
|
+
* getOrInsert(map, 'a', 1); // Map { 'a' => 1 }
|
|
87
|
+
* getOrInsert(map, 'a', 2); // Map { 'a' => 1 }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function getOrInsert<K, V>(map: Map<K, V>, key: K, defaultValue: V): Map<K, V>;
|
|
91
|
+
/**
|
|
92
|
+
* Inserts a computed value when a key is absent and returns the same map.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const map = new Map<string, number>();
|
|
97
|
+
* getOrInsertComputed(map, 'a', () => 1); // Map { 'a' => 1 }
|
|
98
|
+
* getOrInsertComputed(map, 'a', () => 2); // Map { 'a' => 1 }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function getOrInsertComputed<K, V>(map: Map<K, V>, key: K, callback: (key: K) => V): Map<K, V>;
|
|
102
|
+
//#endregion
|
|
19
103
|
//#region src/map/groupBy.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Groups iterable items into a map keyed by a selector function.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* groupBy(
|
|
110
|
+
* [{ id: 1 }, { id: 2 }, { id: 1 }],
|
|
111
|
+
* item => item.id,
|
|
112
|
+
* ); // Map { 1 => [{ id: 1 }, { id: 1 }], 2 => [{ id: 2 }] }
|
|
113
|
+
* groupBy(item => item.id)([{ id: 1 }, { id: 2 }]); // Map { 1 => [...], 2 => [...] }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
20
116
|
declare function groupBy<K, T>(keySelector: (item: T, index: number) => K): (items: Iterable<T>) => Map<K, T[]>;
|
|
21
117
|
declare function groupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]>;
|
|
22
118
|
//#endregion
|
|
23
119
|
//#region src/map/keys.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Returns an iterator of a map's keys.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* [...keys(new Map([['a', 1], ['b', 2]]))]; // ['a', 'b']
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
24
128
|
declare function keys<K, V>(data: Map<K, V>): MapIterator<K>;
|
|
25
129
|
//#endregion
|
|
26
130
|
//#region src/map/remove.d.ts
|
|
27
131
|
/**
|
|
28
|
-
*
|
|
132
|
+
* Removes an entry by key and returns the same map.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const map = new Map([['a', 1], ['b', 2]]);
|
|
137
|
+
* remove(map, 'a'); // Map { 'b' => 2 }
|
|
138
|
+
* remove('b')(map); // Map(0) {}
|
|
139
|
+
* ```
|
|
29
140
|
*/
|
|
30
141
|
declare function remove<K>(key: K): <V>(data: Map<K, V>) => Map<K, V>;
|
|
31
142
|
declare function remove<K, V>(data: Map<K, V>, key: K): Map<K, V>;
|
|
32
143
|
//#endregion
|
|
33
144
|
//#region src/map/set.d.ts
|
|
145
|
+
/**
|
|
146
|
+
* Sets a key-value pair and returns the same map.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* set(new Map(), 'a', 1); // Map { 'a' => 1 }
|
|
151
|
+
* set('b', 2)(new Map([['a', 1]])); // Map { 'a' => 1, 'b' => 2 }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
34
154
|
declare function set<K, V>(key: K, value: V): (data: Map<K, V>) => Map<K, V>;
|
|
35
155
|
declare function set<K, V>(data: Map<K, V>, key: K, value: V): Map<K, V>;
|
|
36
156
|
//#endregion
|
|
37
157
|
//#region src/map/values.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Returns an iterator of a map's values.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* [...values(new Map([['a', 1], ['b', 2]]))]; // [1, 2]
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
38
166
|
declare function values<K, V>(data: Map<K, V>): MapIterator<V>;
|
|
39
167
|
//#endregion
|
|
40
|
-
export { clear, empty, entries, forEach, from, get, groupBy, keys, remove, set, values };
|
|
168
|
+
export { Ctor, clear, empty, entries, forEach, from, get, getOrInsert, getOrInsertComputed, groupBy, keys, remove, set, values };
|
|
41
169
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/map/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/groupBy.ts","../../src/map/keys.ts","../../src/map/remove.ts","../../src/map/set.ts","../../src/map/values.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/map/_globalAliases.ts","../../src/map/clear.ts","../../src/map/entries.ts","../../src/map/forEach.ts","../../src/map/from.ts","../../src/map/get.ts","../../src/map/getOrInsert.ts","../../src/map/groupBy.ts","../../src/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AAG,CAAA,MAAO,GAAA,CAAI,CAAA,EAAG,CAAA;AAAA,iBACzD,GAAA,OAAU,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,GAAI,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA,EAAG,CAAA;;;;AVZrE;;;;AAAuB;;;iBWIP,MAAA,OAAa,IAAA,EAAM,GAAA,CAAI,CAAA,EAAG,CAAA,IAAK,WAAA,CAAY,CAAA"}
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import { t as purry } from "../purry-
|
|
1
|
+
import { t as purry } from "../purry-DXnhXie9.mjs";
|
|
2
|
+
import { a as NotYetImplementedError } from "../errors-Dw1kitu_.mjs";
|
|
3
|
+
//#region src/map/_globalAliases.ts
|
|
4
|
+
/**
|
|
5
|
+
* Alias of the built-in map constructor. `new Map() === new Map.Ctor()`
|
|
6
|
+
* @function
|
|
7
|
+
*/
|
|
8
|
+
const Ctor = Map;
|
|
9
|
+
//#endregion
|
|
2
10
|
//#region src/map/clear.ts
|
|
11
|
+
/**
|
|
12
|
+
* Removes all entries from a map and returns the same map.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* clear(new Map([['a', 1], ['b', 2]])); // Map(0) {}
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
3
19
|
function clear(data) {
|
|
4
20
|
data.clear();
|
|
5
21
|
return data;
|
|
6
22
|
}
|
|
7
23
|
//#endregion
|
|
8
24
|
//#region src/map/entries.ts
|
|
25
|
+
/**
|
|
26
|
+
* Returns an iterator of a map's key-value pairs.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* [...entries(new Map([['a', 1], ['b', 2]]))]; // [['a', 1], ['b', 2]]
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
9
33
|
function entries(data) {
|
|
10
34
|
return data.entries();
|
|
11
35
|
}
|
|
@@ -20,9 +44,25 @@ function forEach(...args) {
|
|
|
20
44
|
}
|
|
21
45
|
//#endregion
|
|
22
46
|
//#region src/map/from.ts
|
|
47
|
+
/**
|
|
48
|
+
* Creates a map from an iterable of key-value pairs.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* from([['a', 1], ['b', 2]]); // Map { 'a' => 1, 'b' => 2 }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
23
55
|
function from(iterable) {
|
|
24
56
|
return new Map(iterable);
|
|
25
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates an empty map.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* empty(); // Map(0) {}
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
26
66
|
function empty() {
|
|
27
67
|
return /* @__PURE__ */ new Map();
|
|
28
68
|
}
|
|
@@ -35,6 +75,34 @@ function get(...args) {
|
|
|
35
75
|
return purry(getImplementation, args);
|
|
36
76
|
}
|
|
37
77
|
//#endregion
|
|
78
|
+
//#region src/map/getOrInsert.ts
|
|
79
|
+
/**
|
|
80
|
+
* Inserts a default value when a key is absent and returns the same map.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const map = new Map<string, number>();
|
|
85
|
+
* getOrInsert(map, 'a', 1); // Map { 'a' => 1 }
|
|
86
|
+
* getOrInsert(map, 'a', 2); // Map { 'a' => 1 }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
function getOrInsert(map, key, defaultValue) {
|
|
90
|
+
throw new NotYetImplementedError("M.getOrInsert not yet implemented");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Inserts a computed value when a key is absent and returns the same map.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const map = new Map<string, number>();
|
|
98
|
+
* getOrInsertComputed(map, 'a', () => 1); // Map { 'a' => 1 }
|
|
99
|
+
* getOrInsertComputed(map, 'a', () => 2); // Map { 'a' => 1 }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function getOrInsertComputed(map, key, callback) {
|
|
103
|
+
throw new NotYetImplementedError("M.getOrInsertComputed not yet implemented");
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
38
106
|
//#region src/map/groupBy.ts
|
|
39
107
|
function groupByImplementation(items, keySelector) {
|
|
40
108
|
return Map.groupBy(items, keySelector);
|
|
@@ -44,6 +112,14 @@ function groupBy(...args) {
|
|
|
44
112
|
}
|
|
45
113
|
//#endregion
|
|
46
114
|
//#region src/map/keys.ts
|
|
115
|
+
/**
|
|
116
|
+
* Returns an iterator of a map's keys.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* [...keys(new Map([['a', 1], ['b', 2]]))]; // ['a', 'b']
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
47
123
|
function keys(data) {
|
|
48
124
|
return data.keys();
|
|
49
125
|
}
|
|
@@ -66,10 +142,18 @@ function set(...args) {
|
|
|
66
142
|
}
|
|
67
143
|
//#endregion
|
|
68
144
|
//#region src/map/values.ts
|
|
145
|
+
/**
|
|
146
|
+
* Returns an iterator of a map's values.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* [...values(new Map([['a', 1], ['b', 2]]))]; // [1, 2]
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
69
153
|
function values(data) {
|
|
70
154
|
return data.values();
|
|
71
155
|
}
|
|
72
156
|
//#endregion
|
|
73
|
-
export { clear, empty, entries, forEach, from, get, groupBy, keys, remove, set, values };
|
|
157
|
+
export { Ctor, clear, empty, entries, forEach, from, get, getOrInsert, getOrInsertComputed, groupBy, keys, remove, set, values };
|
|
74
158
|
|
|
75
159
|
//# sourceMappingURL=index.mjs.map
|