@bemoje/map 2.0.0 → 2.1.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.
- package/lib/index.cjs +121 -54
- package/lib/index.js +103 -36
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var defineMethod = require('@mono/object/defineMethod');
|
|
4
|
-
var entriesOf = require('@mono/object/entriesOf');
|
|
5
|
-
var filterIterableValues = require('@mono/iter/filterIterableValues');
|
|
6
|
-
var util = require('util');
|
|
7
3
|
var iterTools = require('iter-tools');
|
|
8
|
-
var
|
|
9
|
-
var mapIterableValues = require('@mono/iter/mapIterableValues');
|
|
10
|
-
var reduceIterableValues = require('@mono/iter/reduceIterableValues');
|
|
11
|
-
var thisify = require('@mono/fn/thisify');
|
|
12
|
-
var toObjectIterable = require('@mono/iter/toObjectIterable');
|
|
13
|
-
var transformReturnValue = require('@mono/fn/transformReturnValue');
|
|
4
|
+
var util = require('util');
|
|
14
5
|
var mnemonist = require('mnemonist');
|
|
15
6
|
|
|
16
7
|
var __defProp = Object.defineProperty;
|
|
17
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
18
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
|
+
|
|
19
28
|
// ../composition/src/View.ts
|
|
20
29
|
var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
|
|
21
30
|
var View = class {
|
|
@@ -77,13 +86,7 @@ __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
|
|
|
77
86
|
|
|
78
87
|
// ../composition/src/inheritProxifiedPrototype.ts
|
|
79
88
|
function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
|
|
80
|
-
Reflect.ownKeys(TargetClass.prototype).filter((k) =>
|
|
81
|
-
return k !== "constructor" && k !== Symbol.toStringTag;
|
|
82
|
-
}).filter((k) => {
|
|
83
|
-
return omitKeys ? !omitKeys.includes(k) : true;
|
|
84
|
-
}).forEach((k) => {
|
|
85
|
-
return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
|
|
86
|
-
});
|
|
89
|
+
Reflect.ownKeys(TargetClass.prototype).filter((k) => k !== "constructor" && k !== Symbol.toStringTag).filter((k) => omitKeys ? !omitKeys.includes(k) : true).forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k));
|
|
87
90
|
return ViewerClass;
|
|
88
91
|
}
|
|
89
92
|
__name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
|
|
@@ -93,6 +96,48 @@ function entriesArray(ins) {
|
|
|
93
96
|
return Array.from(ins);
|
|
94
97
|
}
|
|
95
98
|
__name(entriesArray, "entriesArray");
|
|
99
|
+
function filterIterableValues(mapLike, predicate) {
|
|
100
|
+
return iterTools.filter(([k, v]) => predicate(v, k), mapLike);
|
|
101
|
+
}
|
|
102
|
+
__name(filterIterableValues, "filterIterableValues");
|
|
103
|
+
function mapIterableKeys(mapLike, mapper) {
|
|
104
|
+
return iterTools.map(([k, v]) => [
|
|
105
|
+
mapper(k, v),
|
|
106
|
+
v
|
|
107
|
+
], mapLike);
|
|
108
|
+
}
|
|
109
|
+
__name(mapIterableKeys, "mapIterableKeys");
|
|
110
|
+
function mapIterableValues(mapLike, mapper) {
|
|
111
|
+
return iterTools.map(([k, v]) => [
|
|
112
|
+
k,
|
|
113
|
+
mapper(v, k)
|
|
114
|
+
], mapLike);
|
|
115
|
+
}
|
|
116
|
+
__name(mapIterableValues, "mapIterableValues");
|
|
117
|
+
|
|
118
|
+
// ../iter/src/reduceIterableValues.ts
|
|
119
|
+
function reduceIterableValues(mapLike, reducer, initial) {
|
|
120
|
+
let accumulator = initial;
|
|
121
|
+
for (const [k, v] of mapLike) {
|
|
122
|
+
accumulator = reducer(accumulator, v, k);
|
|
123
|
+
}
|
|
124
|
+
return accumulator;
|
|
125
|
+
}
|
|
126
|
+
__name(reduceIterableValues, "reduceIterableValues");
|
|
127
|
+
|
|
128
|
+
// ../iter/src/toObjectIterable.ts
|
|
129
|
+
function toObjectIterable(mapLike) {
|
|
130
|
+
const object = {};
|
|
131
|
+
for (const [key, value] of mapLike) {
|
|
132
|
+
if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
|
|
133
|
+
object[String(key)] = value;
|
|
134
|
+
} else {
|
|
135
|
+
object[key] = value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return object;
|
|
139
|
+
}
|
|
140
|
+
__name(toObjectIterable, "toObjectIterable");
|
|
96
141
|
|
|
97
142
|
// src/keysArray.ts
|
|
98
143
|
function keysArray(ins) {
|
|
@@ -101,13 +146,13 @@ function keysArray(ins) {
|
|
|
101
146
|
__name(keysArray, "keysArray");
|
|
102
147
|
|
|
103
148
|
// src/mapGetOrDefault.ts
|
|
104
|
-
function mapGetOrDefault(
|
|
105
|
-
let value =
|
|
106
|
-
if (value !== void 0 ||
|
|
149
|
+
function mapGetOrDefault(map3, key, factory) {
|
|
150
|
+
let value = map3.get(key);
|
|
151
|
+
if (value !== void 0 || map3.has(key)) {
|
|
107
152
|
return value;
|
|
108
153
|
}
|
|
109
|
-
value = factory(key,
|
|
110
|
-
|
|
154
|
+
value = factory(key, map3);
|
|
155
|
+
map3.set(key, value);
|
|
111
156
|
return value;
|
|
112
157
|
}
|
|
113
158
|
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
@@ -151,9 +196,7 @@ __name(sort, "sort");
|
|
|
151
196
|
|
|
152
197
|
// src/sortByKeys.ts
|
|
153
198
|
function sortByKeys(ins, compare) {
|
|
154
|
-
const entries = Array.from(ins).sort((a, b) =>
|
|
155
|
-
return compare(a[0], b[0]);
|
|
156
|
-
});
|
|
199
|
+
const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]));
|
|
157
200
|
ins.clear();
|
|
158
201
|
for (const [k, v] of entries) {
|
|
159
202
|
ins.set(k, v);
|
|
@@ -164,9 +207,7 @@ __name(sortByKeys, "sortByKeys");
|
|
|
164
207
|
|
|
165
208
|
// src/sortByValues.ts
|
|
166
209
|
function sortByValues(ins, compare) {
|
|
167
|
-
const entries = Array.from(ins).sort((a, b) =>
|
|
168
|
-
return compare(a[1], b[1]);
|
|
169
|
-
});
|
|
210
|
+
const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]));
|
|
170
211
|
ins.clear();
|
|
171
212
|
for (const [k, v] of entries) {
|
|
172
213
|
ins.set(k, v);
|
|
@@ -175,6 +216,38 @@ function sortByValues(ins, compare) {
|
|
|
175
216
|
}
|
|
176
217
|
__name(sortByValues, "sortByValues");
|
|
177
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
|
+
// ../fn/src/transformReturnValue.ts
|
|
243
|
+
function transformReturnValue(fn, transform) {
|
|
244
|
+
return setNameAndLength(fn, function(...args) {
|
|
245
|
+
const result = fn.apply(this, args);
|
|
246
|
+
return transform(result);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
__name(transformReturnValue, "transformReturnValue");
|
|
250
|
+
|
|
178
251
|
// src/toMap.ts
|
|
179
252
|
function toMap(ins) {
|
|
180
253
|
return new Map(ins);
|
|
@@ -193,7 +266,7 @@ var ExtMap = class _ExtMap extends View {
|
|
|
193
266
|
__name(this, "ExtMap");
|
|
194
267
|
}
|
|
195
268
|
constructor(arg) {
|
|
196
|
-
super(new Map(iterTools.isIterable(arg) ? arg : arg ? entriesOf
|
|
269
|
+
super(new Map(iterTools.isIterable(arg) ? arg : arg ? entriesOf(arg) : void 0));
|
|
197
270
|
}
|
|
198
271
|
/**
|
|
199
272
|
* Creates a new ExtMap instance from a regular object.
|
|
@@ -245,23 +318,23 @@ var ExtMap = class _ExtMap extends View {
|
|
|
245
318
|
}
|
|
246
319
|
};
|
|
247
320
|
inheritProxifiedPrototype(ExtMap, Map, []);
|
|
248
|
-
defineMethod
|
|
249
|
-
defineMethod
|
|
250
|
-
defineMethod
|
|
251
|
-
defineMethod
|
|
252
|
-
defineMethod
|
|
253
|
-
defineMethod
|
|
254
|
-
defineMethod
|
|
255
|
-
defineMethod
|
|
256
|
-
defineMethod
|
|
257
|
-
defineMethod
|
|
258
|
-
defineMethod
|
|
259
|
-
defineMethod
|
|
260
|
-
defineMethod
|
|
261
|
-
defineMethod
|
|
262
|
-
defineMethod
|
|
263
|
-
defineMethod
|
|
264
|
-
defineMethod
|
|
321
|
+
defineMethod(ExtMap.prototype, "load", thisify(mapLoad));
|
|
322
|
+
defineMethod(ExtMap.prototype, "sort", thisify(sort));
|
|
323
|
+
defineMethod(ExtMap.prototype, "sortByKeys", thisify(sortByKeys));
|
|
324
|
+
defineMethod(ExtMap.prototype, "sortByValues", thisify(sortByValues));
|
|
325
|
+
defineMethod(ExtMap.prototype, "reverse", thisify(mapReverse));
|
|
326
|
+
defineMethod(ExtMap.prototype, "update", thisify(mapUpdate));
|
|
327
|
+
defineMethod(ExtMap.prototype, "getOrDefault", thisify(mapGetOrDefault));
|
|
328
|
+
defineMethod(ExtMap.prototype, "keysArray", thisify(keysArray));
|
|
329
|
+
defineMethod(ExtMap.prototype, "valuesArray", thisify(valuesArray));
|
|
330
|
+
defineMethod(ExtMap.prototype, "entriesArray", thisify(entriesArray));
|
|
331
|
+
defineMethod(ExtMap.prototype, "toObject", thisify(toObjectIterable));
|
|
332
|
+
defineMethod(ExtMap.prototype, "toMap", thisify(toMap));
|
|
333
|
+
defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableValues));
|
|
334
|
+
defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
|
|
335
|
+
defineMethod(ExtMap.prototype, "mapKeys", thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)));
|
|
336
|
+
defineMethod(ExtMap.prototype, "mapValues", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
|
|
337
|
+
defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)));
|
|
265
338
|
|
|
266
339
|
// src/TimeoutWeakMap.ts
|
|
267
340
|
var TimeoutWeakMap = class {
|
|
@@ -379,11 +452,7 @@ var TimeoutWeakMap = class {
|
|
|
379
452
|
}
|
|
380
453
|
};
|
|
381
454
|
function countUniques(input) {
|
|
382
|
-
return new ExtMap(iterTools.reduce(new mnemonist.MultiSet(), (acc, imp) =>
|
|
383
|
-
return acc.add(imp);
|
|
384
|
-
}, input).multiplicities()).sortByValues((a, b) => {
|
|
385
|
-
return b - a;
|
|
386
|
-
});
|
|
455
|
+
return new ExtMap(iterTools.reduce(new mnemonist.MultiSet(), (acc, imp) => acc.add(imp), input).multiplicities()).sortByValues((a, b) => b - a);
|
|
387
456
|
}
|
|
388
457
|
__name(countUniques, "countUniques");
|
|
389
458
|
|
|
@@ -393,9 +462,7 @@ function isGenericMap(target, requiredProps = [
|
|
|
393
462
|
"set",
|
|
394
463
|
"has"
|
|
395
464
|
]) {
|
|
396
|
-
return !!target && requiredProps.every((prop) =>
|
|
397
|
-
return typeof target[prop] === typeof Map.prototype[prop];
|
|
398
|
-
});
|
|
465
|
+
return !!target && requiredProps.every((prop) => typeof target[prop] === typeof Map.prototype[prop]);
|
|
399
466
|
}
|
|
400
467
|
__name(isGenericMap, "isGenericMap");
|
|
401
468
|
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { entriesOf } from '@mono/object/entriesOf';
|
|
3
|
-
import { filterIterableValues } from '@mono/iter/filterIterableValues';
|
|
1
|
+
import { isIterable, map, filter, reduce } from 'iter-tools';
|
|
4
2
|
import { inspect } from 'util';
|
|
5
|
-
import { isIterable, reduce } from 'iter-tools';
|
|
6
|
-
import { mapIterableKeys } from '@mono/iter/mapIterableKeys';
|
|
7
|
-
import { mapIterableValues } from '@mono/iter/mapIterableValues';
|
|
8
|
-
import { reduceIterableValues } from '@mono/iter/reduceIterableValues';
|
|
9
|
-
import { thisify } from '@mono/fn/thisify';
|
|
10
|
-
import { toObjectIterable } from '@mono/iter/toObjectIterable';
|
|
11
|
-
import { transformReturnValue } from '@mono/fn/transformReturnValue';
|
|
12
3
|
import { MultiSet } from 'mnemonist';
|
|
13
4
|
|
|
14
5
|
var __defProp = Object.defineProperty;
|
|
15
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
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
|
+
|
|
17
26
|
// ../composition/src/View.ts
|
|
18
27
|
var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
|
|
19
28
|
var View = class {
|
|
@@ -75,13 +84,7 @@ __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
|
|
|
75
84
|
|
|
76
85
|
// ../composition/src/inheritProxifiedPrototype.ts
|
|
77
86
|
function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
|
|
78
|
-
Reflect.ownKeys(TargetClass.prototype).filter((k) =>
|
|
79
|
-
return k !== "constructor" && k !== Symbol.toStringTag;
|
|
80
|
-
}).filter((k) => {
|
|
81
|
-
return omitKeys ? !omitKeys.includes(k) : true;
|
|
82
|
-
}).forEach((k) => {
|
|
83
|
-
return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
|
|
84
|
-
});
|
|
87
|
+
Reflect.ownKeys(TargetClass.prototype).filter((k) => k !== "constructor" && k !== Symbol.toStringTag).filter((k) => omitKeys ? !omitKeys.includes(k) : true).forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k));
|
|
85
88
|
return ViewerClass;
|
|
86
89
|
}
|
|
87
90
|
__name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
|
|
@@ -91,6 +94,48 @@ function entriesArray(ins) {
|
|
|
91
94
|
return Array.from(ins);
|
|
92
95
|
}
|
|
93
96
|
__name(entriesArray, "entriesArray");
|
|
97
|
+
function filterIterableValues(mapLike, predicate) {
|
|
98
|
+
return filter(([k, v]) => predicate(v, k), mapLike);
|
|
99
|
+
}
|
|
100
|
+
__name(filterIterableValues, "filterIterableValues");
|
|
101
|
+
function mapIterableKeys(mapLike, mapper) {
|
|
102
|
+
return map(([k, v]) => [
|
|
103
|
+
mapper(k, v),
|
|
104
|
+
v
|
|
105
|
+
], mapLike);
|
|
106
|
+
}
|
|
107
|
+
__name(mapIterableKeys, "mapIterableKeys");
|
|
108
|
+
function mapIterableValues(mapLike, mapper) {
|
|
109
|
+
return map(([k, v]) => [
|
|
110
|
+
k,
|
|
111
|
+
mapper(v, k)
|
|
112
|
+
], mapLike);
|
|
113
|
+
}
|
|
114
|
+
__name(mapIterableValues, "mapIterableValues");
|
|
115
|
+
|
|
116
|
+
// ../iter/src/reduceIterableValues.ts
|
|
117
|
+
function reduceIterableValues(mapLike, reducer, initial) {
|
|
118
|
+
let accumulator = initial;
|
|
119
|
+
for (const [k, v] of mapLike) {
|
|
120
|
+
accumulator = reducer(accumulator, v, k);
|
|
121
|
+
}
|
|
122
|
+
return accumulator;
|
|
123
|
+
}
|
|
124
|
+
__name(reduceIterableValues, "reduceIterableValues");
|
|
125
|
+
|
|
126
|
+
// ../iter/src/toObjectIterable.ts
|
|
127
|
+
function toObjectIterable(mapLike) {
|
|
128
|
+
const object = {};
|
|
129
|
+
for (const [key, value] of mapLike) {
|
|
130
|
+
if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
|
|
131
|
+
object[String(key)] = value;
|
|
132
|
+
} else {
|
|
133
|
+
object[key] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return object;
|
|
137
|
+
}
|
|
138
|
+
__name(toObjectIterable, "toObjectIterable");
|
|
94
139
|
|
|
95
140
|
// src/keysArray.ts
|
|
96
141
|
function keysArray(ins) {
|
|
@@ -99,13 +144,13 @@ function keysArray(ins) {
|
|
|
99
144
|
__name(keysArray, "keysArray");
|
|
100
145
|
|
|
101
146
|
// src/mapGetOrDefault.ts
|
|
102
|
-
function mapGetOrDefault(
|
|
103
|
-
let value =
|
|
104
|
-
if (value !== void 0 ||
|
|
147
|
+
function mapGetOrDefault(map3, key, factory) {
|
|
148
|
+
let value = map3.get(key);
|
|
149
|
+
if (value !== void 0 || map3.has(key)) {
|
|
105
150
|
return value;
|
|
106
151
|
}
|
|
107
|
-
value = factory(key,
|
|
108
|
-
|
|
152
|
+
value = factory(key, map3);
|
|
153
|
+
map3.set(key, value);
|
|
109
154
|
return value;
|
|
110
155
|
}
|
|
111
156
|
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
@@ -149,9 +194,7 @@ __name(sort, "sort");
|
|
|
149
194
|
|
|
150
195
|
// src/sortByKeys.ts
|
|
151
196
|
function sortByKeys(ins, compare) {
|
|
152
|
-
const entries = Array.from(ins).sort((a, b) =>
|
|
153
|
-
return compare(a[0], b[0]);
|
|
154
|
-
});
|
|
197
|
+
const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]));
|
|
155
198
|
ins.clear();
|
|
156
199
|
for (const [k, v] of entries) {
|
|
157
200
|
ins.set(k, v);
|
|
@@ -162,9 +205,7 @@ __name(sortByKeys, "sortByKeys");
|
|
|
162
205
|
|
|
163
206
|
// src/sortByValues.ts
|
|
164
207
|
function sortByValues(ins, compare) {
|
|
165
|
-
const entries = Array.from(ins).sort((a, b) =>
|
|
166
|
-
return compare(a[1], b[1]);
|
|
167
|
-
});
|
|
208
|
+
const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]));
|
|
168
209
|
ins.clear();
|
|
169
210
|
for (const [k, v] of entries) {
|
|
170
211
|
ins.set(k, v);
|
|
@@ -173,6 +214,38 @@ function sortByValues(ins, compare) {
|
|
|
173
214
|
}
|
|
174
215
|
__name(sortByValues, "sortByValues");
|
|
175
216
|
|
|
217
|
+
// ../fn/src/setNameAndLength.ts
|
|
218
|
+
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
219
|
+
return Object.defineProperties(target, {
|
|
220
|
+
name: {
|
|
221
|
+
configurable: true,
|
|
222
|
+
value: source.name
|
|
223
|
+
},
|
|
224
|
+
length: {
|
|
225
|
+
configurable: true,
|
|
226
|
+
value: source.length + lengthDelta
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
__name(setNameAndLength, "setNameAndLength");
|
|
231
|
+
|
|
232
|
+
// ../fn/src/thisify.ts
|
|
233
|
+
function thisify(fn) {
|
|
234
|
+
return setNameAndLength(fn, /* @__PURE__ */ __name(function f(...args) {
|
|
235
|
+
return fn(this, ...args);
|
|
236
|
+
}, "f"), -1);
|
|
237
|
+
}
|
|
238
|
+
__name(thisify, "thisify");
|
|
239
|
+
|
|
240
|
+
// ../fn/src/transformReturnValue.ts
|
|
241
|
+
function transformReturnValue(fn, transform) {
|
|
242
|
+
return setNameAndLength(fn, function(...args) {
|
|
243
|
+
const result = fn.apply(this, args);
|
|
244
|
+
return transform(result);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
__name(transformReturnValue, "transformReturnValue");
|
|
248
|
+
|
|
176
249
|
// src/toMap.ts
|
|
177
250
|
function toMap(ins) {
|
|
178
251
|
return new Map(ins);
|
|
@@ -377,11 +450,7 @@ var TimeoutWeakMap = class {
|
|
|
377
450
|
}
|
|
378
451
|
};
|
|
379
452
|
function countUniques(input) {
|
|
380
|
-
return new ExtMap(reduce(new MultiSet(), (acc, imp) =>
|
|
381
|
-
return acc.add(imp);
|
|
382
|
-
}, input).multiplicities()).sortByValues((a, b) => {
|
|
383
|
-
return b - a;
|
|
384
|
-
});
|
|
453
|
+
return new ExtMap(reduce(new MultiSet(), (acc, imp) => acc.add(imp), input).multiplicities()).sortByValues((a, b) => b - a);
|
|
385
454
|
}
|
|
386
455
|
__name(countUniques, "countUniques");
|
|
387
456
|
|
|
@@ -391,9 +460,7 @@ function isGenericMap(target, requiredProps = [
|
|
|
391
460
|
"set",
|
|
392
461
|
"has"
|
|
393
462
|
]) {
|
|
394
|
-
return !!target && requiredProps.every((prop) =>
|
|
395
|
-
return typeof target[prop] === typeof Map.prototype[prop];
|
|
396
|
-
});
|
|
463
|
+
return !!target && requiredProps.every((prop) => typeof target[prop] === typeof Map.prototype[prop]);
|
|
397
464
|
}
|
|
398
465
|
__name(isGenericMap, "isGenericMap");
|
|
399
466
|
|