@softwareventures/array 7.0.0-alpha.1 → 7.0.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/.husky/pre-commit +1 -3
- package/LICENSE.md +1 -1
- package/index.js +181 -184
- package/index.js.map +1 -1
- package/package.json +22 -22
package/index.js
CHANGED
|
@@ -1,9 +1,186 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
3
|
+
exports.map = exports.isArray = exports.copy = void 0;
|
|
4
|
+
exports.isArrayLike = isArrayLike;
|
|
5
|
+
exports.coerce = coerce;
|
|
6
|
+
exports.first = first;
|
|
7
|
+
exports.tail = tail;
|
|
8
|
+
exports.push = push;
|
|
9
|
+
exports.pushFn = pushFn;
|
|
10
|
+
exports.unshift = unshift;
|
|
11
|
+
exports.unshiftFn = unshiftFn;
|
|
12
|
+
exports.initial = initial;
|
|
13
|
+
exports.last = last;
|
|
14
|
+
exports.only = only;
|
|
15
|
+
exports.empty = empty;
|
|
16
|
+
exports.notEmpty = notEmpty;
|
|
17
|
+
exports.reverse = reverse;
|
|
18
|
+
exports.slice = slice;
|
|
19
|
+
exports.sliceFn = sliceFn;
|
|
20
|
+
exports.take = take;
|
|
21
|
+
exports.takeFn = takeFn;
|
|
22
|
+
exports.drop = drop;
|
|
23
|
+
exports.dropFn = dropFn;
|
|
24
|
+
exports.takeWhile = takeWhile;
|
|
25
|
+
exports.takeWhileFn = takeWhileFn;
|
|
26
|
+
exports.takeUntil = takeUntil;
|
|
27
|
+
exports.takeUntilFn = takeUntilFn;
|
|
28
|
+
exports.dropWhile = dropWhile;
|
|
29
|
+
exports.dropWhileFn = dropWhileFn;
|
|
30
|
+
exports.dropUntil = dropUntil;
|
|
31
|
+
exports.dropUntilFn = dropUntilFn;
|
|
32
|
+
exports.equal = equal;
|
|
33
|
+
exports.equalFn = equalFn;
|
|
34
|
+
exports.notEqual = notEqual;
|
|
35
|
+
exports.notEqualFn = notEqualFn;
|
|
36
|
+
exports.prefixMatch = prefixMatch;
|
|
37
|
+
exports.prefixMatchFn = prefixMatchFn;
|
|
38
|
+
exports.mapFn = mapFn;
|
|
39
|
+
exports.filter = filter;
|
|
40
|
+
exports.filterFn = filterFn;
|
|
41
|
+
exports.exclude = exclude;
|
|
42
|
+
exports.excludeFn = excludeFn;
|
|
43
|
+
exports.excludeNull = excludeNull;
|
|
44
|
+
exports.excludeFirst = excludeFirst;
|
|
45
|
+
exports.excludeFirstFn = excludeFirstFn;
|
|
46
|
+
exports.remove = remove;
|
|
47
|
+
exports.removeFn = removeFn;
|
|
48
|
+
exports.removeFirst = removeFirst;
|
|
49
|
+
exports.removeFirstFn = removeFirstFn;
|
|
50
|
+
exports.fold = fold;
|
|
51
|
+
exports.foldFn = foldFn;
|
|
52
|
+
exports.fold1 = fold1;
|
|
53
|
+
exports.fold1Fn = fold1Fn;
|
|
54
|
+
exports.foldRight = foldRight;
|
|
55
|
+
exports.foldRightFn = foldRightFn;
|
|
56
|
+
exports.foldRight1 = foldRight1;
|
|
57
|
+
exports.foldRight1Fn = foldRight1Fn;
|
|
58
|
+
exports.foldMap = foldMap;
|
|
59
|
+
exports.foldMapFn = foldMapFn;
|
|
60
|
+
exports.foldMapRight = foldMapRight;
|
|
61
|
+
exports.foldMapRightFn = foldMapRightFn;
|
|
62
|
+
exports.contains = contains;
|
|
63
|
+
exports.containsFn = containsFn;
|
|
64
|
+
exports.indexOf = indexOf;
|
|
65
|
+
exports.indexOfFn = indexOfFn;
|
|
66
|
+
exports.lastIndexOf = lastIndexOf;
|
|
67
|
+
exports.lastIndexOfFn = lastIndexOfFn;
|
|
68
|
+
exports.findIndex = findIndex;
|
|
69
|
+
exports.findIndexFn = findIndexFn;
|
|
70
|
+
exports.findLastIndex = findLastIndex;
|
|
71
|
+
exports.findLastIndexFn = findLastIndexFn;
|
|
72
|
+
exports.find = find;
|
|
73
|
+
exports.findFn = findFn;
|
|
74
|
+
exports.findLast = findLast;
|
|
75
|
+
exports.findLastFn = findLastFn;
|
|
76
|
+
exports.maximum = maximum;
|
|
77
|
+
exports.maximumFn = maximumFn;
|
|
78
|
+
exports.maximumBy = maximumBy;
|
|
79
|
+
exports.maximumByFn = maximumByFn;
|
|
80
|
+
exports.minimum = minimum;
|
|
81
|
+
exports.minimumFn = minimumFn;
|
|
82
|
+
exports.minimumBy = minimumBy;
|
|
83
|
+
exports.minimumByFn = minimumByFn;
|
|
84
|
+
exports.sum = sum;
|
|
85
|
+
exports.product = product;
|
|
86
|
+
exports.average = average;
|
|
87
|
+
exports.and = and;
|
|
88
|
+
exports.or = or;
|
|
89
|
+
exports.any = any;
|
|
90
|
+
exports.anyFn = anyFn;
|
|
91
|
+
exports.all = all;
|
|
92
|
+
exports.allFn = allFn;
|
|
93
|
+
exports.concat = concat;
|
|
94
|
+
exports.prepend = prepend;
|
|
95
|
+
exports.append = append;
|
|
96
|
+
exports.concatMap = concatMap;
|
|
97
|
+
exports.concatMapFn = concatMapFn;
|
|
98
|
+
exports.noneNull = noneNull;
|
|
99
|
+
exports.scan = scan;
|
|
100
|
+
exports.scanFn = scanFn;
|
|
101
|
+
exports.scan1 = scan1;
|
|
102
|
+
exports.scan1Fn = scan1Fn;
|
|
103
|
+
exports.scanRight = scanRight;
|
|
104
|
+
exports.scanRightFn = scanRightFn;
|
|
105
|
+
exports.scanRight1 = scanRight1;
|
|
106
|
+
exports.scanRight1Fn = scanRight1Fn;
|
|
107
|
+
exports.split = split;
|
|
108
|
+
exports.splitFn = splitFn;
|
|
109
|
+
exports.partition = partition;
|
|
110
|
+
exports.partitionFn = partitionFn;
|
|
111
|
+
exports.partitionWhile = partitionWhile;
|
|
112
|
+
exports.partitionWhileFn = partitionWhileFn;
|
|
113
|
+
exports.partitionUntil = partitionUntil;
|
|
114
|
+
exports.partitionUntilFn = partitionUntilFn;
|
|
115
|
+
exports.zip = zip;
|
|
116
|
+
exports.zipFn = zipFn;
|
|
117
|
+
exports.keyBy = keyBy;
|
|
118
|
+
exports.keyByFn = keyByFn;
|
|
119
|
+
exports.keyFirstBy = keyFirstBy;
|
|
120
|
+
exports.keyFirstByFn = keyFirstByFn;
|
|
121
|
+
exports.keyLastBy = keyLastBy;
|
|
122
|
+
exports.keyLastByFn = keyLastByFn;
|
|
123
|
+
exports.mapKeyBy = mapKeyBy;
|
|
124
|
+
exports.mapKeyByFn = mapKeyByFn;
|
|
125
|
+
exports.mapKeyFirstBy = mapKeyFirstBy;
|
|
126
|
+
exports.mapKeyFirstByFn = mapKeyFirstByFn;
|
|
127
|
+
exports.mapKeyLastBy = mapKeyLastBy;
|
|
128
|
+
exports.mapKeyLastByFn = mapKeyLastByFn;
|
|
129
|
+
exports.group = group;
|
|
130
|
+
exports.groupFn = groupFn;
|
|
131
|
+
exports.groupByIdentity = groupByIdentity;
|
|
132
|
+
exports.groupByIdentityFn = groupByIdentityFn;
|
|
133
|
+
exports.groupByEquality = groupByEquality;
|
|
134
|
+
exports.groupByEqualityFn = groupByEqualityFn;
|
|
135
|
+
exports.groupByOrder = groupByOrder;
|
|
136
|
+
exports.groupByOrderFn = groupByOrderFn;
|
|
137
|
+
exports.groupByHash = groupByHash;
|
|
138
|
+
exports.groupByHashFn = groupByHashFn;
|
|
139
|
+
exports.groupByEqualityWithHash = groupByEqualityWithHash;
|
|
140
|
+
exports.groupByEqualityWithHashFn = groupByEqualityWithHashFn;
|
|
141
|
+
exports.groupByOrderWithHash = groupByOrderWithHash;
|
|
142
|
+
exports.groupByOrderWithHashFn = groupByOrderWithHashFn;
|
|
143
|
+
exports.groupAdjacent = groupAdjacent;
|
|
144
|
+
exports.groupAdjacentFn = groupAdjacentFn;
|
|
145
|
+
exports.groupAdjacentByIdentity = groupAdjacentByIdentity;
|
|
146
|
+
exports.groupAdjacentByIdentityFn = groupAdjacentByIdentityFn;
|
|
147
|
+
exports.groupAdjacentByEquality = groupAdjacentByEquality;
|
|
148
|
+
exports.groupAdjacentByEqualityFn = groupAdjacentByEqualityFn;
|
|
149
|
+
exports.groupAdjacentByOrder = groupAdjacentByOrder;
|
|
150
|
+
exports.groupAdjacentByOrderFn = groupAdjacentByOrderFn;
|
|
151
|
+
exports.groupAdjacentByHash = groupAdjacentByHash;
|
|
152
|
+
exports.groupAdjacentByHashFn = groupAdjacentByHashFn;
|
|
153
|
+
exports.unique = unique;
|
|
154
|
+
exports.uniqueFn = uniqueFn;
|
|
155
|
+
exports.uniqueByIdentity = uniqueByIdentity;
|
|
156
|
+
exports.uniqueByEquality = uniqueByEquality;
|
|
157
|
+
exports.uniqueByEqualityFn = uniqueByEqualityFn;
|
|
158
|
+
exports.uniqueByOrder = uniqueByOrder;
|
|
159
|
+
exports.uniqueByOrderFn = uniqueByOrderFn;
|
|
160
|
+
exports.uniqueByHash = uniqueByHash;
|
|
161
|
+
exports.uniqueByHashFn = uniqueByHashFn;
|
|
162
|
+
exports.uniqueByEqualityWithHash = uniqueByEqualityWithHash;
|
|
163
|
+
exports.uniqueByEqualityWithHashFn = uniqueByEqualityWithHashFn;
|
|
164
|
+
exports.uniqueByOrderWithHash = uniqueByOrderWithHash;
|
|
165
|
+
exports.uniqueByOrderWithHashFn = uniqueByOrderWithHashFn;
|
|
166
|
+
exports.uniqueAdjacent = uniqueAdjacent;
|
|
167
|
+
exports.uniqueAdjacentFn = uniqueAdjacentFn;
|
|
168
|
+
exports.uniqueAdjacentByIdentity = uniqueAdjacentByIdentity;
|
|
169
|
+
exports.uniqueAdjacentByIdentityFn = uniqueAdjacentByIdentityFn;
|
|
170
|
+
exports.uniqueAdjacentByEquality = uniqueAdjacentByEquality;
|
|
171
|
+
exports.uniqueAdjacentByEqualityFn = uniqueAdjacentByEqualityFn;
|
|
172
|
+
exports.uniqueAdjacentByOrder = uniqueAdjacentByOrder;
|
|
173
|
+
exports.uniqueAdjacentByOrderFn = uniqueAdjacentByOrderFn;
|
|
174
|
+
exports.uniqueAdjacentByHash = uniqueAdjacentByHash;
|
|
175
|
+
exports.uniqueAdjacentByHashFn = uniqueAdjacentByHashFn;
|
|
176
|
+
exports.sort = sort;
|
|
177
|
+
exports.sortFn = sortFn;
|
|
178
|
+
exports.sortBy = sortBy;
|
|
179
|
+
exports.sortByFn = sortByFn;
|
|
180
|
+
exports.sortByDescending = sortByDescending;
|
|
181
|
+
exports.sortByDescendingFn = sortByDescendingFn;
|
|
182
|
+
exports.forEach = forEach;
|
|
183
|
+
exports.forEachFn = forEachFn;
|
|
7
184
|
const nullable_1 = require("@softwareventures/nullable");
|
|
8
185
|
const ordered_1 = require("@softwareventures/ordered");
|
|
9
186
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -37,85 +214,65 @@ function isArrayLike(value) {
|
|
|
37
214
|
"length" in value &&
|
|
38
215
|
typeof value.length === "number");
|
|
39
216
|
}
|
|
40
|
-
exports.isArrayLike = isArrayLike;
|
|
41
217
|
function coerce(array) {
|
|
42
218
|
return (0, exports.isArray)(array) ? array : (0, exports.copy)(array);
|
|
43
219
|
}
|
|
44
|
-
exports.coerce = coerce;
|
|
45
220
|
function first(array) {
|
|
46
221
|
return array.length === 0 ? null : array[0];
|
|
47
222
|
}
|
|
48
|
-
exports.first = first;
|
|
49
223
|
function tail(array) {
|
|
50
224
|
return nativeSlice.call(array, 1);
|
|
51
225
|
}
|
|
52
|
-
exports.tail = tail;
|
|
53
226
|
function push(array, value) {
|
|
54
227
|
return [...coerce(array), value];
|
|
55
228
|
}
|
|
56
|
-
exports.push = push;
|
|
57
229
|
function pushFn(value) {
|
|
58
230
|
return array => push(array, value);
|
|
59
231
|
}
|
|
60
|
-
exports.pushFn = pushFn;
|
|
61
232
|
function unshift(array, value) {
|
|
62
233
|
return [value, ...coerce(array)];
|
|
63
234
|
}
|
|
64
|
-
exports.unshift = unshift;
|
|
65
235
|
function unshiftFn(value) {
|
|
66
236
|
return array => unshift(array, value);
|
|
67
237
|
}
|
|
68
|
-
exports.unshiftFn = unshiftFn;
|
|
69
238
|
function initial(array) {
|
|
70
239
|
return array.length === 0 ? [] : nativeSlice.call(array, 0, array.length - 1);
|
|
71
240
|
}
|
|
72
|
-
exports.initial = initial;
|
|
73
241
|
function last(array) {
|
|
74
242
|
return array.length === 0 ? null : array[array.length - 1];
|
|
75
243
|
}
|
|
76
|
-
exports.last = last;
|
|
77
244
|
/** If the array contains exactly one element, returns that element.
|
|
78
245
|
* Otherwise, returns null. */
|
|
79
246
|
function only(array) {
|
|
80
247
|
return array.length === 1 ? array[0] : null;
|
|
81
248
|
}
|
|
82
|
-
exports.only = only;
|
|
83
249
|
function empty(array) {
|
|
84
250
|
return array.length === 0;
|
|
85
251
|
}
|
|
86
|
-
exports.empty = empty;
|
|
87
252
|
function notEmpty(array) {
|
|
88
253
|
return array.length > 0;
|
|
89
254
|
}
|
|
90
|
-
exports.notEmpty = notEmpty;
|
|
91
255
|
function reverse(array) {
|
|
92
256
|
return nativeReverse.call((0, exports.copy)(array));
|
|
93
257
|
}
|
|
94
|
-
exports.reverse = reverse;
|
|
95
258
|
function slice(array, start, end) {
|
|
96
259
|
return nativeSlice.call(array, start, end);
|
|
97
260
|
}
|
|
98
|
-
exports.slice = slice;
|
|
99
261
|
function sliceFn(start, end) {
|
|
100
262
|
return array => nativeSlice.call(array, start, end);
|
|
101
263
|
}
|
|
102
|
-
exports.sliceFn = sliceFn;
|
|
103
264
|
function take(array, count) {
|
|
104
265
|
return nativeSlice.call(array, 0, count);
|
|
105
266
|
}
|
|
106
|
-
exports.take = take;
|
|
107
267
|
function takeFn(count) {
|
|
108
268
|
return array => nativeSlice.call(array, 0, count);
|
|
109
269
|
}
|
|
110
|
-
exports.takeFn = takeFn;
|
|
111
270
|
function drop(array, count) {
|
|
112
271
|
return nativeSlice.call(array, count);
|
|
113
272
|
}
|
|
114
|
-
exports.drop = drop;
|
|
115
273
|
function dropFn(count) {
|
|
116
274
|
return array => nativeSlice.call(array, count);
|
|
117
275
|
}
|
|
118
|
-
exports.dropFn = dropFn;
|
|
119
276
|
function takeWhile(array, predicate) {
|
|
120
277
|
let i = 0;
|
|
121
278
|
while (i < array.length && predicate(array[i], i)) {
|
|
@@ -123,19 +280,15 @@ function takeWhile(array, predicate) {
|
|
|
123
280
|
}
|
|
124
281
|
return take(array, i);
|
|
125
282
|
}
|
|
126
|
-
exports.takeWhile = takeWhile;
|
|
127
283
|
function takeWhileFn(predicate) {
|
|
128
284
|
return array => takeWhile(array, predicate);
|
|
129
285
|
}
|
|
130
|
-
exports.takeWhileFn = takeWhileFn;
|
|
131
286
|
function takeUntil(array, predicate) {
|
|
132
287
|
return takeWhile(array, (element, index) => !predicate(element, index));
|
|
133
288
|
}
|
|
134
|
-
exports.takeUntil = takeUntil;
|
|
135
289
|
function takeUntilFn(predicate) {
|
|
136
290
|
return array => takeUntil(array, predicate);
|
|
137
291
|
}
|
|
138
|
-
exports.takeUntilFn = takeUntilFn;
|
|
139
292
|
function dropWhile(array, predicate) {
|
|
140
293
|
let i = 0;
|
|
141
294
|
while (i < array.length && predicate(array[i], i)) {
|
|
@@ -143,19 +296,15 @@ function dropWhile(array, predicate) {
|
|
|
143
296
|
}
|
|
144
297
|
return drop(array, i);
|
|
145
298
|
}
|
|
146
|
-
exports.dropWhile = dropWhile;
|
|
147
299
|
function dropWhileFn(predicate) {
|
|
148
300
|
return array => dropWhile(array, predicate);
|
|
149
301
|
}
|
|
150
|
-
exports.dropWhileFn = dropWhileFn;
|
|
151
302
|
function dropUntil(array, predicate) {
|
|
152
303
|
return dropWhile(array, (element, index) => !predicate(element, index));
|
|
153
304
|
}
|
|
154
|
-
exports.dropUntil = dropUntil;
|
|
155
305
|
function dropUntilFn(predicate) {
|
|
156
306
|
return array => dropWhile(array, predicate);
|
|
157
307
|
}
|
|
158
|
-
exports.dropUntilFn = dropUntilFn;
|
|
159
308
|
function equal(a, b, elementsEqual = ordered_1.equal) {
|
|
160
309
|
if (a.length !== b.length) {
|
|
161
310
|
return false;
|
|
@@ -167,19 +316,15 @@ function equal(a, b, elementsEqual = ordered_1.equal) {
|
|
|
167
316
|
}
|
|
168
317
|
return true;
|
|
169
318
|
}
|
|
170
|
-
exports.equal = equal;
|
|
171
319
|
function equalFn(b, elementsEqual = ordered_1.equal) {
|
|
172
320
|
return a => equal(a, b, elementsEqual);
|
|
173
321
|
}
|
|
174
|
-
exports.equalFn = equalFn;
|
|
175
322
|
function notEqual(a, b, elementsEqual = ordered_1.equal) {
|
|
176
323
|
return !equal(a, b, elementsEqual);
|
|
177
324
|
}
|
|
178
|
-
exports.notEqual = notEqual;
|
|
179
325
|
function notEqualFn(b, elementsEqual = ordered_1.equal) {
|
|
180
326
|
return a => notEqual(a, b, elementsEqual);
|
|
181
327
|
}
|
|
182
|
-
exports.notEqualFn = notEqualFn;
|
|
183
328
|
function prefixMatch(a, b, elementsEqual = ordered_1.equal) {
|
|
184
329
|
if (a.length < b.length) {
|
|
185
330
|
return false;
|
|
@@ -191,11 +336,9 @@ function prefixMatch(a, b, elementsEqual = ordered_1.equal) {
|
|
|
191
336
|
}
|
|
192
337
|
return true;
|
|
193
338
|
}
|
|
194
|
-
exports.prefixMatch = prefixMatch;
|
|
195
339
|
function prefixMatchFn(b, elementsEqual = ordered_1.equal) {
|
|
196
340
|
return a => prefixMatch(a, b, elementsEqual);
|
|
197
341
|
}
|
|
198
|
-
exports.prefixMatchFn = prefixMatchFn;
|
|
199
342
|
/** @internal This implementation is for internal use only, the exported declaration is above */
|
|
200
343
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
201
344
|
// @ts-ignore duplicate identifier: This is the actual implementation, the exported declaration is above.
|
|
@@ -203,27 +346,21 @@ exports.map = Array.from;
|
|
|
203
346
|
function mapFn(f) {
|
|
204
347
|
return array => Array.from(array, f);
|
|
205
348
|
}
|
|
206
|
-
exports.mapFn = mapFn;
|
|
207
349
|
function filter(array, predicate) {
|
|
208
350
|
return nativeFilter.call(array, predicate);
|
|
209
351
|
}
|
|
210
|
-
exports.filter = filter;
|
|
211
352
|
function filterFn(predicate) {
|
|
212
353
|
return array => nativeFilter.call(array, predicate);
|
|
213
354
|
}
|
|
214
|
-
exports.filterFn = filterFn;
|
|
215
355
|
function exclude(array, predicate) {
|
|
216
356
|
return filter(array, (element, index) => !predicate(element, index));
|
|
217
357
|
}
|
|
218
|
-
exports.exclude = exclude;
|
|
219
358
|
function excludeFn(predicate) {
|
|
220
359
|
return array => exclude(array, predicate);
|
|
221
360
|
}
|
|
222
|
-
exports.excludeFn = excludeFn;
|
|
223
361
|
function excludeNull(array) {
|
|
224
362
|
return filter(array, nullable_1.isNotNull);
|
|
225
363
|
}
|
|
226
|
-
exports.excludeNull = excludeNull;
|
|
227
364
|
function excludeFirst(array, predicate) {
|
|
228
365
|
const result = [];
|
|
229
366
|
let i = 0;
|
|
@@ -241,59 +378,45 @@ function excludeFirst(array, predicate) {
|
|
|
241
378
|
}
|
|
242
379
|
return result;
|
|
243
380
|
}
|
|
244
|
-
exports.excludeFirst = excludeFirst;
|
|
245
381
|
function excludeFirstFn(predicate) {
|
|
246
382
|
return array => excludeFirst(array, predicate);
|
|
247
383
|
}
|
|
248
|
-
exports.excludeFirstFn = excludeFirstFn;
|
|
249
384
|
function remove(array, value) {
|
|
250
385
|
return exclude(array, element => element === value);
|
|
251
386
|
}
|
|
252
|
-
exports.remove = remove;
|
|
253
387
|
function removeFn(value) {
|
|
254
388
|
return array => remove(array, value);
|
|
255
389
|
}
|
|
256
|
-
exports.removeFn = removeFn;
|
|
257
390
|
function removeFirst(array, value) {
|
|
258
391
|
return excludeFirst(array, element => element === value);
|
|
259
392
|
}
|
|
260
|
-
exports.removeFirst = removeFirst;
|
|
261
393
|
function removeFirstFn(value) {
|
|
262
394
|
return array => removeFirst(array, value);
|
|
263
395
|
}
|
|
264
|
-
exports.removeFirstFn = removeFirstFn;
|
|
265
396
|
function fold(array, f, initial) {
|
|
266
397
|
return nativeReduce.call(array, f, initial);
|
|
267
398
|
}
|
|
268
|
-
exports.fold = fold;
|
|
269
399
|
function foldFn(f, initial) {
|
|
270
400
|
return array => nativeReduce.call(array, f, initial);
|
|
271
401
|
}
|
|
272
|
-
exports.foldFn = foldFn;
|
|
273
402
|
function fold1(array, f) {
|
|
274
403
|
return nativeReduce.call(array, f);
|
|
275
404
|
}
|
|
276
|
-
exports.fold1 = fold1;
|
|
277
405
|
function fold1Fn(f) {
|
|
278
406
|
return array => fold1(array, f);
|
|
279
407
|
}
|
|
280
|
-
exports.fold1Fn = fold1Fn;
|
|
281
408
|
function foldRight(array, f, initial) {
|
|
282
409
|
return nativeReduceRight.call(array, f, initial);
|
|
283
410
|
}
|
|
284
|
-
exports.foldRight = foldRight;
|
|
285
411
|
function foldRightFn(f, initial) {
|
|
286
412
|
return array => nativeReduceRight.call(array, f, initial);
|
|
287
413
|
}
|
|
288
|
-
exports.foldRightFn = foldRightFn;
|
|
289
414
|
function foldRight1(array, f) {
|
|
290
415
|
return nativeReduceRight.call(array, f);
|
|
291
416
|
}
|
|
292
|
-
exports.foldRight1 = foldRight1;
|
|
293
417
|
function foldRight1Fn(f) {
|
|
294
418
|
return array => foldRight1(array, f);
|
|
295
419
|
}
|
|
296
|
-
exports.foldRight1Fn = foldRight1Fn;
|
|
297
420
|
function foldMap(array, f, m, initial) {
|
|
298
421
|
let accumulator = initial;
|
|
299
422
|
for (let i = 0; i < array.length; ++i) {
|
|
@@ -301,11 +424,9 @@ function foldMap(array, f, m, initial) {
|
|
|
301
424
|
}
|
|
302
425
|
return accumulator;
|
|
303
426
|
}
|
|
304
|
-
exports.foldMap = foldMap;
|
|
305
427
|
function foldMapFn(f, m, initial) {
|
|
306
428
|
return array => foldMap(array, f, m, initial);
|
|
307
429
|
}
|
|
308
|
-
exports.foldMapFn = foldMapFn;
|
|
309
430
|
function foldMapRight(array, f, m, initial) {
|
|
310
431
|
let accumulator = initial;
|
|
311
432
|
const length = array.length;
|
|
@@ -314,28 +435,22 @@ function foldMapRight(array, f, m, initial) {
|
|
|
314
435
|
}
|
|
315
436
|
return accumulator;
|
|
316
437
|
}
|
|
317
|
-
exports.foldMapRight = foldMapRight;
|
|
318
438
|
function foldMapRightFn(f, m, initial) {
|
|
319
439
|
return array => foldMapRight(array, f, m, initial);
|
|
320
440
|
}
|
|
321
|
-
exports.foldMapRightFn = foldMapRightFn;
|
|
322
441
|
function contains(array, value) {
|
|
323
442
|
return nativeIndexOf.call(array, value) !== -1;
|
|
324
443
|
}
|
|
325
|
-
exports.contains = contains;
|
|
326
444
|
function containsFn(value) {
|
|
327
445
|
return array => nativeIndexOf.call(array, value) !== -1;
|
|
328
446
|
}
|
|
329
|
-
exports.containsFn = containsFn;
|
|
330
447
|
function indexOf(array, value) {
|
|
331
448
|
const index = nativeIndexOf.call(array, value);
|
|
332
449
|
return index === -1 ? null : index;
|
|
333
450
|
}
|
|
334
|
-
exports.indexOf = indexOf;
|
|
335
451
|
function indexOfFn(value) {
|
|
336
452
|
return array => indexOf(array, value);
|
|
337
453
|
}
|
|
338
|
-
exports.indexOfFn = indexOfFn;
|
|
339
454
|
function lastIndexOf(array, value) {
|
|
340
455
|
for (let i = array.length - 1; i >= 0; --i) {
|
|
341
456
|
if (array[i] === value) {
|
|
@@ -344,20 +459,16 @@ function lastIndexOf(array, value) {
|
|
|
344
459
|
}
|
|
345
460
|
return null;
|
|
346
461
|
}
|
|
347
|
-
exports.lastIndexOf = lastIndexOf;
|
|
348
462
|
function lastIndexOfFn(value) {
|
|
349
463
|
return array => lastIndexOf(array, value);
|
|
350
464
|
}
|
|
351
|
-
exports.lastIndexOfFn = lastIndexOfFn;
|
|
352
465
|
function findIndex(array, predicate) {
|
|
353
466
|
const index = nativeFindIndex.call(array, predicate);
|
|
354
467
|
return index === -1 ? null : index;
|
|
355
468
|
}
|
|
356
|
-
exports.findIndex = findIndex;
|
|
357
469
|
function findIndexFn(predicate) {
|
|
358
470
|
return array => findIndex(array, predicate);
|
|
359
471
|
}
|
|
360
|
-
exports.findIndexFn = findIndexFn;
|
|
361
472
|
function findLastIndex(array, predicate) {
|
|
362
473
|
for (let i = array.length - 1; i >= 0; --i) {
|
|
363
474
|
if (predicate(array[i], i)) {
|
|
@@ -366,20 +477,16 @@ function findLastIndex(array, predicate) {
|
|
|
366
477
|
}
|
|
367
478
|
return null;
|
|
368
479
|
}
|
|
369
|
-
exports.findLastIndex = findLastIndex;
|
|
370
480
|
function findLastIndexFn(predicate) {
|
|
371
481
|
return array => findLastIndex(array, predicate);
|
|
372
482
|
}
|
|
373
|
-
exports.findLastIndexFn = findLastIndexFn;
|
|
374
483
|
function find(array, predicate) {
|
|
375
484
|
const index = findIndex(array, predicate);
|
|
376
485
|
return index == null ? null : array[index];
|
|
377
486
|
}
|
|
378
|
-
exports.find = find;
|
|
379
487
|
function findFn(predicate) {
|
|
380
488
|
return array => find(array, predicate);
|
|
381
489
|
}
|
|
382
|
-
exports.findFn = findFn;
|
|
383
490
|
function findLast(array, predicate) {
|
|
384
491
|
for (let i = array.length - 1; i >= 0; --i) {
|
|
385
492
|
const element = array[i];
|
|
@@ -389,19 +496,15 @@ function findLast(array, predicate) {
|
|
|
389
496
|
}
|
|
390
497
|
return null;
|
|
391
498
|
}
|
|
392
|
-
exports.findLast = findLast;
|
|
393
499
|
function findLastFn(predicate) {
|
|
394
500
|
return array => findLast(array, predicate);
|
|
395
501
|
}
|
|
396
|
-
exports.findLastFn = findLastFn;
|
|
397
502
|
function maximum(array, compare) {
|
|
398
503
|
return internalMaximum(array, compare !== null && compare !== void 0 ? compare : ordered_1.compare);
|
|
399
504
|
}
|
|
400
|
-
exports.maximum = maximum;
|
|
401
505
|
function maximumFn(compare) {
|
|
402
506
|
return array => internalMaximum(array, compare !== null && compare !== void 0 ? compare : ordered_1.compare);
|
|
403
507
|
}
|
|
404
|
-
exports.maximumFn = maximumFn;
|
|
405
508
|
function internalMaximum(array, compare) {
|
|
406
509
|
if (array.length === 0) {
|
|
407
510
|
return null;
|
|
@@ -417,19 +520,15 @@ function internalMaximum(array, compare) {
|
|
|
417
520
|
function maximumBy(array, select) {
|
|
418
521
|
return maximum(array, (a, b) => (0, ordered_1.compare)(select(a), select(b)));
|
|
419
522
|
}
|
|
420
|
-
exports.maximumBy = maximumBy;
|
|
421
523
|
function maximumByFn(select) {
|
|
422
524
|
return array => maximumBy(array, select);
|
|
423
525
|
}
|
|
424
|
-
exports.maximumByFn = maximumByFn;
|
|
425
526
|
function minimum(array, compare) {
|
|
426
527
|
return internalMinimum(array, compare !== null && compare !== void 0 ? compare : ordered_1.compare);
|
|
427
528
|
}
|
|
428
|
-
exports.minimum = minimum;
|
|
429
529
|
function minimumFn(compare) {
|
|
430
530
|
return array => internalMinimum(array, compare !== null && compare !== void 0 ? compare : ordered_1.compare);
|
|
431
531
|
}
|
|
432
|
-
exports.minimumFn = minimumFn;
|
|
433
532
|
function internalMinimum(array, compare) {
|
|
434
533
|
if (array.length === 0) {
|
|
435
534
|
return null;
|
|
@@ -445,19 +544,15 @@ function internalMinimum(array, compare) {
|
|
|
445
544
|
function minimumBy(array, select) {
|
|
446
545
|
return minimum(array, (a, b) => (0, ordered_1.compare)(select(a), select(b)));
|
|
447
546
|
}
|
|
448
|
-
exports.minimumBy = minimumBy;
|
|
449
547
|
function minimumByFn(select) {
|
|
450
548
|
return array => minimumBy(array, select);
|
|
451
549
|
}
|
|
452
|
-
exports.minimumByFn = minimumByFn;
|
|
453
550
|
function sum(array) {
|
|
454
551
|
return fold(array, (a, b) => a + b, 0);
|
|
455
552
|
}
|
|
456
|
-
exports.sum = sum;
|
|
457
553
|
function product(array) {
|
|
458
554
|
return fold(array, (a, b) => a * b, 1);
|
|
459
555
|
}
|
|
460
|
-
exports.product = product;
|
|
461
556
|
function average(array) {
|
|
462
557
|
if (array.length === 0) {
|
|
463
558
|
return null;
|
|
@@ -466,55 +561,42 @@ function average(array) {
|
|
|
466
561
|
return sum(array) / array.length;
|
|
467
562
|
}
|
|
468
563
|
}
|
|
469
|
-
exports.average = average;
|
|
470
564
|
function and(array) {
|
|
471
565
|
return findIndex(array, element => !element) == null;
|
|
472
566
|
}
|
|
473
|
-
exports.and = and;
|
|
474
567
|
function or(array) {
|
|
475
568
|
return findIndex(array, element => Boolean(element)) != null;
|
|
476
569
|
}
|
|
477
|
-
exports.or = or;
|
|
478
570
|
function any(array, predicate) {
|
|
479
571
|
return findIndex(array, predicate) != null;
|
|
480
572
|
}
|
|
481
|
-
exports.any = any;
|
|
482
573
|
function anyFn(predicate) {
|
|
483
574
|
return array => any(array, predicate);
|
|
484
575
|
}
|
|
485
|
-
exports.anyFn = anyFn;
|
|
486
576
|
function all(array, predicate) {
|
|
487
577
|
return !any(array, (element, index) => !predicate(element, index));
|
|
488
578
|
}
|
|
489
|
-
exports.all = all;
|
|
490
579
|
function allFn(predicate) {
|
|
491
580
|
return array => all(array, predicate);
|
|
492
581
|
}
|
|
493
|
-
exports.allFn = allFn;
|
|
494
582
|
function concat(arrays) {
|
|
495
583
|
return nativeConcat.apply([], (0, exports.map)(arrays, coerce));
|
|
496
584
|
}
|
|
497
|
-
exports.concat = concat;
|
|
498
585
|
function prepend(a) {
|
|
499
586
|
return b => concat([a, b]);
|
|
500
587
|
}
|
|
501
|
-
exports.prepend = prepend;
|
|
502
588
|
function append(b) {
|
|
503
589
|
return a => concat([a, b]);
|
|
504
590
|
}
|
|
505
|
-
exports.append = append;
|
|
506
591
|
function concatMap(array, f) {
|
|
507
592
|
return concat((0, exports.map)(array, f));
|
|
508
593
|
}
|
|
509
|
-
exports.concatMap = concatMap;
|
|
510
594
|
function concatMapFn(f) {
|
|
511
595
|
return array => concatMap(array, f);
|
|
512
596
|
}
|
|
513
|
-
exports.concatMapFn = concatMapFn;
|
|
514
597
|
function noneNull(array) {
|
|
515
598
|
return any(array, nullable_1.isNull) ? null : array;
|
|
516
599
|
}
|
|
517
|
-
exports.noneNull = noneNull;
|
|
518
600
|
function scan(array, f, initial) {
|
|
519
601
|
const result = (0, exports.copy)({ length: array.length });
|
|
520
602
|
let accumulator = initial;
|
|
@@ -523,11 +605,9 @@ function scan(array, f, initial) {
|
|
|
523
605
|
}
|
|
524
606
|
return result;
|
|
525
607
|
}
|
|
526
|
-
exports.scan = scan;
|
|
527
608
|
function scanFn(f, initial) {
|
|
528
609
|
return array => scan(array, f, initial);
|
|
529
610
|
}
|
|
530
|
-
exports.scanFn = scanFn;
|
|
531
611
|
function scan1(array, f) {
|
|
532
612
|
if (array.length === 0) {
|
|
533
613
|
return [];
|
|
@@ -539,11 +619,9 @@ function scan1(array, f) {
|
|
|
539
619
|
}
|
|
540
620
|
return result;
|
|
541
621
|
}
|
|
542
|
-
exports.scan1 = scan1;
|
|
543
622
|
function scan1Fn(f) {
|
|
544
623
|
return array => scan1(array, f);
|
|
545
624
|
}
|
|
546
|
-
exports.scan1Fn = scan1Fn;
|
|
547
625
|
function scanRight(array, f, initial) {
|
|
548
626
|
const result = (0, exports.copy)({ length: array.length });
|
|
549
627
|
let accumulator = initial;
|
|
@@ -552,11 +630,9 @@ function scanRight(array, f, initial) {
|
|
|
552
630
|
}
|
|
553
631
|
return result;
|
|
554
632
|
}
|
|
555
|
-
exports.scanRight = scanRight;
|
|
556
633
|
function scanRightFn(f, initial) {
|
|
557
634
|
return array => scanRight(array, f, initial);
|
|
558
635
|
}
|
|
559
|
-
exports.scanRightFn = scanRightFn;
|
|
560
636
|
function scanRight1(array, f) {
|
|
561
637
|
if (array.length === 0) {
|
|
562
638
|
return [];
|
|
@@ -568,11 +644,9 @@ function scanRight1(array, f) {
|
|
|
568
644
|
}
|
|
569
645
|
return result;
|
|
570
646
|
}
|
|
571
|
-
exports.scanRight1 = scanRight1;
|
|
572
647
|
function scanRight1Fn(f) {
|
|
573
648
|
return array => scanRight1(array, f);
|
|
574
649
|
}
|
|
575
|
-
exports.scanRight1Fn = scanRight1Fn;
|
|
576
650
|
/** Splits the array at the specified index.
|
|
577
651
|
*
|
|
578
652
|
* Returns a tuple where the first element is the first `index` elements of the
|
|
@@ -580,14 +654,12 @@ exports.scanRight1Fn = scanRight1Fn;
|
|
|
580
654
|
function split(array, index) {
|
|
581
655
|
return [take(array, index), drop(array, index)];
|
|
582
656
|
}
|
|
583
|
-
exports.split = split;
|
|
584
657
|
/** Returns a function that splits an array at the specified index.
|
|
585
658
|
*
|
|
586
659
|
* This is the curried form of {@link split}. */
|
|
587
660
|
function splitFn(index) {
|
|
588
661
|
return array => split(array, index);
|
|
589
662
|
}
|
|
590
|
-
exports.splitFn = splitFn;
|
|
591
663
|
function partition(array, predicate) {
|
|
592
664
|
const a = [];
|
|
593
665
|
const b = [];
|
|
@@ -601,11 +673,9 @@ function partition(array, predicate) {
|
|
|
601
673
|
}
|
|
602
674
|
return [a, b];
|
|
603
675
|
}
|
|
604
|
-
exports.partition = partition;
|
|
605
676
|
function partitionFn(predicate) {
|
|
606
677
|
return array => partition(array, predicate);
|
|
607
678
|
}
|
|
608
|
-
exports.partitionFn = partitionFn;
|
|
609
679
|
function partitionWhile(array, predicate) {
|
|
610
680
|
let i;
|
|
611
681
|
for (i = 0; i < array.length; ++i) {
|
|
@@ -615,19 +685,15 @@ function partitionWhile(array, predicate) {
|
|
|
615
685
|
}
|
|
616
686
|
return [take(array, i), drop(array, i)];
|
|
617
687
|
}
|
|
618
|
-
exports.partitionWhile = partitionWhile;
|
|
619
688
|
function partitionWhileFn(predicate) {
|
|
620
689
|
return array => partitionWhile(array, predicate);
|
|
621
690
|
}
|
|
622
|
-
exports.partitionWhileFn = partitionWhileFn;
|
|
623
691
|
function partitionUntil(array, predicate) {
|
|
624
692
|
return partitionWhile(array, element => !predicate(element));
|
|
625
693
|
}
|
|
626
|
-
exports.partitionUntil = partitionUntil;
|
|
627
694
|
function partitionUntilFn(predicate) {
|
|
628
695
|
return array => partitionUntil(array, predicate);
|
|
629
696
|
}
|
|
630
|
-
exports.partitionUntilFn = partitionUntilFn;
|
|
631
697
|
/** Takes two arrays and returns an array of corresponding pairs.
|
|
632
698
|
*
|
|
633
699
|
* If one of the supplied arrays is shorter than the other, then the excess
|
|
@@ -640,7 +706,6 @@ function zip(a, b) {
|
|
|
640
706
|
}
|
|
641
707
|
return result;
|
|
642
708
|
}
|
|
643
|
-
exports.zip = zip;
|
|
644
709
|
/** Returns a function that combines the elements of `a` with the elements of
|
|
645
710
|
* `b` and returns an array of corresponding pairs.
|
|
646
711
|
*
|
|
@@ -651,7 +716,6 @@ exports.zip = zip;
|
|
|
651
716
|
function zipFn(b) {
|
|
652
717
|
return a => zip(a, b);
|
|
653
718
|
}
|
|
654
|
-
exports.zipFn = zipFn;
|
|
655
719
|
function keyBy(array, f) {
|
|
656
720
|
var _a;
|
|
657
721
|
const result = new Map();
|
|
@@ -666,11 +730,9 @@ function keyBy(array, f) {
|
|
|
666
730
|
}
|
|
667
731
|
return result;
|
|
668
732
|
}
|
|
669
|
-
exports.keyBy = keyBy;
|
|
670
733
|
function keyByFn(f) {
|
|
671
734
|
return array => keyBy(array, f);
|
|
672
735
|
}
|
|
673
|
-
exports.keyByFn = keyByFn;
|
|
674
736
|
function keyFirstBy(array, f) {
|
|
675
737
|
const result = new Map();
|
|
676
738
|
for (let i = 0; i < array.length; ++i) {
|
|
@@ -682,11 +744,9 @@ function keyFirstBy(array, f) {
|
|
|
682
744
|
}
|
|
683
745
|
return result;
|
|
684
746
|
}
|
|
685
|
-
exports.keyFirstBy = keyFirstBy;
|
|
686
747
|
function keyFirstByFn(f) {
|
|
687
748
|
return array => keyFirstBy(array, f);
|
|
688
749
|
}
|
|
689
|
-
exports.keyFirstByFn = keyFirstByFn;
|
|
690
750
|
function keyLastBy(array, f) {
|
|
691
751
|
const result = new Map();
|
|
692
752
|
for (let i = 0; i < array.length; ++i) {
|
|
@@ -696,11 +756,9 @@ function keyLastBy(array, f) {
|
|
|
696
756
|
}
|
|
697
757
|
return result;
|
|
698
758
|
}
|
|
699
|
-
exports.keyLastBy = keyLastBy;
|
|
700
759
|
function keyLastByFn(f) {
|
|
701
760
|
return array => keyLastBy(array, f);
|
|
702
761
|
}
|
|
703
|
-
exports.keyLastByFn = keyLastByFn;
|
|
704
762
|
function mapKeyBy(array, f) {
|
|
705
763
|
var _a;
|
|
706
764
|
const result = new Map();
|
|
@@ -714,11 +772,9 @@ function mapKeyBy(array, f) {
|
|
|
714
772
|
}
|
|
715
773
|
return result;
|
|
716
774
|
}
|
|
717
|
-
exports.mapKeyBy = mapKeyBy;
|
|
718
775
|
function mapKeyByFn(f) {
|
|
719
776
|
return array => mapKeyBy(array, f);
|
|
720
777
|
}
|
|
721
|
-
exports.mapKeyByFn = mapKeyByFn;
|
|
722
778
|
function mapKeyFirstBy(array, f) {
|
|
723
779
|
const result = new Map();
|
|
724
780
|
for (let i = 0; i < array.length; ++i) {
|
|
@@ -729,11 +785,9 @@ function mapKeyFirstBy(array, f) {
|
|
|
729
785
|
}
|
|
730
786
|
return result;
|
|
731
787
|
}
|
|
732
|
-
exports.mapKeyFirstBy = mapKeyFirstBy;
|
|
733
788
|
function mapKeyFirstByFn(f) {
|
|
734
789
|
return array => mapKeyFirstBy(array, f);
|
|
735
790
|
}
|
|
736
|
-
exports.mapKeyFirstByFn = mapKeyFirstByFn;
|
|
737
791
|
function mapKeyLastBy(array, f) {
|
|
738
792
|
const result = new Map();
|
|
739
793
|
for (let i = 0; i < array.length; ++i) {
|
|
@@ -742,11 +796,9 @@ function mapKeyLastBy(array, f) {
|
|
|
742
796
|
}
|
|
743
797
|
return result;
|
|
744
798
|
}
|
|
745
|
-
exports.mapKeyLastBy = mapKeyLastBy;
|
|
746
799
|
function mapKeyLastByFn(f) {
|
|
747
800
|
return array => mapKeyLastBy(array, f);
|
|
748
801
|
}
|
|
749
|
-
exports.mapKeyLastByFn = mapKeyLastByFn;
|
|
750
802
|
function group(array, grouping) {
|
|
751
803
|
if ("identity" in grouping) {
|
|
752
804
|
return groupByIdentity(array, grouping.identity);
|
|
@@ -771,11 +823,9 @@ function group(array, grouping) {
|
|
|
771
823
|
return groupByHash(array, grouping.hash);
|
|
772
824
|
}
|
|
773
825
|
}
|
|
774
|
-
exports.group = group;
|
|
775
826
|
function groupFn(grouping) {
|
|
776
827
|
return array => group(array, grouping);
|
|
777
828
|
}
|
|
778
|
-
exports.groupFn = groupFn;
|
|
779
829
|
function groupByIdentity(array, identity = element => element) {
|
|
780
830
|
var _a;
|
|
781
831
|
const groups = [];
|
|
@@ -792,11 +842,9 @@ function groupByIdentity(array, identity = element => element) {
|
|
|
792
842
|
}
|
|
793
843
|
return groups;
|
|
794
844
|
}
|
|
795
|
-
exports.groupByIdentity = groupByIdentity;
|
|
796
845
|
function groupByIdentityFn(identity) {
|
|
797
846
|
return array => groupByIdentity(array, identity);
|
|
798
847
|
}
|
|
799
|
-
exports.groupByIdentityFn = groupByIdentityFn;
|
|
800
848
|
function groupByEquality(array, equal) {
|
|
801
849
|
const result = [];
|
|
802
850
|
outer: for (let i = 0; i < array.length; ++i) {
|
|
@@ -811,20 +859,16 @@ function groupByEquality(array, equal) {
|
|
|
811
859
|
}
|
|
812
860
|
return result;
|
|
813
861
|
}
|
|
814
|
-
exports.groupByEquality = groupByEquality;
|
|
815
862
|
function groupByEqualityFn(equal) {
|
|
816
863
|
return array => groupByEquality(array, equal);
|
|
817
864
|
}
|
|
818
|
-
exports.groupByEqualityFn = groupByEqualityFn;
|
|
819
865
|
function groupByOrder(array, compare) {
|
|
820
866
|
// TODO: This could use a binary tree to be way more efficient
|
|
821
867
|
return groupByEquality(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal);
|
|
822
868
|
}
|
|
823
|
-
exports.groupByOrder = groupByOrder;
|
|
824
869
|
function groupByOrderFn(compare) {
|
|
825
870
|
return array => groupByOrder(array, compare);
|
|
826
871
|
}
|
|
827
|
-
exports.groupByOrderFn = groupByOrderFn;
|
|
828
872
|
function groupByHash(array, hash) {
|
|
829
873
|
var _a;
|
|
830
874
|
const groups = new Map();
|
|
@@ -841,11 +885,9 @@ function groupByHash(array, hash) {
|
|
|
841
885
|
}
|
|
842
886
|
return result;
|
|
843
887
|
}
|
|
844
|
-
exports.groupByHash = groupByHash;
|
|
845
888
|
function groupByHashFn(hash) {
|
|
846
889
|
return array => groupByHash(array, hash);
|
|
847
890
|
}
|
|
848
|
-
exports.groupByHashFn = groupByHashFn;
|
|
849
891
|
function groupByEqualityWithHash(array, equal, hash) {
|
|
850
892
|
var _a;
|
|
851
893
|
const groups = new Map();
|
|
@@ -869,19 +911,15 @@ function groupByEqualityWithHash(array, equal, hash) {
|
|
|
869
911
|
}
|
|
870
912
|
return result;
|
|
871
913
|
}
|
|
872
|
-
exports.groupByEqualityWithHash = groupByEqualityWithHash;
|
|
873
914
|
function groupByEqualityWithHashFn(equal, hash) {
|
|
874
915
|
return array => groupByEqualityWithHash(array, equal, hash);
|
|
875
916
|
}
|
|
876
|
-
exports.groupByEqualityWithHashFn = groupByEqualityWithHashFn;
|
|
877
917
|
function groupByOrderWithHash(array, compare, hash) {
|
|
878
918
|
return groupByEqualityWithHash(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal, hash);
|
|
879
919
|
}
|
|
880
|
-
exports.groupByOrderWithHash = groupByOrderWithHash;
|
|
881
920
|
function groupByOrderWithHashFn(compare, hash) {
|
|
882
921
|
return array => groupByOrderWithHash(array, compare, hash);
|
|
883
922
|
}
|
|
884
|
-
exports.groupByOrderWithHashFn = groupByOrderWithHashFn;
|
|
885
923
|
function groupAdjacent(array, grouping) {
|
|
886
924
|
if ("identity" in grouping) {
|
|
887
925
|
return groupAdjacentByIdentity(array, grouping.identity);
|
|
@@ -896,21 +934,17 @@ function groupAdjacent(array, grouping) {
|
|
|
896
934
|
return groupByHash(array, grouping.hash);
|
|
897
935
|
}
|
|
898
936
|
}
|
|
899
|
-
exports.groupAdjacent = groupAdjacent;
|
|
900
937
|
function groupAdjacentFn(grouping) {
|
|
901
938
|
return array => groupAdjacent(array, grouping);
|
|
902
939
|
}
|
|
903
|
-
exports.groupAdjacentFn = groupAdjacentFn;
|
|
904
940
|
function groupAdjacentByIdentity(array, identity) {
|
|
905
941
|
return identity == null
|
|
906
942
|
? groupAdjacentByEquality(array, (a, b) => a === b)
|
|
907
943
|
: groupAdjacentByEquality(array, (a, b) => identity(a) === identity(b));
|
|
908
944
|
}
|
|
909
|
-
exports.groupAdjacentByIdentity = groupAdjacentByIdentity;
|
|
910
945
|
function groupAdjacentByIdentityFn(identity) {
|
|
911
946
|
return array => groupAdjacentByEquality(array, (a, b) => identity(a) === identity(b));
|
|
912
947
|
}
|
|
913
|
-
exports.groupAdjacentByIdentityFn = groupAdjacentByIdentityFn;
|
|
914
948
|
function groupAdjacentByEquality(array, equal) {
|
|
915
949
|
if (array.length === 0) {
|
|
916
950
|
return [];
|
|
@@ -931,19 +965,15 @@ function groupAdjacentByEquality(array, equal) {
|
|
|
931
965
|
}
|
|
932
966
|
return result;
|
|
933
967
|
}
|
|
934
|
-
exports.groupAdjacentByEquality = groupAdjacentByEquality;
|
|
935
968
|
function groupAdjacentByEqualityFn(equal) {
|
|
936
969
|
return array => groupAdjacentByEquality(array, equal);
|
|
937
970
|
}
|
|
938
|
-
exports.groupAdjacentByEqualityFn = groupAdjacentByEqualityFn;
|
|
939
971
|
function groupAdjacentByOrder(array, compare) {
|
|
940
972
|
return groupAdjacentByEquality(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal);
|
|
941
973
|
}
|
|
942
|
-
exports.groupAdjacentByOrder = groupAdjacentByOrder;
|
|
943
974
|
function groupAdjacentByOrderFn(compare) {
|
|
944
975
|
return array => groupAdjacentByOrder(array, compare);
|
|
945
976
|
}
|
|
946
|
-
exports.groupAdjacentByOrderFn = groupAdjacentByOrderFn;
|
|
947
977
|
function groupAdjacentByHash(array, hash) {
|
|
948
978
|
if (array.length === 0) {
|
|
949
979
|
return [];
|
|
@@ -966,11 +996,9 @@ function groupAdjacentByHash(array, hash) {
|
|
|
966
996
|
}
|
|
967
997
|
return result;
|
|
968
998
|
}
|
|
969
|
-
exports.groupAdjacentByHash = groupAdjacentByHash;
|
|
970
999
|
function groupAdjacentByHashFn(hash) {
|
|
971
1000
|
return array => groupAdjacentByHash(array, hash);
|
|
972
1001
|
}
|
|
973
|
-
exports.groupAdjacentByHashFn = groupAdjacentByHashFn;
|
|
974
1002
|
function unique(array, grouping) {
|
|
975
1003
|
if ("identity" in grouping) {
|
|
976
1004
|
return uniqueByIdentityInternal(array, grouping.identity);
|
|
@@ -995,15 +1023,12 @@ function unique(array, grouping) {
|
|
|
995
1023
|
return uniqueByHash(array, grouping.hash);
|
|
996
1024
|
}
|
|
997
1025
|
}
|
|
998
|
-
exports.unique = unique;
|
|
999
1026
|
function uniqueFn(grouping) {
|
|
1000
1027
|
return array => unique(array, grouping);
|
|
1001
1028
|
}
|
|
1002
|
-
exports.uniqueFn = uniqueFn;
|
|
1003
1029
|
function uniqueByIdentity(array, identity) {
|
|
1004
1030
|
return uniqueByIdentityInternal(array, identity !== null && identity !== void 0 ? identity : (element => element));
|
|
1005
1031
|
}
|
|
1006
|
-
exports.uniqueByIdentity = uniqueByIdentity;
|
|
1007
1032
|
function uniqueByIdentityInternal(array, identity) {
|
|
1008
1033
|
const set = new Set();
|
|
1009
1034
|
const result = [];
|
|
@@ -1029,20 +1054,16 @@ function uniqueByEquality(array, equal) {
|
|
|
1029
1054
|
}
|
|
1030
1055
|
return result;
|
|
1031
1056
|
}
|
|
1032
|
-
exports.uniqueByEquality = uniqueByEquality;
|
|
1033
1057
|
function uniqueByEqualityFn(equal) {
|
|
1034
1058
|
return array => uniqueByEquality(array, equal);
|
|
1035
1059
|
}
|
|
1036
|
-
exports.uniqueByEqualityFn = uniqueByEqualityFn;
|
|
1037
1060
|
function uniqueByOrder(array, compare) {
|
|
1038
1061
|
return uniqueByEquality(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal);
|
|
1039
1062
|
}
|
|
1040
|
-
exports.uniqueByOrder = uniqueByOrder;
|
|
1041
1063
|
function uniqueByOrderFn(compare) {
|
|
1042
1064
|
// TODO: This could use a binary tree to be more efficient
|
|
1043
1065
|
return array => uniqueByOrder(array, compare);
|
|
1044
1066
|
}
|
|
1045
|
-
exports.uniqueByOrderFn = uniqueByOrderFn;
|
|
1046
1067
|
function uniqueByHash(array, hash) {
|
|
1047
1068
|
const seen = new Set();
|
|
1048
1069
|
const result = [];
|
|
@@ -1056,11 +1077,9 @@ function uniqueByHash(array, hash) {
|
|
|
1056
1077
|
}
|
|
1057
1078
|
return result;
|
|
1058
1079
|
}
|
|
1059
|
-
exports.uniqueByHash = uniqueByHash;
|
|
1060
1080
|
function uniqueByHashFn(hash) {
|
|
1061
1081
|
return array => uniqueByHash(array, hash);
|
|
1062
1082
|
}
|
|
1063
|
-
exports.uniqueByHashFn = uniqueByHashFn;
|
|
1064
1083
|
function uniqueByEqualityWithHash(array, equal, hash) {
|
|
1065
1084
|
var _a;
|
|
1066
1085
|
const seenGroups = new Map();
|
|
@@ -1079,19 +1098,15 @@ function uniqueByEqualityWithHash(array, equal, hash) {
|
|
|
1079
1098
|
}
|
|
1080
1099
|
return result;
|
|
1081
1100
|
}
|
|
1082
|
-
exports.uniqueByEqualityWithHash = uniqueByEqualityWithHash;
|
|
1083
1101
|
function uniqueByEqualityWithHashFn(equal, hash) {
|
|
1084
1102
|
return array => uniqueByEqualityWithHash(array, equal, hash);
|
|
1085
1103
|
}
|
|
1086
|
-
exports.uniqueByEqualityWithHashFn = uniqueByEqualityWithHashFn;
|
|
1087
1104
|
function uniqueByOrderWithHash(array, compare, hash) {
|
|
1088
1105
|
return uniqueByEqualityWithHash(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal, hash);
|
|
1089
1106
|
}
|
|
1090
|
-
exports.uniqueByOrderWithHash = uniqueByOrderWithHash;
|
|
1091
1107
|
function uniqueByOrderWithHashFn(compare, hash) {
|
|
1092
1108
|
return array => uniqueByOrderWithHash(array, compare, hash);
|
|
1093
1109
|
}
|
|
1094
|
-
exports.uniqueByOrderWithHashFn = uniqueByOrderWithHashFn;
|
|
1095
1110
|
function uniqueAdjacent(array, grouping) {
|
|
1096
1111
|
if ("identity" in grouping) {
|
|
1097
1112
|
return uniqueAdjacentByIdentity(array, grouping.identity);
|
|
@@ -1106,21 +1121,17 @@ function uniqueAdjacent(array, grouping) {
|
|
|
1106
1121
|
return uniqueAdjacentByHash(array, grouping.hash);
|
|
1107
1122
|
}
|
|
1108
1123
|
}
|
|
1109
|
-
exports.uniqueAdjacent = uniqueAdjacent;
|
|
1110
1124
|
function uniqueAdjacentFn(grouping) {
|
|
1111
1125
|
return array => uniqueAdjacent(array, grouping);
|
|
1112
1126
|
}
|
|
1113
|
-
exports.uniqueAdjacentFn = uniqueAdjacentFn;
|
|
1114
1127
|
function uniqueAdjacentByIdentity(array, identity) {
|
|
1115
1128
|
return identity == null
|
|
1116
1129
|
? uniqueAdjacentByEquality(array, (a, b) => a === b)
|
|
1117
1130
|
: uniqueAdjacentByEquality(array, (a, b) => identity(a) === identity(b));
|
|
1118
1131
|
}
|
|
1119
|
-
exports.uniqueAdjacentByIdentity = uniqueAdjacentByIdentity;
|
|
1120
1132
|
function uniqueAdjacentByIdentityFn(identity) {
|
|
1121
1133
|
return array => uniqueAdjacentByIdentity(array, identity);
|
|
1122
1134
|
}
|
|
1123
|
-
exports.uniqueAdjacentByIdentityFn = uniqueAdjacentByIdentityFn;
|
|
1124
1135
|
function uniqueAdjacentByEquality(array, equal) {
|
|
1125
1136
|
if (array.length === 0) {
|
|
1126
1137
|
return [];
|
|
@@ -1136,19 +1147,15 @@ function uniqueAdjacentByEquality(array, equal) {
|
|
|
1136
1147
|
}
|
|
1137
1148
|
return result;
|
|
1138
1149
|
}
|
|
1139
|
-
exports.uniqueAdjacentByEquality = uniqueAdjacentByEquality;
|
|
1140
1150
|
function uniqueAdjacentByEqualityFn(equal) {
|
|
1141
1151
|
return array => uniqueAdjacentByEquality(array, equal);
|
|
1142
1152
|
}
|
|
1143
|
-
exports.uniqueAdjacentByEqualityFn = uniqueAdjacentByEqualityFn;
|
|
1144
1153
|
function uniqueAdjacentByOrder(array, compare) {
|
|
1145
1154
|
return uniqueAdjacentByEquality(array, (a, b) => compare(a, b) === ordered_1.Comparison.equal);
|
|
1146
1155
|
}
|
|
1147
|
-
exports.uniqueAdjacentByOrder = uniqueAdjacentByOrder;
|
|
1148
1156
|
function uniqueAdjacentByOrderFn(compare) {
|
|
1149
1157
|
return array => uniqueAdjacentByOrder(array, compare);
|
|
1150
1158
|
}
|
|
1151
|
-
exports.uniqueAdjacentByOrderFn = uniqueAdjacentByOrderFn;
|
|
1152
1159
|
function uniqueAdjacentByHash(array, hash) {
|
|
1153
1160
|
if (array.length === 0) {
|
|
1154
1161
|
return [];
|
|
@@ -1166,44 +1173,34 @@ function uniqueAdjacentByHash(array, hash) {
|
|
|
1166
1173
|
}
|
|
1167
1174
|
return result;
|
|
1168
1175
|
}
|
|
1169
|
-
exports.uniqueAdjacentByHash = uniqueAdjacentByHash;
|
|
1170
1176
|
function uniqueAdjacentByHashFn(hash) {
|
|
1171
1177
|
return array => uniqueAdjacentByHash(array, hash);
|
|
1172
1178
|
}
|
|
1173
|
-
exports.uniqueAdjacentByHashFn = uniqueAdjacentByHashFn;
|
|
1174
1179
|
function sort(array, comparator) {
|
|
1175
1180
|
return (0, exports.copy)(array).sort(comparator !== null && comparator !== void 0 ? comparator : ordered_1.compare);
|
|
1176
1181
|
}
|
|
1177
|
-
exports.sort = sort;
|
|
1178
1182
|
function sortFn(comparator) {
|
|
1179
1183
|
return array => sort(array, comparator);
|
|
1180
1184
|
}
|
|
1181
|
-
exports.sortFn = sortFn;
|
|
1182
1185
|
function sortBy(array, select) {
|
|
1183
1186
|
return sort(array, (a, b) => ordered_1.compare(select(a), select(b)));
|
|
1184
1187
|
}
|
|
1185
|
-
exports.sortBy = sortBy;
|
|
1186
1188
|
function sortByFn(select) {
|
|
1187
1189
|
return array => sortBy(array, select);
|
|
1188
1190
|
}
|
|
1189
|
-
exports.sortByFn = sortByFn;
|
|
1190
1191
|
function sortByDescending(array, select) {
|
|
1191
1192
|
return sort(array, (a, b) => -ordered_1.compare(select(a), select(b)));
|
|
1192
1193
|
}
|
|
1193
|
-
exports.sortByDescending = sortByDescending;
|
|
1194
1194
|
function sortByDescendingFn(select) {
|
|
1195
1195
|
return array => sortByDescending(array, select);
|
|
1196
1196
|
}
|
|
1197
|
-
exports.sortByDescendingFn = sortByDescendingFn;
|
|
1198
1197
|
function forEach(array, f) {
|
|
1199
1198
|
for (let i = 0; i < array.length; ++i) {
|
|
1200
1199
|
f(array[i], i);
|
|
1201
1200
|
}
|
|
1202
1201
|
return array;
|
|
1203
1202
|
}
|
|
1204
|
-
exports.forEach = forEach;
|
|
1205
1203
|
function forEachFn(f) {
|
|
1206
1204
|
return array => forEach(array, f);
|
|
1207
1205
|
}
|
|
1208
|
-
exports.forEachFn = forEachFn;
|
|
1209
1206
|
//# sourceMappingURL=index.js.map
|