@bemoje/map 1.2.0 → 1.2.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/lib/index.cjs +414 -108
- package/lib/index.d.cts +364 -17
- package/lib/index.d.ts +364 -17
- package/lib/index.js +400 -15
- package/package.json +81 -141
- package/lib/ExtMap.cjs +0 -104
- package/lib/ExtMap.d.cts +0 -110
- package/lib/ExtMap.d.ts +0 -110
- package/lib/ExtMap.js +0 -101
- package/lib/TimeoutWeakMap.cjs +0 -120
- package/lib/TimeoutWeakMap.d.cts +0 -75
- package/lib/TimeoutWeakMap.d.ts +0 -75
- package/lib/TimeoutWeakMap.js +0 -118
- package/lib/countUniques.cjs +0 -18
- package/lib/countUniques.d.cts +0 -9
- package/lib/countUniques.d.ts +0 -9
- package/lib/countUniques.js +0 -15
- package/lib/entriesArray.cjs +0 -10
- package/lib/entriesArray.d.cts +0 -19
- package/lib/entriesArray.d.ts +0 -19
- package/lib/entriesArray.js +0 -8
- package/lib/isGenericMap.cjs +0 -16
- package/lib/isGenericMap.d.cts +0 -6
- package/lib/isGenericMap.d.ts +0 -6
- package/lib/isGenericMap.js +0 -14
- package/lib/keysArray.cjs +0 -10
- package/lib/keysArray.d.cts +0 -19
- package/lib/keysArray.d.ts +0 -19
- package/lib/keysArray.js +0 -8
- package/lib/mapGetOrDefault.cjs +0 -16
- package/lib/mapGetOrDefault.d.cts +0 -8
- package/lib/mapGetOrDefault.d.ts +0 -8
- package/lib/mapGetOrDefault.js +0 -14
- package/lib/mapLoad.cjs +0 -13
- package/lib/mapLoad.d.cts +0 -11
- package/lib/mapLoad.d.ts +0 -11
- package/lib/mapLoad.js +0 -11
- package/lib/mapReverse.cjs +0 -15
- package/lib/mapReverse.d.cts +0 -15
- package/lib/mapReverse.d.ts +0 -15
- package/lib/mapReverse.js +0 -12
- package/lib/mapUpdate.cjs +0 -12
- package/lib/mapUpdate.d.cts +0 -13
- package/lib/mapUpdate.d.ts +0 -13
- package/lib/mapUpdate.js +0 -10
- package/lib/sort.cjs +0 -15
- package/lib/sort.d.cts +0 -25
- package/lib/sort.d.ts +0 -25
- package/lib/sort.js +0 -13
- package/lib/sortByKeys.cjs +0 -17
- package/lib/sortByKeys.d.cts +0 -24
- package/lib/sortByKeys.d.ts +0 -24
- package/lib/sortByKeys.js +0 -15
- package/lib/sortByValues.cjs +0 -17
- package/lib/sortByValues.d.cts +0 -25
- package/lib/sortByValues.d.ts +0 -25
- package/lib/sortByValues.js +0 -15
- package/lib/toMap.cjs +0 -10
- package/lib/toMap.d.cts +0 -20
- package/lib/toMap.d.ts +0 -20
- package/lib/toMap.js +0 -8
- package/lib/valuesArray.cjs +0 -10
- package/lib/valuesArray.d.cts +0 -19
- package/lib/valuesArray.d.ts +0 -19
- package/lib/valuesArray.js +0 -8
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/map",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Extended Map class and utilities for sorting, filtering, mapping, and managing key-value data.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
5
7
|
"keywords": [
|
|
6
8
|
"map",
|
|
7
9
|
"key-value",
|
|
@@ -11,18 +13,15 @@
|
|
|
11
13
|
"utilities",
|
|
12
14
|
"typescript"
|
|
13
15
|
],
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"iter-tools": "^7.5.4",
|
|
16
|
-
"mnemonist": "^0.40.3"
|
|
17
|
-
},
|
|
18
|
-
"type": "module",
|
|
19
|
-
"sideEffects": false,
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
16
|
"main": "./lib/index.cjs",
|
|
24
17
|
"module": "./lib/index.js",
|
|
25
18
|
"types": "./lib/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"./lib/index.js",
|
|
21
|
+
"./lib/index.d.ts",
|
|
22
|
+
"./lib/index.cjs",
|
|
23
|
+
"./lib/index.d.cts"
|
|
24
|
+
],
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"import": {
|
|
@@ -36,230 +35,171 @@
|
|
|
36
35
|
},
|
|
37
36
|
"./ExtMap": {
|
|
38
37
|
"import": {
|
|
39
|
-
"types": "./lib/
|
|
40
|
-
"default": "./lib/
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
41
40
|
},
|
|
42
41
|
"require": {
|
|
43
|
-
"types": "./lib/
|
|
44
|
-
"default": "./lib/
|
|
42
|
+
"types": "./lib/index.d.cts",
|
|
43
|
+
"default": "./lib/index.cjs"
|
|
45
44
|
}
|
|
46
45
|
},
|
|
47
46
|
"./TimeoutWeakMap": {
|
|
48
47
|
"import": {
|
|
49
|
-
"types": "./lib/
|
|
50
|
-
"default": "./lib/
|
|
48
|
+
"types": "./lib/index.d.ts",
|
|
49
|
+
"default": "./lib/index.js"
|
|
51
50
|
},
|
|
52
51
|
"require": {
|
|
53
|
-
"types": "./lib/
|
|
54
|
-
"default": "./lib/
|
|
52
|
+
"types": "./lib/index.d.cts",
|
|
53
|
+
"default": "./lib/index.cjs"
|
|
55
54
|
}
|
|
56
55
|
},
|
|
57
56
|
"./countUniques": {
|
|
58
57
|
"import": {
|
|
59
|
-
"types": "./lib/
|
|
60
|
-
"default": "./lib/
|
|
58
|
+
"types": "./lib/index.d.ts",
|
|
59
|
+
"default": "./lib/index.js"
|
|
61
60
|
},
|
|
62
61
|
"require": {
|
|
63
|
-
"types": "./lib/
|
|
64
|
-
"default": "./lib/
|
|
62
|
+
"types": "./lib/index.d.cts",
|
|
63
|
+
"default": "./lib/index.cjs"
|
|
65
64
|
}
|
|
66
65
|
},
|
|
67
66
|
"./entriesArray": {
|
|
68
67
|
"import": {
|
|
69
|
-
"types": "./lib/
|
|
70
|
-
"default": "./lib/
|
|
68
|
+
"types": "./lib/index.d.ts",
|
|
69
|
+
"default": "./lib/index.js"
|
|
71
70
|
},
|
|
72
71
|
"require": {
|
|
73
|
-
"types": "./lib/
|
|
74
|
-
"default": "./lib/
|
|
72
|
+
"types": "./lib/index.d.cts",
|
|
73
|
+
"default": "./lib/index.cjs"
|
|
75
74
|
}
|
|
76
75
|
},
|
|
77
76
|
"./isGenericMap": {
|
|
78
77
|
"import": {
|
|
79
|
-
"types": "./lib/
|
|
80
|
-
"default": "./lib/
|
|
78
|
+
"types": "./lib/index.d.ts",
|
|
79
|
+
"default": "./lib/index.js"
|
|
81
80
|
},
|
|
82
81
|
"require": {
|
|
83
|
-
"types": "./lib/
|
|
84
|
-
"default": "./lib/
|
|
82
|
+
"types": "./lib/index.d.cts",
|
|
83
|
+
"default": "./lib/index.cjs"
|
|
85
84
|
}
|
|
86
85
|
},
|
|
87
86
|
"./keysArray": {
|
|
88
87
|
"import": {
|
|
89
|
-
"types": "./lib/
|
|
90
|
-
"default": "./lib/
|
|
88
|
+
"types": "./lib/index.d.ts",
|
|
89
|
+
"default": "./lib/index.js"
|
|
91
90
|
},
|
|
92
91
|
"require": {
|
|
93
|
-
"types": "./lib/
|
|
94
|
-
"default": "./lib/
|
|
92
|
+
"types": "./lib/index.d.cts",
|
|
93
|
+
"default": "./lib/index.cjs"
|
|
95
94
|
}
|
|
96
95
|
},
|
|
97
96
|
"./mapGetOrDefault": {
|
|
98
97
|
"import": {
|
|
99
|
-
"types": "./lib/
|
|
100
|
-
"default": "./lib/
|
|
98
|
+
"types": "./lib/index.d.ts",
|
|
99
|
+
"default": "./lib/index.js"
|
|
101
100
|
},
|
|
102
101
|
"require": {
|
|
103
|
-
"types": "./lib/
|
|
104
|
-
"default": "./lib/
|
|
102
|
+
"types": "./lib/index.d.cts",
|
|
103
|
+
"default": "./lib/index.cjs"
|
|
105
104
|
}
|
|
106
105
|
},
|
|
107
106
|
"./mapLoad": {
|
|
108
107
|
"import": {
|
|
109
|
-
"types": "./lib/
|
|
110
|
-
"default": "./lib/
|
|
108
|
+
"types": "./lib/index.d.ts",
|
|
109
|
+
"default": "./lib/index.js"
|
|
111
110
|
},
|
|
112
111
|
"require": {
|
|
113
|
-
"types": "./lib/
|
|
114
|
-
"default": "./lib/
|
|
112
|
+
"types": "./lib/index.d.cts",
|
|
113
|
+
"default": "./lib/index.cjs"
|
|
115
114
|
}
|
|
116
115
|
},
|
|
117
116
|
"./mapReverse": {
|
|
118
117
|
"import": {
|
|
119
|
-
"types": "./lib/
|
|
120
|
-
"default": "./lib/
|
|
118
|
+
"types": "./lib/index.d.ts",
|
|
119
|
+
"default": "./lib/index.js"
|
|
121
120
|
},
|
|
122
121
|
"require": {
|
|
123
|
-
"types": "./lib/
|
|
124
|
-
"default": "./lib/
|
|
122
|
+
"types": "./lib/index.d.cts",
|
|
123
|
+
"default": "./lib/index.cjs"
|
|
125
124
|
}
|
|
126
125
|
},
|
|
127
126
|
"./mapUpdate": {
|
|
128
127
|
"import": {
|
|
129
|
-
"types": "./lib/
|
|
130
|
-
"default": "./lib/
|
|
128
|
+
"types": "./lib/index.d.ts",
|
|
129
|
+
"default": "./lib/index.js"
|
|
131
130
|
},
|
|
132
131
|
"require": {
|
|
133
|
-
"types": "./lib/
|
|
134
|
-
"default": "./lib/
|
|
132
|
+
"types": "./lib/index.d.cts",
|
|
133
|
+
"default": "./lib/index.cjs"
|
|
135
134
|
}
|
|
136
135
|
},
|
|
137
136
|
"./sort": {
|
|
138
137
|
"import": {
|
|
139
|
-
"types": "./lib/
|
|
140
|
-
"default": "./lib/
|
|
138
|
+
"types": "./lib/index.d.ts",
|
|
139
|
+
"default": "./lib/index.js"
|
|
141
140
|
},
|
|
142
141
|
"require": {
|
|
143
|
-
"types": "./lib/
|
|
144
|
-
"default": "./lib/
|
|
142
|
+
"types": "./lib/index.d.cts",
|
|
143
|
+
"default": "./lib/index.cjs"
|
|
145
144
|
}
|
|
146
145
|
},
|
|
147
146
|
"./sortByKeys": {
|
|
148
147
|
"import": {
|
|
149
|
-
"types": "./lib/
|
|
150
|
-
"default": "./lib/
|
|
148
|
+
"types": "./lib/index.d.ts",
|
|
149
|
+
"default": "./lib/index.js"
|
|
151
150
|
},
|
|
152
151
|
"require": {
|
|
153
|
-
"types": "./lib/
|
|
154
|
-
"default": "./lib/
|
|
152
|
+
"types": "./lib/index.d.cts",
|
|
153
|
+
"default": "./lib/index.cjs"
|
|
155
154
|
}
|
|
156
155
|
},
|
|
157
156
|
"./sortByValues": {
|
|
158
157
|
"import": {
|
|
159
|
-
"types": "./lib/
|
|
160
|
-
"default": "./lib/
|
|
158
|
+
"types": "./lib/index.d.ts",
|
|
159
|
+
"default": "./lib/index.js"
|
|
161
160
|
},
|
|
162
161
|
"require": {
|
|
163
|
-
"types": "./lib/
|
|
164
|
-
"default": "./lib/
|
|
162
|
+
"types": "./lib/index.d.cts",
|
|
163
|
+
"default": "./lib/index.cjs"
|
|
165
164
|
}
|
|
166
165
|
},
|
|
167
166
|
"./toMap": {
|
|
168
167
|
"import": {
|
|
169
|
-
"types": "./lib/
|
|
170
|
-
"default": "./lib/
|
|
168
|
+
"types": "./lib/index.d.ts",
|
|
169
|
+
"default": "./lib/index.js"
|
|
171
170
|
},
|
|
172
171
|
"require": {
|
|
173
|
-
"types": "./lib/
|
|
174
|
-
"default": "./lib/
|
|
172
|
+
"types": "./lib/index.d.cts",
|
|
173
|
+
"default": "./lib/index.cjs"
|
|
175
174
|
}
|
|
176
175
|
},
|
|
177
176
|
"./valuesArray": {
|
|
178
177
|
"import": {
|
|
179
|
-
"types": "./lib/
|
|
180
|
-
"default": "./lib/
|
|
178
|
+
"types": "./lib/index.d.ts",
|
|
179
|
+
"default": "./lib/index.js"
|
|
181
180
|
},
|
|
182
181
|
"require": {
|
|
183
|
-
"types": "./lib/
|
|
184
|
-
"default": "./lib/
|
|
182
|
+
"types": "./lib/index.d.cts",
|
|
183
|
+
"default": "./lib/index.cjs"
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
186
|
},
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"./lib/index.cjs",
|
|
192
|
-
"./lib/index.d.cts",
|
|
193
|
-
"./lib/ExtMap.js",
|
|
194
|
-
"./lib/ExtMap.d.ts",
|
|
195
|
-
"./lib/ExtMap.cjs",
|
|
196
|
-
"./lib/ExtMap.d.cts",
|
|
197
|
-
"./lib/TimeoutWeakMap.js",
|
|
198
|
-
"./lib/TimeoutWeakMap.d.ts",
|
|
199
|
-
"./lib/TimeoutWeakMap.cjs",
|
|
200
|
-
"./lib/TimeoutWeakMap.d.cts",
|
|
201
|
-
"./lib/countUniques.js",
|
|
202
|
-
"./lib/countUniques.d.ts",
|
|
203
|
-
"./lib/countUniques.cjs",
|
|
204
|
-
"./lib/countUniques.d.cts",
|
|
205
|
-
"./lib/entriesArray.js",
|
|
206
|
-
"./lib/entriesArray.d.ts",
|
|
207
|
-
"./lib/entriesArray.cjs",
|
|
208
|
-
"./lib/entriesArray.d.cts",
|
|
209
|
-
"./lib/isGenericMap.js",
|
|
210
|
-
"./lib/isGenericMap.d.ts",
|
|
211
|
-
"./lib/isGenericMap.cjs",
|
|
212
|
-
"./lib/isGenericMap.d.cts",
|
|
213
|
-
"./lib/keysArray.js",
|
|
214
|
-
"./lib/keysArray.d.ts",
|
|
215
|
-
"./lib/keysArray.cjs",
|
|
216
|
-
"./lib/keysArray.d.cts",
|
|
217
|
-
"./lib/mapGetOrDefault.js",
|
|
218
|
-
"./lib/mapGetOrDefault.d.ts",
|
|
219
|
-
"./lib/mapGetOrDefault.cjs",
|
|
220
|
-
"./lib/mapGetOrDefault.d.cts",
|
|
221
|
-
"./lib/mapLoad.js",
|
|
222
|
-
"./lib/mapLoad.d.ts",
|
|
223
|
-
"./lib/mapLoad.cjs",
|
|
224
|
-
"./lib/mapLoad.d.cts",
|
|
225
|
-
"./lib/mapReverse.js",
|
|
226
|
-
"./lib/mapReverse.d.ts",
|
|
227
|
-
"./lib/mapReverse.cjs",
|
|
228
|
-
"./lib/mapReverse.d.cts",
|
|
229
|
-
"./lib/mapUpdate.js",
|
|
230
|
-
"./lib/mapUpdate.d.ts",
|
|
231
|
-
"./lib/mapUpdate.cjs",
|
|
232
|
-
"./lib/mapUpdate.d.cts",
|
|
233
|
-
"./lib/sort.js",
|
|
234
|
-
"./lib/sort.d.ts",
|
|
235
|
-
"./lib/sort.cjs",
|
|
236
|
-
"./lib/sort.d.cts",
|
|
237
|
-
"./lib/sortByKeys.js",
|
|
238
|
-
"./lib/sortByKeys.d.ts",
|
|
239
|
-
"./lib/sortByKeys.cjs",
|
|
240
|
-
"./lib/sortByKeys.d.cts",
|
|
241
|
-
"./lib/sortByValues.js",
|
|
242
|
-
"./lib/sortByValues.d.ts",
|
|
243
|
-
"./lib/sortByValues.cjs",
|
|
244
|
-
"./lib/sortByValues.d.cts",
|
|
245
|
-
"./lib/toMap.js",
|
|
246
|
-
"./lib/toMap.d.ts",
|
|
247
|
-
"./lib/toMap.cjs",
|
|
248
|
-
"./lib/toMap.d.cts",
|
|
249
|
-
"./lib/valuesArray.js",
|
|
250
|
-
"./lib/valuesArray.d.ts",
|
|
251
|
-
"./lib/valuesArray.cjs",
|
|
252
|
-
"./lib/valuesArray.d.cts"
|
|
253
|
-
],
|
|
254
|
-
"repository": {
|
|
255
|
-
"type": "git",
|
|
256
|
-
"url": "git+https://github.com/bemoje/mono.git",
|
|
257
|
-
"directory": "libs/map"
|
|
187
|
+
"dependencies": {
|
|
188
|
+
"iter-tools": "^7.5.4",
|
|
189
|
+
"mnemonist": "^0.40.3"
|
|
258
190
|
},
|
|
191
|
+
"publishConfig": {
|
|
192
|
+
"access": "public"
|
|
193
|
+
},
|
|
194
|
+
"license": "MIT",
|
|
259
195
|
"author": {
|
|
260
196
|
"name": "Benjamin Møller Jensen",
|
|
261
197
|
"email": "bemoje@bemoje.net",
|
|
262
198
|
"url": "https://github.com/bemoje/"
|
|
263
199
|
},
|
|
264
|
-
"
|
|
200
|
+
"repository": {
|
|
201
|
+
"type": "git",
|
|
202
|
+
"url": "git+https://github.com/bemoje/mono.git",
|
|
203
|
+
"directory": "libs/map"
|
|
204
|
+
}
|
|
265
205
|
}
|
package/lib/ExtMap.cjs
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var composition = require('@mono/composition');
|
|
4
|
-
var defineMethod = require('@mono/object/defineMethod');
|
|
5
|
-
var entriesArray = require('./entriesArray');
|
|
6
|
-
var entriesOf = require('@mono/object/entriesOf');
|
|
7
|
-
var filterIterableValues = require('@mono/iter/filterIterableValues');
|
|
8
|
-
var util = require('util');
|
|
9
|
-
var iterTools = require('iter-tools');
|
|
10
|
-
var keysArray = require('./keysArray');
|
|
11
|
-
var mapGetOrDefault = require('./mapGetOrDefault');
|
|
12
|
-
var mapIterableKeys = require('@mono/iter/mapIterableKeys');
|
|
13
|
-
var mapIterableValues = require('@mono/iter/mapIterableValues');
|
|
14
|
-
var mapLoad = require('./mapLoad');
|
|
15
|
-
var mapReverse = require('./mapReverse');
|
|
16
|
-
var mapUpdate = require('./mapUpdate');
|
|
17
|
-
var reduceIterableValues = require('@mono/iter/reduceIterableValues');
|
|
18
|
-
var sort = require('./sort');
|
|
19
|
-
var sortByKeys = require('./sortByKeys');
|
|
20
|
-
var sortByValues = require('./sortByValues');
|
|
21
|
-
var thisify = require('@mono/fn/thisify');
|
|
22
|
-
var toMap = require('./toMap');
|
|
23
|
-
var toObjectIterable = require('@mono/iter/toObjectIterable');
|
|
24
|
-
var transformReturnValue = require('@mono/fn/transformReturnValue');
|
|
25
|
-
var valuesArray = require('./valuesArray');
|
|
26
|
-
|
|
27
|
-
var __defProp = Object.defineProperty;
|
|
28
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
29
|
-
class ExtMap extends composition.View {
|
|
30
|
-
static {
|
|
31
|
-
__name(this, "ExtMap");
|
|
32
|
-
}
|
|
33
|
-
constructor(arg) {
|
|
34
|
-
super(new Map(iterTools.isIterable(arg) ? arg : arg ? entriesOf.entriesOf(arg) : void 0));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Creates a new ExtMap instance from a regular object.
|
|
38
|
-
*
|
|
39
|
-
* @param obj - An object whose key-value pairs will be used to initialize the map
|
|
40
|
-
* @returns A new ExtMap instance containing the entries from the object
|
|
41
|
-
*/
|
|
42
|
-
static fromObject(obj) {
|
|
43
|
-
return new ExtMap(Object.entries(obj));
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a new ExtMap instance from an iterable of key-value pairs.
|
|
47
|
-
*
|
|
48
|
-
* @param entries - An iterable of key-value pairs to initialize the map
|
|
49
|
-
* @returns A new ExtMap instance containing the provided entries
|
|
50
|
-
*/
|
|
51
|
-
static fromIterable(entries) {
|
|
52
|
-
return new ExtMap(entries);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Creates a shallow copy of the map.
|
|
56
|
-
*
|
|
57
|
-
* @returns A new ExtMap instance with the same entries
|
|
58
|
-
*/
|
|
59
|
-
clone() {
|
|
60
|
-
return new ExtMap(this);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Converts the map to a JSON-serializable format.
|
|
64
|
-
*
|
|
65
|
-
* @returns Array of key-value pairs suitable for JSON serialization
|
|
66
|
-
*/
|
|
67
|
-
toJSON() {
|
|
68
|
-
return [
|
|
69
|
-
...this.entries()
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Custom inspection method for better debugging output.
|
|
74
|
-
*
|
|
75
|
-
* @param _depth - The depth of inspection
|
|
76
|
-
* @param _options - Options for inspection
|
|
77
|
-
* @returns A string representation of the map
|
|
78
|
-
*/
|
|
79
|
-
[util.inspect.custom](_depth, _options) {
|
|
80
|
-
return util.inspect(this.target, {
|
|
81
|
-
breakLength: 50
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
composition.inheritProxifiedPrototype(ExtMap, Map, []);
|
|
86
|
-
defineMethod.defineMethod(ExtMap.prototype, "load", thisify.thisify(mapLoad.mapLoad));
|
|
87
|
-
defineMethod.defineMethod(ExtMap.prototype, "sort", thisify.thisify(sort.sort));
|
|
88
|
-
defineMethod.defineMethod(ExtMap.prototype, "sortByKeys", thisify.thisify(sortByKeys.sortByKeys));
|
|
89
|
-
defineMethod.defineMethod(ExtMap.prototype, "sortByValues", thisify.thisify(sortByValues.sortByValues));
|
|
90
|
-
defineMethod.defineMethod(ExtMap.prototype, "reverse", thisify.thisify(mapReverse.mapReverse));
|
|
91
|
-
defineMethod.defineMethod(ExtMap.prototype, "update", thisify.thisify(mapUpdate.mapUpdate));
|
|
92
|
-
defineMethod.defineMethod(ExtMap.prototype, "getOrDefault", thisify.thisify(mapGetOrDefault.mapGetOrDefault));
|
|
93
|
-
defineMethod.defineMethod(ExtMap.prototype, "keysArray", thisify.thisify(keysArray.keysArray));
|
|
94
|
-
defineMethod.defineMethod(ExtMap.prototype, "valuesArray", thisify.thisify(valuesArray.valuesArray));
|
|
95
|
-
defineMethod.defineMethod(ExtMap.prototype, "entriesArray", thisify.thisify(entriesArray.entriesArray));
|
|
96
|
-
defineMethod.defineMethod(ExtMap.prototype, "toObject", thisify.thisify(toObjectIterable.toObjectIterable));
|
|
97
|
-
defineMethod.defineMethod(ExtMap.prototype, "toMap", thisify.thisify(toMap.toMap));
|
|
98
|
-
defineMethod.defineMethod(ExtMap.prototype, "reduce", thisify.thisify(reduceIterableValues.reduceIterableValues));
|
|
99
|
-
defineMethod.defineMethod(ExtMap.prototype, "map", thisify.thisify(transformReturnValue.transformReturnValue(mapIterableValues.mapIterableValues, ExtMap.fromIterable)));
|
|
100
|
-
defineMethod.defineMethod(ExtMap.prototype, "mapKeys", thisify.thisify(transformReturnValue.transformReturnValue(mapIterableKeys.mapIterableKeys, ExtMap.fromIterable)));
|
|
101
|
-
defineMethod.defineMethod(ExtMap.prototype, "mapValues", thisify.thisify(transformReturnValue.transformReturnValue(mapIterableValues.mapIterableValues, ExtMap.fromIterable)));
|
|
102
|
-
defineMethod.defineMethod(ExtMap.prototype, "filter", thisify.thisify(transformReturnValue.transformReturnValue(filterIterableValues.filterIterableValues, ExtMap.fromIterable)));
|
|
103
|
-
|
|
104
|
-
exports.ExtMap = ExtMap;
|
package/lib/ExtMap.d.cts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { inspect, InspectOptions } from 'util';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface for a View that wraps a target object.
|
|
5
|
-
* View methods are redirected to the wrapped object which acts as
|
|
6
|
-
* a surrogate 'this'.
|
|
7
|
-
*
|
|
8
|
-
* To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
|
|
9
|
-
*/
|
|
10
|
-
interface IView<T extends object> {
|
|
11
|
-
readonly target: T;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare const TARGET_SYMBOL: unique symbol;
|
|
15
|
-
/**
|
|
16
|
-
* Base class providing view functionality over a target object using the Composition pattern.
|
|
17
|
-
*/
|
|
18
|
-
declare class View<Target extends object> implements IView<Target> {
|
|
19
|
-
private [TARGET_SYMBOL];
|
|
20
|
-
constructor(target: Target);
|
|
21
|
-
get [Symbol.toStringTag](): string;
|
|
22
|
-
get target(): Target;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare module './ExtMap' {
|
|
26
|
-
interface ExtMap<K = any, V = any> extends Map<K, V> {
|
|
27
|
-
load(entries: Iterable<[K, V]>): this;
|
|
28
|
-
sort(compare: (a: [K, V], b: [K, V]) => number): this;
|
|
29
|
-
sortByKeys(compare: (a: K, b: K) => number): this;
|
|
30
|
-
sortByValues(compare: (a: V, b: V) => number): this;
|
|
31
|
-
reverse(): this;
|
|
32
|
-
update(key: K, update: (value: V | undefined, key: K, map: this) => V): this;
|
|
33
|
-
getOrDefault(key: K, factory: (key: K, map: this) => V): V;
|
|
34
|
-
keysArray(): K[];
|
|
35
|
-
valuesArray(): V[];
|
|
36
|
-
entriesArray(): [K, V][];
|
|
37
|
-
toMap(): Map<K, V>;
|
|
38
|
-
toObject<K extends string, V>(): Record<K, V>;
|
|
39
|
-
toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>;
|
|
40
|
-
reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R;
|
|
41
|
-
map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>;
|
|
42
|
-
mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>;
|
|
43
|
-
mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>;
|
|
44
|
-
filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Minimal Extended Map class focused only on Map-specific utilities.
|
|
49
|
-
*
|
|
50
|
-
* @template K - The type of keys in the map
|
|
51
|
-
* @template V - The type of values in the map
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* import { map as iterMap, filter } from 'iter-tools'
|
|
56
|
-
*
|
|
57
|
-
* const extMap = new ExtMap<string, number>()
|
|
58
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
59
|
-
* .update('a', v => (v ?? 0) + 10)
|
|
60
|
-
* .sortByValues((a, b) => a - b)
|
|
61
|
-
*
|
|
62
|
-
* // Use iter-tools for transformations
|
|
63
|
-
* const doubled = new ExtMap<string, number>()
|
|
64
|
-
* .load(iterMap(([k, v]) => [k, v * 2], extMap))
|
|
65
|
-
*
|
|
66
|
-
* // Use iter-tools for filtering
|
|
67
|
-
* const filtered = new ExtMap<string, number>()
|
|
68
|
-
* .load(filter(([k, v]) => v > 5, extMap))
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {
|
|
72
|
-
constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);
|
|
73
|
-
constructor(obj?: Record<Extract<K, PropertyKey>, V>);
|
|
74
|
-
/**
|
|
75
|
-
* Creates a new ExtMap instance from a regular object.
|
|
76
|
-
*
|
|
77
|
-
* @param obj - An object whose key-value pairs will be used to initialize the map
|
|
78
|
-
* @returns A new ExtMap instance containing the entries from the object
|
|
79
|
-
*/
|
|
80
|
-
static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V>;
|
|
81
|
-
/**
|
|
82
|
-
* Creates a new ExtMap instance from an iterable of key-value pairs.
|
|
83
|
-
*
|
|
84
|
-
* @param entries - An iterable of key-value pairs to initialize the map
|
|
85
|
-
* @returns A new ExtMap instance containing the provided entries
|
|
86
|
-
*/
|
|
87
|
-
static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V>;
|
|
88
|
-
/**
|
|
89
|
-
* Creates a shallow copy of the map.
|
|
90
|
-
*
|
|
91
|
-
* @returns A new ExtMap instance with the same entries
|
|
92
|
-
*/
|
|
93
|
-
clone(): ExtMap<K, V>;
|
|
94
|
-
/**
|
|
95
|
-
* Converts the map to a JSON-serializable format.
|
|
96
|
-
*
|
|
97
|
-
* @returns Array of key-value pairs suitable for JSON serialization
|
|
98
|
-
*/
|
|
99
|
-
toJSON(): [K, V][];
|
|
100
|
-
/**
|
|
101
|
-
* Custom inspection method for better debugging output.
|
|
102
|
-
*
|
|
103
|
-
* @param _depth - The depth of inspection
|
|
104
|
-
* @param _options - Options for inspection
|
|
105
|
-
* @returns A string representation of the map
|
|
106
|
-
*/
|
|
107
|
-
[inspect.custom](_depth: number, _options: InspectOptions): string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export { ExtMap };
|
package/lib/ExtMap.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { inspect, InspectOptions } from 'util';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface for a View that wraps a target object.
|
|
5
|
-
* View methods are redirected to the wrapped object which acts as
|
|
6
|
-
* a surrogate 'this'.
|
|
7
|
-
*
|
|
8
|
-
* To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
|
|
9
|
-
*/
|
|
10
|
-
interface IView<T extends object> {
|
|
11
|
-
readonly target: T;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare const TARGET_SYMBOL: unique symbol;
|
|
15
|
-
/**
|
|
16
|
-
* Base class providing view functionality over a target object using the Composition pattern.
|
|
17
|
-
*/
|
|
18
|
-
declare class View<Target extends object> implements IView<Target> {
|
|
19
|
-
private [TARGET_SYMBOL];
|
|
20
|
-
constructor(target: Target);
|
|
21
|
-
get [Symbol.toStringTag](): string;
|
|
22
|
-
get target(): Target;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare module './ExtMap' {
|
|
26
|
-
interface ExtMap<K = any, V = any> extends Map<K, V> {
|
|
27
|
-
load(entries: Iterable<[K, V]>): this;
|
|
28
|
-
sort(compare: (a: [K, V], b: [K, V]) => number): this;
|
|
29
|
-
sortByKeys(compare: (a: K, b: K) => number): this;
|
|
30
|
-
sortByValues(compare: (a: V, b: V) => number): this;
|
|
31
|
-
reverse(): this;
|
|
32
|
-
update(key: K, update: (value: V | undefined, key: K, map: this) => V): this;
|
|
33
|
-
getOrDefault(key: K, factory: (key: K, map: this) => V): V;
|
|
34
|
-
keysArray(): K[];
|
|
35
|
-
valuesArray(): V[];
|
|
36
|
-
entriesArray(): [K, V][];
|
|
37
|
-
toMap(): Map<K, V>;
|
|
38
|
-
toObject<K extends string, V>(): Record<K, V>;
|
|
39
|
-
toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>;
|
|
40
|
-
reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R;
|
|
41
|
-
map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>;
|
|
42
|
-
mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>;
|
|
43
|
-
mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>;
|
|
44
|
-
filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Minimal Extended Map class focused only on Map-specific utilities.
|
|
49
|
-
*
|
|
50
|
-
* @template K - The type of keys in the map
|
|
51
|
-
* @template V - The type of values in the map
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* import { map as iterMap, filter } from 'iter-tools'
|
|
56
|
-
*
|
|
57
|
-
* const extMap = new ExtMap<string, number>()
|
|
58
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
59
|
-
* .update('a', v => (v ?? 0) + 10)
|
|
60
|
-
* .sortByValues((a, b) => a - b)
|
|
61
|
-
*
|
|
62
|
-
* // Use iter-tools for transformations
|
|
63
|
-
* const doubled = new ExtMap<string, number>()
|
|
64
|
-
* .load(iterMap(([k, v]) => [k, v * 2], extMap))
|
|
65
|
-
*
|
|
66
|
-
* // Use iter-tools for filtering
|
|
67
|
-
* const filtered = new ExtMap<string, number>()
|
|
68
|
-
* .load(filter(([k, v]) => v > 5, extMap))
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {
|
|
72
|
-
constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);
|
|
73
|
-
constructor(obj?: Record<Extract<K, PropertyKey>, V>);
|
|
74
|
-
/**
|
|
75
|
-
* Creates a new ExtMap instance from a regular object.
|
|
76
|
-
*
|
|
77
|
-
* @param obj - An object whose key-value pairs will be used to initialize the map
|
|
78
|
-
* @returns A new ExtMap instance containing the entries from the object
|
|
79
|
-
*/
|
|
80
|
-
static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V>;
|
|
81
|
-
/**
|
|
82
|
-
* Creates a new ExtMap instance from an iterable of key-value pairs.
|
|
83
|
-
*
|
|
84
|
-
* @param entries - An iterable of key-value pairs to initialize the map
|
|
85
|
-
* @returns A new ExtMap instance containing the provided entries
|
|
86
|
-
*/
|
|
87
|
-
static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V>;
|
|
88
|
-
/**
|
|
89
|
-
* Creates a shallow copy of the map.
|
|
90
|
-
*
|
|
91
|
-
* @returns A new ExtMap instance with the same entries
|
|
92
|
-
*/
|
|
93
|
-
clone(): ExtMap<K, V>;
|
|
94
|
-
/**
|
|
95
|
-
* Converts the map to a JSON-serializable format.
|
|
96
|
-
*
|
|
97
|
-
* @returns Array of key-value pairs suitable for JSON serialization
|
|
98
|
-
*/
|
|
99
|
-
toJSON(): [K, V][];
|
|
100
|
-
/**
|
|
101
|
-
* Custom inspection method for better debugging output.
|
|
102
|
-
*
|
|
103
|
-
* @param _depth - The depth of inspection
|
|
104
|
-
* @param _options - Options for inspection
|
|
105
|
-
* @returns A string representation of the map
|
|
106
|
-
*/
|
|
107
|
-
[inspect.custom](_depth: number, _options: InspectOptions): string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export { ExtMap };
|