@bemoje/map 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,358 @@
1
1
  'use strict';
2
2
 
3
- var ExtMap = require('./ExtMap');
4
- var mnemonist = require('mnemonist');
5
3
  var iterTools = require('iter-tools');
4
+ var util = require('util');
5
+ var mnemonist = require('mnemonist');
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+
10
+ // ../object/src/defineMethod.ts
11
+ function defineMethod(obj, key, value, des = {}) {
12
+ return Object.defineProperty(obj, key, {
13
+ value,
14
+ configurable: true,
15
+ writable: true,
16
+ enumerable: false,
17
+ ...des
18
+ });
19
+ }
20
+ __name(defineMethod, "defineMethod");
21
+
22
+ // ../object/src/entriesOf.ts
23
+ function entriesOf(obj) {
24
+ return Object.entries(obj);
25
+ }
26
+ __name(entriesOf, "entriesOf");
27
+
28
+ // ../composition/src/View.ts
29
+ var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
30
+ var View = class {
31
+ static {
32
+ __name(this, "View");
33
+ }
34
+ [TARGET_SYMBOL];
35
+ constructor(target) {
36
+ this[TARGET_SYMBOL] = target;
37
+ }
38
+ get [Symbol.toStringTag]() {
39
+ return this.constructor.name;
40
+ }
41
+ get target() {
42
+ return this[TARGET_SYMBOL];
43
+ }
44
+ };
45
+
46
+ // ../composition/src/inheritProxifiedPrototypeProperty.ts
47
+ function inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, key) {
48
+ const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key);
49
+ if (!des) {
50
+ return;
51
+ }
52
+ if (des.value && typeof des.value === "function") {
53
+ return Object.defineProperty(ViewerClass.prototype, key, {
54
+ value(...args) {
55
+ return this.target[key](...args);
56
+ },
57
+ writable: true,
58
+ configurable: true,
59
+ enumerable: false
60
+ });
61
+ } else if (des && !des.get && !des.set) {
62
+ return Object.defineProperty(ViewerClass.prototype, key, {
63
+ get() {
64
+ return this.target[key];
65
+ },
66
+ set: des.writable ? /* @__PURE__ */ __name(function set(value) {
67
+ this.target[key] = value;
68
+ }, "set") : void 0,
69
+ configurable: true,
70
+ enumerable: false
71
+ });
72
+ } else {
73
+ Object.defineProperty(ViewerClass.prototype, key, {
74
+ get: des.get ? function() {
75
+ return this.target[key];
76
+ } : void 0,
77
+ set: des.set ? function(value) {
78
+ this.target[key] = value;
79
+ } : void 0,
80
+ configurable: true,
81
+ enumerable: false
82
+ });
83
+ }
84
+ }
85
+ __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
86
+
87
+ // ../composition/src/inheritProxifiedPrototype.ts
88
+ function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
89
+ Reflect.ownKeys(TargetClass.prototype).filter((k) => {
90
+ return k !== "constructor" && k !== Symbol.toStringTag;
91
+ }).filter((k) => {
92
+ return omitKeys ? !omitKeys.includes(k) : true;
93
+ }).forEach((k) => {
94
+ return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
95
+ });
96
+ return ViewerClass;
97
+ }
98
+ __name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
99
+
100
+ // src/entriesArray.ts
101
+ function entriesArray(ins) {
102
+ return Array.from(ins);
103
+ }
104
+ __name(entriesArray, "entriesArray");
105
+ function filterIterableValues(mapLike, predicate) {
106
+ return iterTools.filter(([k, v]) => {
107
+ return predicate(v, k);
108
+ }, mapLike);
109
+ }
110
+ __name(filterIterableValues, "filterIterableValues");
111
+
112
+ // src/keysArray.ts
113
+ function keysArray(ins) {
114
+ return Array.from(ins.keys());
115
+ }
116
+ __name(keysArray, "keysArray");
117
+
118
+ // src/mapGetOrDefault.ts
119
+ function mapGetOrDefault(map3, key, factory) {
120
+ let value = map3.get(key);
121
+ if (value !== void 0 || map3.has(key)) {
122
+ return value;
123
+ }
124
+ value = factory(key, map3);
125
+ map3.set(key, value);
126
+ return value;
127
+ }
128
+ __name(mapGetOrDefault, "mapGetOrDefault");
129
+ function mapIterableKeys(mapLike, mapper) {
130
+ return iterTools.map(([k, v]) => {
131
+ return [
132
+ mapper(k, v),
133
+ v
134
+ ];
135
+ }, mapLike);
136
+ }
137
+ __name(mapIterableKeys, "mapIterableKeys");
138
+ function mapIterableValues(mapLike, mapper) {
139
+ return iterTools.map(([k, v]) => {
140
+ return [
141
+ k,
142
+ mapper(v, k)
143
+ ];
144
+ }, mapLike);
145
+ }
146
+ __name(mapIterableValues, "mapIterableValues");
147
+
148
+ // src/mapLoad.ts
149
+ function mapLoad(ins, entries) {
150
+ for (const [key, value] of entries) {
151
+ ins.set(key, value);
152
+ }
153
+ return ins;
154
+ }
155
+ __name(mapLoad, "mapLoad");
156
+
157
+ // src/mapReverse.ts
158
+ function mapReverse(ins) {
159
+ const entries = Array.from(ins).reverse();
160
+ ins.clear();
161
+ mapLoad(ins, entries);
162
+ return ins;
163
+ }
164
+ __name(mapReverse, "mapReverse");
165
+
166
+ // src/mapUpdate.ts
167
+ function mapUpdate(ins, key, update) {
168
+ const newValue = update(ins.get(key), key, ins);
169
+ ins.set(key, newValue);
170
+ return ins;
171
+ }
172
+ __name(mapUpdate, "mapUpdate");
173
+
174
+ // ../iter/src/reduceIterableValues.ts
175
+ function reduceIterableValues(mapLike, reducer, initial) {
176
+ let accumulator = initial;
177
+ for (const [k, v] of mapLike) {
178
+ accumulator = reducer(accumulator, v, k);
179
+ }
180
+ return accumulator;
181
+ }
182
+ __name(reduceIterableValues, "reduceIterableValues");
183
+
184
+ // src/sort.ts
185
+ function sort(ins, compare) {
186
+ const entries = Array.from(ins).sort(compare);
187
+ ins.clear();
188
+ for (const [k, v] of entries) {
189
+ ins.set(k, v);
190
+ }
191
+ return ins;
192
+ }
193
+ __name(sort, "sort");
194
+
195
+ // src/sortByKeys.ts
196
+ function sortByKeys(ins, compare) {
197
+ const entries = Array.from(ins).sort((a, b) => {
198
+ return compare(a[0], b[0]);
199
+ });
200
+ ins.clear();
201
+ for (const [k, v] of entries) {
202
+ ins.set(k, v);
203
+ }
204
+ return ins;
205
+ }
206
+ __name(sortByKeys, "sortByKeys");
207
+
208
+ // src/sortByValues.ts
209
+ function sortByValues(ins, compare) {
210
+ const entries = Array.from(ins).sort((a, b) => {
211
+ return compare(a[1], b[1]);
212
+ });
213
+ ins.clear();
214
+ for (const [k, v] of entries) {
215
+ ins.set(k, v);
216
+ }
217
+ return ins;
218
+ }
219
+ __name(sortByValues, "sortByValues");
220
+
221
+ // ../fn/src/setNameAndLength.ts
222
+ function setNameAndLength(source, target, lengthDelta = 0) {
223
+ return Object.defineProperties(target, {
224
+ name: {
225
+ configurable: true,
226
+ value: source.name
227
+ },
228
+ length: {
229
+ configurable: true,
230
+ value: source.length + lengthDelta
231
+ }
232
+ });
233
+ }
234
+ __name(setNameAndLength, "setNameAndLength");
235
+
236
+ // ../fn/src/thisify.ts
237
+ function thisify(fn) {
238
+ return setNameAndLength(fn, /* @__PURE__ */ __name(function f(...args) {
239
+ return fn(this, ...args);
240
+ }, "f"), -1);
241
+ }
242
+ __name(thisify, "thisify");
243
+
244
+ // src/toMap.ts
245
+ function toMap(ins) {
246
+ return new Map(ins);
247
+ }
248
+ __name(toMap, "toMap");
249
+
250
+ // ../iter/src/toObjectIterable.ts
251
+ function toObjectIterable(mapLike) {
252
+ const object = {};
253
+ for (const [key, value] of mapLike) {
254
+ if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
255
+ object[String(key)] = value;
256
+ } else {
257
+ object[key] = value;
258
+ }
259
+ }
260
+ return object;
261
+ }
262
+ __name(toObjectIterable, "toObjectIterable");
263
+
264
+ // ../fn/src/transformReturnValue.ts
265
+ function transformReturnValue(fn, transform) {
266
+ return setNameAndLength(fn, function(...args) {
267
+ const result = fn.apply(this, args);
268
+ return transform(result);
269
+ });
270
+ }
271
+ __name(transformReturnValue, "transformReturnValue");
272
+
273
+ // src/valuesArray.ts
274
+ function valuesArray(ins) {
275
+ return Array.from(ins.values());
276
+ }
277
+ __name(valuesArray, "valuesArray");
278
+
279
+ // src/ExtMap.ts
280
+ var ExtMap = class _ExtMap extends View {
281
+ static {
282
+ __name(this, "ExtMap");
283
+ }
284
+ constructor(arg) {
285
+ super(new Map(iterTools.isIterable(arg) ? arg : arg ? entriesOf(arg) : void 0));
286
+ }
287
+ /**
288
+ * Creates a new ExtMap instance from a regular object.
289
+ *
290
+ * @param obj - An object whose key-value pairs will be used to initialize the map
291
+ * @returns A new ExtMap instance containing the entries from the object
292
+ */
293
+ static fromObject(obj) {
294
+ return new _ExtMap(Object.entries(obj));
295
+ }
296
+ /**
297
+ * Creates a new ExtMap instance from an iterable of key-value pairs.
298
+ *
299
+ * @param entries - An iterable of key-value pairs to initialize the map
300
+ * @returns A new ExtMap instance containing the provided entries
301
+ */
302
+ static fromIterable(entries) {
303
+ return new _ExtMap(entries);
304
+ }
305
+ /**
306
+ * Creates a shallow copy of the map.
307
+ *
308
+ * @returns A new ExtMap instance with the same entries
309
+ */
310
+ clone() {
311
+ return new _ExtMap(this);
312
+ }
313
+ /**
314
+ * Converts the map to a JSON-serializable format.
315
+ *
316
+ * @returns Array of key-value pairs suitable for JSON serialization
317
+ */
318
+ toJSON() {
319
+ return [
320
+ ...this.entries()
321
+ ];
322
+ }
323
+ /**
324
+ * Custom inspection method for better debugging output.
325
+ *
326
+ * @param _depth - The depth of inspection
327
+ * @param _options - Options for inspection
328
+ * @returns A string representation of the map
329
+ */
330
+ [util.inspect.custom](_depth, _options) {
331
+ return util.inspect(this.target, {
332
+ breakLength: 50
333
+ });
334
+ }
335
+ };
336
+ inheritProxifiedPrototype(ExtMap, Map, []);
337
+ defineMethod(ExtMap.prototype, "load", thisify(mapLoad));
338
+ defineMethod(ExtMap.prototype, "sort", thisify(sort));
339
+ defineMethod(ExtMap.prototype, "sortByKeys", thisify(sortByKeys));
340
+ defineMethod(ExtMap.prototype, "sortByValues", thisify(sortByValues));
341
+ defineMethod(ExtMap.prototype, "reverse", thisify(mapReverse));
342
+ defineMethod(ExtMap.prototype, "update", thisify(mapUpdate));
343
+ defineMethod(ExtMap.prototype, "getOrDefault", thisify(mapGetOrDefault));
344
+ defineMethod(ExtMap.prototype, "keysArray", thisify(keysArray));
345
+ defineMethod(ExtMap.prototype, "valuesArray", thisify(valuesArray));
346
+ defineMethod(ExtMap.prototype, "entriesArray", thisify(entriesArray));
347
+ defineMethod(ExtMap.prototype, "toObject", thisify(toObjectIterable));
348
+ defineMethod(ExtMap.prototype, "toMap", thisify(toMap));
349
+ defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableValues));
350
+ defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
351
+ defineMethod(ExtMap.prototype, "mapKeys", thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)));
352
+ defineMethod(ExtMap.prototype, "mapValues", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
353
+ defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)));
9
354
  function countUniques(input) {
10
- return new ExtMap.ExtMap(iterTools.reduce(new mnemonist.MultiSet(), (acc, imp) => {
355
+ return new ExtMap(iterTools.reduce(new mnemonist.MultiSet(), (acc, imp) => {
11
356
  return acc.add(imp);
12
357
  }, input).multiplicities()).sortByValues((a, b) => {
13
358
  return b - a;
@@ -1,8 +1,354 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
- import { ExtMap } from './ExtMap';
1
+ import { isIterable, map, filter, reduce } from 'iter-tools';
2
+ import { inspect } from 'util';
3
3
  import { MultiSet } from 'mnemonist';
4
- import { reduce } from 'iter-tools';
5
4
 
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+
8
+ // ../object/src/defineMethod.ts
9
+ function defineMethod(obj, key, value, des = {}) {
10
+ return Object.defineProperty(obj, key, {
11
+ value,
12
+ configurable: true,
13
+ writable: true,
14
+ enumerable: false,
15
+ ...des
16
+ });
17
+ }
18
+ __name(defineMethod, "defineMethod");
19
+
20
+ // ../object/src/entriesOf.ts
21
+ function entriesOf(obj) {
22
+ return Object.entries(obj);
23
+ }
24
+ __name(entriesOf, "entriesOf");
25
+
26
+ // ../composition/src/View.ts
27
+ var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
28
+ var View = class {
29
+ static {
30
+ __name(this, "View");
31
+ }
32
+ [TARGET_SYMBOL];
33
+ constructor(target) {
34
+ this[TARGET_SYMBOL] = target;
35
+ }
36
+ get [Symbol.toStringTag]() {
37
+ return this.constructor.name;
38
+ }
39
+ get target() {
40
+ return this[TARGET_SYMBOL];
41
+ }
42
+ };
43
+
44
+ // ../composition/src/inheritProxifiedPrototypeProperty.ts
45
+ function inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, key) {
46
+ const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key);
47
+ if (!des) {
48
+ return;
49
+ }
50
+ if (des.value && typeof des.value === "function") {
51
+ return Object.defineProperty(ViewerClass.prototype, key, {
52
+ value(...args) {
53
+ return this.target[key](...args);
54
+ },
55
+ writable: true,
56
+ configurable: true,
57
+ enumerable: false
58
+ });
59
+ } else if (des && !des.get && !des.set) {
60
+ return Object.defineProperty(ViewerClass.prototype, key, {
61
+ get() {
62
+ return this.target[key];
63
+ },
64
+ set: des.writable ? /* @__PURE__ */ __name(function set(value) {
65
+ this.target[key] = value;
66
+ }, "set") : void 0,
67
+ configurable: true,
68
+ enumerable: false
69
+ });
70
+ } else {
71
+ Object.defineProperty(ViewerClass.prototype, key, {
72
+ get: des.get ? function() {
73
+ return this.target[key];
74
+ } : void 0,
75
+ set: des.set ? function(value) {
76
+ this.target[key] = value;
77
+ } : void 0,
78
+ configurable: true,
79
+ enumerable: false
80
+ });
81
+ }
82
+ }
83
+ __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
84
+
85
+ // ../composition/src/inheritProxifiedPrototype.ts
86
+ function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
87
+ Reflect.ownKeys(TargetClass.prototype).filter((k) => {
88
+ return k !== "constructor" && k !== Symbol.toStringTag;
89
+ }).filter((k) => {
90
+ return omitKeys ? !omitKeys.includes(k) : true;
91
+ }).forEach((k) => {
92
+ return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
93
+ });
94
+ return ViewerClass;
95
+ }
96
+ __name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
97
+
98
+ // src/entriesArray.ts
99
+ function entriesArray(ins) {
100
+ return Array.from(ins);
101
+ }
102
+ __name(entriesArray, "entriesArray");
103
+ function filterIterableValues(mapLike, predicate) {
104
+ return filter(([k, v]) => {
105
+ return predicate(v, k);
106
+ }, mapLike);
107
+ }
108
+ __name(filterIterableValues, "filterIterableValues");
109
+
110
+ // src/keysArray.ts
111
+ function keysArray(ins) {
112
+ return Array.from(ins.keys());
113
+ }
114
+ __name(keysArray, "keysArray");
115
+
116
+ // src/mapGetOrDefault.ts
117
+ function mapGetOrDefault(map3, key, factory) {
118
+ let value = map3.get(key);
119
+ if (value !== void 0 || map3.has(key)) {
120
+ return value;
121
+ }
122
+ value = factory(key, map3);
123
+ map3.set(key, value);
124
+ return value;
125
+ }
126
+ __name(mapGetOrDefault, "mapGetOrDefault");
127
+ function mapIterableKeys(mapLike, mapper) {
128
+ return map(([k, v]) => {
129
+ return [
130
+ mapper(k, v),
131
+ v
132
+ ];
133
+ }, mapLike);
134
+ }
135
+ __name(mapIterableKeys, "mapIterableKeys");
136
+ function mapIterableValues(mapLike, mapper) {
137
+ return map(([k, v]) => {
138
+ return [
139
+ k,
140
+ mapper(v, k)
141
+ ];
142
+ }, mapLike);
143
+ }
144
+ __name(mapIterableValues, "mapIterableValues");
145
+
146
+ // src/mapLoad.ts
147
+ function mapLoad(ins, entries) {
148
+ for (const [key, value] of entries) {
149
+ ins.set(key, value);
150
+ }
151
+ return ins;
152
+ }
153
+ __name(mapLoad, "mapLoad");
154
+
155
+ // src/mapReverse.ts
156
+ function mapReverse(ins) {
157
+ const entries = Array.from(ins).reverse();
158
+ ins.clear();
159
+ mapLoad(ins, entries);
160
+ return ins;
161
+ }
162
+ __name(mapReverse, "mapReverse");
163
+
164
+ // src/mapUpdate.ts
165
+ function mapUpdate(ins, key, update) {
166
+ const newValue = update(ins.get(key), key, ins);
167
+ ins.set(key, newValue);
168
+ return ins;
169
+ }
170
+ __name(mapUpdate, "mapUpdate");
171
+
172
+ // ../iter/src/reduceIterableValues.ts
173
+ function reduceIterableValues(mapLike, reducer, initial) {
174
+ let accumulator = initial;
175
+ for (const [k, v] of mapLike) {
176
+ accumulator = reducer(accumulator, v, k);
177
+ }
178
+ return accumulator;
179
+ }
180
+ __name(reduceIterableValues, "reduceIterableValues");
181
+
182
+ // src/sort.ts
183
+ function sort(ins, compare) {
184
+ const entries = Array.from(ins).sort(compare);
185
+ ins.clear();
186
+ for (const [k, v] of entries) {
187
+ ins.set(k, v);
188
+ }
189
+ return ins;
190
+ }
191
+ __name(sort, "sort");
192
+
193
+ // src/sortByKeys.ts
194
+ function sortByKeys(ins, compare) {
195
+ const entries = Array.from(ins).sort((a, b) => {
196
+ return compare(a[0], b[0]);
197
+ });
198
+ ins.clear();
199
+ for (const [k, v] of entries) {
200
+ ins.set(k, v);
201
+ }
202
+ return ins;
203
+ }
204
+ __name(sortByKeys, "sortByKeys");
205
+
206
+ // src/sortByValues.ts
207
+ function sortByValues(ins, compare) {
208
+ const entries = Array.from(ins).sort((a, b) => {
209
+ return compare(a[1], b[1]);
210
+ });
211
+ ins.clear();
212
+ for (const [k, v] of entries) {
213
+ ins.set(k, v);
214
+ }
215
+ return ins;
216
+ }
217
+ __name(sortByValues, "sortByValues");
218
+
219
+ // ../fn/src/setNameAndLength.ts
220
+ function setNameAndLength(source, target, lengthDelta = 0) {
221
+ return Object.defineProperties(target, {
222
+ name: {
223
+ configurable: true,
224
+ value: source.name
225
+ },
226
+ length: {
227
+ configurable: true,
228
+ value: source.length + lengthDelta
229
+ }
230
+ });
231
+ }
232
+ __name(setNameAndLength, "setNameAndLength");
233
+
234
+ // ../fn/src/thisify.ts
235
+ function thisify(fn) {
236
+ return setNameAndLength(fn, /* @__PURE__ */ __name(function f(...args) {
237
+ return fn(this, ...args);
238
+ }, "f"), -1);
239
+ }
240
+ __name(thisify, "thisify");
241
+
242
+ // src/toMap.ts
243
+ function toMap(ins) {
244
+ return new Map(ins);
245
+ }
246
+ __name(toMap, "toMap");
247
+
248
+ // ../iter/src/toObjectIterable.ts
249
+ function toObjectIterable(mapLike) {
250
+ const object = {};
251
+ for (const [key, value] of mapLike) {
252
+ if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
253
+ object[String(key)] = value;
254
+ } else {
255
+ object[key] = value;
256
+ }
257
+ }
258
+ return object;
259
+ }
260
+ __name(toObjectIterable, "toObjectIterable");
261
+
262
+ // ../fn/src/transformReturnValue.ts
263
+ function transformReturnValue(fn, transform) {
264
+ return setNameAndLength(fn, function(...args) {
265
+ const result = fn.apply(this, args);
266
+ return transform(result);
267
+ });
268
+ }
269
+ __name(transformReturnValue, "transformReturnValue");
270
+
271
+ // src/valuesArray.ts
272
+ function valuesArray(ins) {
273
+ return Array.from(ins.values());
274
+ }
275
+ __name(valuesArray, "valuesArray");
276
+
277
+ // src/ExtMap.ts
278
+ var ExtMap = class _ExtMap extends View {
279
+ static {
280
+ __name(this, "ExtMap");
281
+ }
282
+ constructor(arg) {
283
+ super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : void 0));
284
+ }
285
+ /**
286
+ * Creates a new ExtMap instance from a regular object.
287
+ *
288
+ * @param obj - An object whose key-value pairs will be used to initialize the map
289
+ * @returns A new ExtMap instance containing the entries from the object
290
+ */
291
+ static fromObject(obj) {
292
+ return new _ExtMap(Object.entries(obj));
293
+ }
294
+ /**
295
+ * Creates a new ExtMap instance from an iterable of key-value pairs.
296
+ *
297
+ * @param entries - An iterable of key-value pairs to initialize the map
298
+ * @returns A new ExtMap instance containing the provided entries
299
+ */
300
+ static fromIterable(entries) {
301
+ return new _ExtMap(entries);
302
+ }
303
+ /**
304
+ * Creates a shallow copy of the map.
305
+ *
306
+ * @returns A new ExtMap instance with the same entries
307
+ */
308
+ clone() {
309
+ return new _ExtMap(this);
310
+ }
311
+ /**
312
+ * Converts the map to a JSON-serializable format.
313
+ *
314
+ * @returns Array of key-value pairs suitable for JSON serialization
315
+ */
316
+ toJSON() {
317
+ return [
318
+ ...this.entries()
319
+ ];
320
+ }
321
+ /**
322
+ * Custom inspection method for better debugging output.
323
+ *
324
+ * @param _depth - The depth of inspection
325
+ * @param _options - Options for inspection
326
+ * @returns A string representation of the map
327
+ */
328
+ [inspect.custom](_depth, _options) {
329
+ return inspect(this.target, {
330
+ breakLength: 50
331
+ });
332
+ }
333
+ };
334
+ inheritProxifiedPrototype(ExtMap, Map, []);
335
+ defineMethod(ExtMap.prototype, "load", thisify(mapLoad));
336
+ defineMethod(ExtMap.prototype, "sort", thisify(sort));
337
+ defineMethod(ExtMap.prototype, "sortByKeys", thisify(sortByKeys));
338
+ defineMethod(ExtMap.prototype, "sortByValues", thisify(sortByValues));
339
+ defineMethod(ExtMap.prototype, "reverse", thisify(mapReverse));
340
+ defineMethod(ExtMap.prototype, "update", thisify(mapUpdate));
341
+ defineMethod(ExtMap.prototype, "getOrDefault", thisify(mapGetOrDefault));
342
+ defineMethod(ExtMap.prototype, "keysArray", thisify(keysArray));
343
+ defineMethod(ExtMap.prototype, "valuesArray", thisify(valuesArray));
344
+ defineMethod(ExtMap.prototype, "entriesArray", thisify(entriesArray));
345
+ defineMethod(ExtMap.prototype, "toObject", thisify(toObjectIterable));
346
+ defineMethod(ExtMap.prototype, "toMap", thisify(toMap));
347
+ defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableValues));
348
+ defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
349
+ defineMethod(ExtMap.prototype, "mapKeys", thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)));
350
+ defineMethod(ExtMap.prototype, "mapValues", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
351
+ defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)));
6
352
  function countUniques(input) {
7
353
  return new ExtMap(reduce(new MultiSet(), (acc, imp) => {
8
354
  return acc.add(imp);