rambda 10.0.0-alpha.0 → 10.0.0-beta.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/CHANGELOG.md +124 -16
- package/README.md +5526 -1730
- package/dist/{rambda.esm.js → rambda.cjs} +663 -355
- package/dist/rambda.js +545 -456
- package/dist/rambda.umd.js +563 -357
- package/immutable.d.ts +321 -343
- package/index.d.ts +321 -343
- package/package.json +20 -13
- package/rambda.js +16 -1
- package/src/addProp.js +3 -0
- package/src/append.js +5 -5
- package/src/ascend.js +16 -0
- package/src/compact.js +12 -0
- package/src/concat.js +1 -1
- package/src/count.js +7 -7
- package/src/countBy.js +12 -12
- package/src/createObjectFromKeys.js +10 -0
- package/src/descend.js +10 -0
- package/src/dropLast.js +1 -3
- package/src/eqProps.js +1 -2
- package/src/equals.js +2 -2
- package/src/evolve.js +2 -23
- package/src/filter.js +14 -14
- package/src/find.js +10 -10
- package/src/findIndex.js +9 -9
- package/src/findLast.js +8 -8
- package/src/findLastIndex.js +8 -8
- package/src/findNth.js +16 -0
- package/src/groupBy.js +14 -13
- package/src/includes.js +12 -13
- package/src/interpolate.js +29 -0
- package/src/intersection.js +1 -1
- package/src/intersperse.js +12 -12
- package/src/join.js +1 -1
- package/src/mapAsync.js +3 -3
- package/src/mapKeys.js +11 -0
- package/src/mapObjectAsync.js +9 -9
- package/src/mapParallelAsync.js +3 -0
- package/src/match.js +5 -5
- package/src/modifyProp.js +20 -0
- package/src/objectIncludes.js +12 -0
- package/src/partition.js +13 -37
- package/src/partitionObject.js +15 -0
- package/src/permutations.js +40 -0
- package/src/pipeAsync.js +7 -6
- package/src/pluck.js +9 -9
- package/src/prepend.js +1 -1
- package/src/propSatisfies.js +1 -3
- package/src/range.js +35 -12
- package/src/reject.js +1 -1
- package/src/rejectObject.js +13 -0
- package/src/shuffle.js +13 -0
- package/src/sort.js +1 -1
- package/src/sortBy.js +12 -10
- package/src/sortObject.js +15 -0
- package/src/sortWith.js +8 -8
- package/src/split.js +2 -2
- package/src/splitEvery.js +11 -11
- package/src/takeLastWhile.js +18 -18
- package/src/tap.js +4 -4
- package/src/test.js +1 -1
- package/src/uniqBy.js +4 -4
- package/src/uniqWith.js +10 -10
- package/src/modifyPath.js +0 -30
package/dist/rambda.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function addProp(key, value) {
|
|
2
|
+
return obj => ({ ...obj, [key]: value })
|
|
3
|
+
}
|
|
2
4
|
|
|
3
5
|
function all(predicate) {
|
|
4
6
|
return list => {
|
|
@@ -54,15 +56,32 @@ function anyPass(predicates) {
|
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
const cloneList = list => Array.prototype.slice.call(list);
|
|
59
|
+
const cloneList$1 = list => Array.prototype.slice.call(list);
|
|
58
60
|
|
|
59
61
|
function append(x) {
|
|
60
|
-
return list=> {
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
return list => {
|
|
63
|
+
const clone = cloneList$1(list);
|
|
64
|
+
clone.push(x);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
return clone
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function createCompareFunction(a, b, winner, loser) {
|
|
71
|
+
if (a === b) {
|
|
72
|
+
return 0
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return a < b ? winner : loser
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function ascend(getFunction) {
|
|
79
|
+
return (a, b) => {
|
|
80
|
+
const aValue = getFunction(a);
|
|
81
|
+
const bValue = getFunction(b);
|
|
82
|
+
|
|
83
|
+
return createCompareFunction(aValue, bValue, -1, 1)
|
|
84
|
+
}
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
function checkObjectWithSpec(conditions) {
|
|
@@ -82,41 +101,100 @@ function checkObjectWithSpec(conditions) {
|
|
|
82
101
|
}
|
|
83
102
|
}
|
|
84
103
|
|
|
104
|
+
const { isArray } = Array;
|
|
105
|
+
|
|
106
|
+
function filter(predicate) {
|
|
107
|
+
return list => {
|
|
108
|
+
if (!list) {
|
|
109
|
+
throw new Error('Incorrect iterable input')
|
|
110
|
+
}
|
|
111
|
+
let index = 0;
|
|
112
|
+
const len = list.length;
|
|
113
|
+
const willReturn = [];
|
|
114
|
+
|
|
115
|
+
while (index < len) {
|
|
116
|
+
if (predicate(list[index], index)) {
|
|
117
|
+
willReturn.push(list[index]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
index++;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return willReturn
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function reject(predicate) {
|
|
128
|
+
return list => filter(x => !predicate(x))(list)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function rejectObject(predicate) {
|
|
132
|
+
return obj => {
|
|
133
|
+
const willReturn = {};
|
|
134
|
+
|
|
135
|
+
for (const prop in obj) {
|
|
136
|
+
if (!predicate(obj[prop], prop, obj)) {
|
|
137
|
+
willReturn[prop] = obj[prop];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return willReturn
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const isNullOrUndefined = x => x === null || x === undefined;
|
|
146
|
+
|
|
147
|
+
function compact(input){
|
|
148
|
+
if(isArray(input)){
|
|
149
|
+
return reject(isNullOrUndefined)(input)
|
|
150
|
+
}
|
|
151
|
+
return rejectObject(isNullOrUndefined)(input)
|
|
152
|
+
}
|
|
153
|
+
|
|
85
154
|
function complement(fn) {
|
|
86
155
|
return (...input) => !fn(...input)
|
|
87
156
|
}
|
|
88
157
|
|
|
89
158
|
function concat(x) {
|
|
90
|
-
return y => typeof x === 'string' ? `${x}${y}` : [...x, ...y]
|
|
159
|
+
return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
|
|
91
160
|
}
|
|
92
161
|
|
|
93
|
-
|
|
162
|
+
function count(predicate) {
|
|
163
|
+
return list => {
|
|
164
|
+
if (!isArray(list)) {
|
|
165
|
+
return 0
|
|
166
|
+
}
|
|
94
167
|
|
|
95
|
-
|
|
96
|
-
return list => {
|
|
97
|
-
if (!isArray(list)) {
|
|
98
|
-
return 0
|
|
168
|
+
return list.filter(x => predicate(x)).length
|
|
99
169
|
}
|
|
100
|
-
|
|
101
|
-
return list.filter(x => predicate(x)).length
|
|
102
|
-
}
|
|
103
170
|
}
|
|
104
171
|
|
|
105
172
|
function countBy(fn) {
|
|
106
|
-
|
|
107
|
-
|
|
173
|
+
return list => {
|
|
174
|
+
const willReturn = {};
|
|
108
175
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
176
|
+
list.forEach(item => {
|
|
177
|
+
const key = fn(item);
|
|
178
|
+
if (!willReturn[key]) {
|
|
179
|
+
willReturn[key] = 1;
|
|
180
|
+
} else {
|
|
181
|
+
willReturn[key]++;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
117
184
|
|
|
118
|
-
|
|
185
|
+
return willReturn
|
|
186
|
+
}
|
|
119
187
|
}
|
|
188
|
+
|
|
189
|
+
function createObjectFromKeys(keys) {
|
|
190
|
+
return fn => {
|
|
191
|
+
const result = {};
|
|
192
|
+
keys.forEach((key, index) => {
|
|
193
|
+
result[key] = fn(key, index);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return result
|
|
197
|
+
}
|
|
120
198
|
}
|
|
121
199
|
|
|
122
200
|
function isFalsy(input) {
|
|
@@ -131,6 +209,15 @@ function defaultTo(defaultArgument, input) {
|
|
|
131
209
|
return isFalsy(input) ? defaultArgument : input
|
|
132
210
|
}
|
|
133
211
|
|
|
212
|
+
function descend(getFunction) {
|
|
213
|
+
return (a, b) => {
|
|
214
|
+
const aValue = getFunction(a);
|
|
215
|
+
const bValue = getFunction(b);
|
|
216
|
+
|
|
217
|
+
return createCompareFunction(aValue, bValue, 1, -1)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
134
221
|
function drop(howManyToDrop, listOrString) {
|
|
135
222
|
if (arguments.length === 1) {
|
|
136
223
|
return _list => drop(howManyToDrop, _list)
|
|
@@ -140,9 +227,7 @@ function drop(howManyToDrop, listOrString) {
|
|
|
140
227
|
}
|
|
141
228
|
|
|
142
229
|
function dropLast(numberItems) {
|
|
143
|
-
|
|
144
|
-
? list.slice(0, -numberItems)
|
|
145
|
-
: list.slice()
|
|
230
|
+
return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
|
|
146
231
|
}
|
|
147
232
|
|
|
148
233
|
function dropLastWhile(predicate) {
|
|
@@ -302,7 +387,7 @@ function parseRegex(maybeRegex) {
|
|
|
302
387
|
}
|
|
303
388
|
|
|
304
389
|
function equalsFn(a, b) {
|
|
305
|
-
|
|
390
|
+
if (Object.is(a, b)) {
|
|
306
391
|
return true
|
|
307
392
|
}
|
|
308
393
|
|
|
@@ -411,19 +496,15 @@ function equalsFn(a, b) {
|
|
|
411
496
|
return false
|
|
412
497
|
}
|
|
413
498
|
function equals(a) {
|
|
414
|
-
|
|
499
|
+
return b => equalsFn(a, b)
|
|
415
500
|
}
|
|
416
501
|
|
|
417
502
|
function eqBy(fn, a) {
|
|
418
503
|
return b => equalsFn(fn(a), fn(b))
|
|
419
504
|
}
|
|
420
505
|
|
|
421
|
-
function prop(searchProperty) {
|
|
422
|
-
return obj => (obj ? obj[searchProperty] : undefined)
|
|
423
|
-
}
|
|
424
|
-
|
|
425
506
|
function eqProps(property, objA) {
|
|
426
|
-
return objB => equalsFn(
|
|
507
|
+
return objB => equalsFn( objA[property], objB[property] )
|
|
427
508
|
}
|
|
428
509
|
|
|
429
510
|
const { keys } = Object;
|
|
@@ -445,73 +526,30 @@ function mapObject(fn) {
|
|
|
445
526
|
}
|
|
446
527
|
}
|
|
447
528
|
|
|
448
|
-
function evolveFn(rules, obj) {
|
|
449
|
-
return mapObject((x, prop) => {
|
|
450
|
-
if (type(x) === 'Object') {
|
|
451
|
-
const typeRule = type(rules[prop]);
|
|
452
|
-
if (typeRule === 'Function') {
|
|
453
|
-
return rules[prop](x)
|
|
454
|
-
}
|
|
455
|
-
if (typeRule === 'Object') {
|
|
456
|
-
return evolveFn(rules[prop], x)
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return x
|
|
460
|
-
}
|
|
461
|
-
if (type(rules[prop]) === 'Function') {
|
|
462
|
-
return rules[prop](x)
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return x
|
|
466
|
-
})(obj)
|
|
467
|
-
}
|
|
468
|
-
|
|
469
529
|
function evolve(rules) {
|
|
470
|
-
return
|
|
471
|
-
|
|
530
|
+
return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
|
|
531
|
+
}
|
|
472
532
|
|
|
473
533
|
function includes(valueToFind) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
534
|
+
return iterable => {
|
|
535
|
+
if (typeof iterable === 'string') {
|
|
536
|
+
return iterable.includes(valueToFind)
|
|
537
|
+
}
|
|
538
|
+
if (!iterable) {
|
|
539
|
+
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
|
|
540
|
+
}
|
|
541
|
+
if (!isArray(iterable)) {
|
|
542
|
+
return false
|
|
543
|
+
}
|
|
485
544
|
|
|
486
|
-
|
|
487
|
-
}
|
|
545
|
+
return _indexOf(valueToFind, iterable) > -1
|
|
546
|
+
}
|
|
488
547
|
}
|
|
489
548
|
|
|
490
549
|
function excludes(valueToFind) {
|
|
491
550
|
return iterable => !includes(valueToFind)(iterable)
|
|
492
551
|
}
|
|
493
552
|
|
|
494
|
-
function filter(predicate) {
|
|
495
|
-
return list => {
|
|
496
|
-
if (!list) {
|
|
497
|
-
throw new Error('Incorrect iterable input')
|
|
498
|
-
}
|
|
499
|
-
let index = 0;
|
|
500
|
-
const len = list.length;
|
|
501
|
-
const willReturn = [];
|
|
502
|
-
|
|
503
|
-
while (index < len) {
|
|
504
|
-
if (predicate(list[index], index)) {
|
|
505
|
-
willReturn.push(list[index]);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
index++;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return willReturn
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
553
|
function filterObject(predicate) {
|
|
516
554
|
return obj => {
|
|
517
555
|
const willReturn = {};
|
|
@@ -527,62 +565,79 @@ function filterObject(predicate) {
|
|
|
527
565
|
}
|
|
528
566
|
|
|
529
567
|
function find(predicate) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
568
|
+
return list => {
|
|
569
|
+
let index = 0;
|
|
570
|
+
const len = list.length;
|
|
533
571
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
572
|
+
while (index < len) {
|
|
573
|
+
const x = list[index];
|
|
574
|
+
if (predicate(x)) {
|
|
575
|
+
return x
|
|
576
|
+
}
|
|
539
577
|
|
|
540
|
-
|
|
578
|
+
index++;
|
|
579
|
+
}
|
|
541
580
|
}
|
|
542
581
|
}
|
|
543
|
-
}
|
|
544
582
|
|
|
545
583
|
function findIndex(predicate) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
584
|
+
return list => {
|
|
585
|
+
const len = list.length;
|
|
586
|
+
let index = -1;
|
|
549
587
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
588
|
+
while (++index < len) {
|
|
589
|
+
if (predicate(list[index])) {
|
|
590
|
+
return index
|
|
591
|
+
}
|
|
553
592
|
}
|
|
554
|
-
}
|
|
555
593
|
|
|
556
|
-
|
|
557
|
-
}
|
|
594
|
+
return -1
|
|
595
|
+
}
|
|
558
596
|
}
|
|
559
597
|
|
|
560
598
|
function findLast(predicate) {
|
|
561
|
-
|
|
562
|
-
|
|
599
|
+
return list => {
|
|
600
|
+
let index = list.length;
|
|
563
601
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
602
|
+
while (--index >= 0) {
|
|
603
|
+
if (predicate(list[index])) {
|
|
604
|
+
return list[index]
|
|
605
|
+
}
|
|
567
606
|
}
|
|
568
|
-
}
|
|
569
607
|
|
|
570
|
-
|
|
571
|
-
}
|
|
608
|
+
return undefined
|
|
609
|
+
}
|
|
572
610
|
}
|
|
573
611
|
|
|
574
612
|
function findLastIndex(fn) {
|
|
575
|
-
|
|
576
|
-
|
|
613
|
+
return list => {
|
|
614
|
+
let index = list.length;
|
|
577
615
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
616
|
+
while (--index >= 0) {
|
|
617
|
+
if (fn(list[index])) {
|
|
618
|
+
return index
|
|
619
|
+
}
|
|
581
620
|
}
|
|
582
|
-
}
|
|
583
621
|
|
|
584
|
-
|
|
622
|
+
return -1
|
|
623
|
+
}
|
|
585
624
|
}
|
|
625
|
+
|
|
626
|
+
function findNth(predicate, nth) {
|
|
627
|
+
return list => {
|
|
628
|
+
let index = 0;
|
|
629
|
+
const len = list.length;
|
|
630
|
+
|
|
631
|
+
while (index < len) {
|
|
632
|
+
const x = list[index];
|
|
633
|
+
if (predicate(x)) {
|
|
634
|
+
if (nth === 0) return x
|
|
635
|
+
nth--;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
index++;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
586
641
|
}
|
|
587
642
|
|
|
588
643
|
function flatMap(fn) {
|
|
@@ -603,24 +658,25 @@ function flatten(list, input) {
|
|
|
603
658
|
return willReturn
|
|
604
659
|
}
|
|
605
660
|
|
|
606
|
-
function
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
661
|
+
function groupByFallback(groupFn, list) {
|
|
662
|
+
const result = {};
|
|
663
|
+
for (let i = 0; i < list.length; i++) {
|
|
664
|
+
const item = list[i];
|
|
665
|
+
const key = groupFn(item);
|
|
610
666
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const key = groupFn(item);
|
|
667
|
+
if (!result[key]) {
|
|
668
|
+
result[key] = [];
|
|
669
|
+
}
|
|
615
670
|
|
|
616
|
-
|
|
617
|
-
result[key] = [];
|
|
671
|
+
result[key].push(item);
|
|
618
672
|
}
|
|
619
673
|
|
|
620
|
-
result
|
|
621
|
-
|
|
674
|
+
return result
|
|
675
|
+
}
|
|
622
676
|
|
|
623
|
-
|
|
677
|
+
|
|
678
|
+
function groupBy(groupFn) {
|
|
679
|
+
return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
|
|
624
680
|
}
|
|
625
681
|
|
|
626
682
|
function head(listOrString) {
|
|
@@ -697,30 +753,60 @@ function innerJoin(pred, xs) {
|
|
|
697
753
|
return ys => _filter(x => _includesWith(pred, x, ys), xs)
|
|
698
754
|
}
|
|
699
755
|
|
|
756
|
+
const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g);
|
|
757
|
+
const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '');
|
|
758
|
+
|
|
759
|
+
const replace$1 = ({ inputHolder, prop, replacer }) => {
|
|
760
|
+
const regexBase = `{{${prop}}}`;
|
|
761
|
+
const regex = new RegExp(regexBase, 'g');
|
|
762
|
+
return inputHolder.replace(regex, replacer)
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
function interpolate(input) {
|
|
766
|
+
return templateInput => {
|
|
767
|
+
const occurrences = getOccurrences(input);
|
|
768
|
+
if (occurrences === null) {
|
|
769
|
+
return input
|
|
770
|
+
}
|
|
771
|
+
let inputHolder = input;
|
|
772
|
+
|
|
773
|
+
for (const occurrence of occurrences) {
|
|
774
|
+
const prop = getOccurrenceProp(occurrence);
|
|
775
|
+
inputHolder = replace$1({
|
|
776
|
+
inputHolder,
|
|
777
|
+
prop,
|
|
778
|
+
replacer: templateInput[prop],
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return inputHolder
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
700
786
|
function intersection(listA) {
|
|
701
|
-
return listB =>filter(x => includes(x)(listA))(listB)
|
|
787
|
+
return listB => filter(x => includes(x)(listA))(listB)
|
|
702
788
|
}
|
|
703
789
|
|
|
704
790
|
function intersperse(separator) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
791
|
+
return list => {
|
|
792
|
+
let index = -1;
|
|
793
|
+
const len = list.length;
|
|
794
|
+
const willReturn = [];
|
|
709
795
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
796
|
+
while (++index < len) {
|
|
797
|
+
if (index === len - 1) {
|
|
798
|
+
willReturn.push(list[index]);
|
|
799
|
+
} else {
|
|
800
|
+
willReturn.push(list[index], separator);
|
|
801
|
+
}
|
|
715
802
|
}
|
|
716
|
-
}
|
|
717
803
|
|
|
718
|
-
|
|
719
|
-
}
|
|
804
|
+
return willReturn
|
|
805
|
+
}
|
|
720
806
|
}
|
|
721
807
|
|
|
722
808
|
function join(glue) {
|
|
723
|
-
return list=> list.join(glue)
|
|
809
|
+
return list => list.join(glue)
|
|
724
810
|
}
|
|
725
811
|
|
|
726
812
|
function last(listOrString) {
|
|
@@ -748,34 +834,50 @@ function map(fn) {
|
|
|
748
834
|
}
|
|
749
835
|
|
|
750
836
|
function mapAsync(fn) {
|
|
751
|
-
|
|
752
|
-
|
|
837
|
+
return async list => {
|
|
838
|
+
const willReturn = [];
|
|
753
839
|
let i = 0;
|
|
754
840
|
for (const a of list) {
|
|
755
841
|
willReturn.push(await fn(a, i++));
|
|
756
842
|
}
|
|
757
843
|
|
|
758
844
|
return willReturn
|
|
759
|
-
|
|
845
|
+
}
|
|
760
846
|
}
|
|
761
847
|
|
|
762
|
-
function
|
|
763
|
-
|
|
848
|
+
function mapKeys(fn) {
|
|
849
|
+
return obj => {
|
|
764
850
|
const willReturn = {};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
851
|
+
|
|
852
|
+
Object.keys(obj).forEach(key => {
|
|
853
|
+
willReturn[fn(key, obj[key])] = obj[key];
|
|
854
|
+
});
|
|
855
|
+
|
|
769
856
|
return willReturn
|
|
770
857
|
}
|
|
771
858
|
}
|
|
772
859
|
|
|
860
|
+
function mapObjectAsync(fn) {
|
|
861
|
+
return async obj => {
|
|
862
|
+
const willReturn = {};
|
|
863
|
+
for (const prop in obj) {
|
|
864
|
+
willReturn[prop] = await fn(obj[prop], prop);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
return willReturn
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function mapParallelAsync(fn) {
|
|
872
|
+
return async list => Promise.all(list.map((x, i) => fn(x, i)))
|
|
873
|
+
}
|
|
874
|
+
|
|
773
875
|
function match(pattern) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
876
|
+
return input => {
|
|
877
|
+
const willReturn = input.match(pattern);
|
|
878
|
+
|
|
879
|
+
return willReturn === null ? [] : willReturn
|
|
880
|
+
}
|
|
779
881
|
}
|
|
780
882
|
|
|
781
883
|
function maxBy(compareFn, x) {
|
|
@@ -795,66 +897,33 @@ function minBy(compareFn, x) {
|
|
|
795
897
|
return y => (compareFn(y) < compareFn(x) ? y : x)
|
|
796
898
|
}
|
|
797
899
|
|
|
798
|
-
function
|
|
799
|
-
return
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
function path(pathInput, obj) {
|
|
805
|
-
if (arguments.length === 1) {
|
|
806
|
-
return _obj => path(pathInput, _obj)
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
if (!obj) {
|
|
810
|
-
return undefined
|
|
811
|
-
}
|
|
812
|
-
let willReturn = obj;
|
|
813
|
-
let counter = 0;
|
|
814
|
-
|
|
815
|
-
const pathArrValue = createPath(pathInput);
|
|
816
|
-
|
|
817
|
-
while (counter < pathArrValue.length) {
|
|
818
|
-
if (willReturn === null || willReturn === undefined) {
|
|
819
|
-
return undefined
|
|
820
|
-
}
|
|
821
|
-
if (willReturn[pathArrValue[counter]] === null) {
|
|
822
|
-
return undefined
|
|
900
|
+
function update(index, newValue) {
|
|
901
|
+
return list => {
|
|
902
|
+
const clone = cloneList$1(list);
|
|
903
|
+
if (index === -1) {
|
|
904
|
+
return clone.fill(newValue, index)
|
|
823
905
|
}
|
|
824
906
|
|
|
825
|
-
|
|
826
|
-
counter++;
|
|
907
|
+
return clone.fill(newValue, index, index + 1)
|
|
827
908
|
}
|
|
828
|
-
|
|
829
|
-
return willReturn
|
|
830
909
|
}
|
|
831
910
|
|
|
832
|
-
function
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
return {
|
|
840
|
-
...obj,
|
|
841
|
-
[path$1[0]]: fn(obj[path$1[0]]),
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
if (path(path$1)(obj) === undefined) {
|
|
845
|
-
return obj
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
const val = modifyPathFn(Array.prototype.slice.call(path$1, 1), fn, obj[path$1[0]]);
|
|
849
|
-
if (val === obj[path$1[0]]) {
|
|
850
|
-
return obj
|
|
851
|
-
}
|
|
911
|
+
function modifyFn(property, fn, list) {
|
|
912
|
+
if (list[property] === undefined) {
|
|
913
|
+
return list
|
|
914
|
+
}
|
|
915
|
+
if (isArray(list)) {
|
|
916
|
+
return update(property, fn(list[property]))(list)
|
|
917
|
+
}
|
|
852
918
|
|
|
853
|
-
|
|
919
|
+
return {
|
|
920
|
+
...list,
|
|
921
|
+
[property]: fn(list[property]),
|
|
922
|
+
}
|
|
854
923
|
}
|
|
855
924
|
|
|
856
|
-
function
|
|
857
|
-
return obj =>
|
|
925
|
+
function modifyProp(property, fn) {
|
|
926
|
+
return obj => modifyFn(property, fn, obj)
|
|
858
927
|
}
|
|
859
928
|
|
|
860
929
|
function none(predicate) {
|
|
@@ -873,6 +942,22 @@ function objOf(key) {
|
|
|
873
942
|
return value => ({ [key]: value })
|
|
874
943
|
}
|
|
875
944
|
|
|
945
|
+
function objectIncludes(condition) {
|
|
946
|
+
return obj => {
|
|
947
|
+
const result = filterObject((conditionValue, conditionProp) =>
|
|
948
|
+
equals(conditionValue)(obj[conditionProp]),
|
|
949
|
+
)(condition);
|
|
950
|
+
|
|
951
|
+
return Object.keys(result).length === Object.keys(condition).length
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function createPath(path, delimiter = '.') {
|
|
956
|
+
return typeof path === 'string'
|
|
957
|
+
? path.split(delimiter).map(x => (Number.isInteger(Number(x)) ? Number(x) : x))
|
|
958
|
+
: path
|
|
959
|
+
}
|
|
960
|
+
|
|
876
961
|
function _includes(x, list) {
|
|
877
962
|
let index = -1;
|
|
878
963
|
const { length } = list;
|
|
@@ -905,10 +990,29 @@ function omit(propsToOmit) {
|
|
|
905
990
|
}
|
|
906
991
|
}
|
|
907
992
|
|
|
908
|
-
function
|
|
993
|
+
function partition(predicate) {
|
|
994
|
+
return list => {
|
|
995
|
+
const yes = [];
|
|
996
|
+
const no = [];
|
|
997
|
+
let counter = -1;
|
|
998
|
+
|
|
999
|
+
while (counter++ < list.length - 1) {
|
|
1000
|
+
if (predicate(list[counter], counter)) {
|
|
1001
|
+
yes.push(list[counter]);
|
|
1002
|
+
} else {
|
|
1003
|
+
no.push(list[counter]);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
return [yes, no]
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function partitionObject(predicate) {
|
|
1012
|
+
return obj => {
|
|
909
1013
|
const yes = {};
|
|
910
1014
|
const no = {};
|
|
911
|
-
Object.entries(
|
|
1015
|
+
Object.entries(obj).forEach(([prop, value]) => {
|
|
912
1016
|
if (predicate(value, prop)) {
|
|
913
1017
|
yes[prop] = value;
|
|
914
1018
|
} else {
|
|
@@ -918,31 +1022,73 @@ function partitionObject(predicate, iterable) {
|
|
|
918
1022
|
|
|
919
1023
|
return [yes, no]
|
|
920
1024
|
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function path(pathInput, obj) {
|
|
1028
|
+
if (arguments.length === 1) {
|
|
1029
|
+
return _obj => path(pathInput, _obj)
|
|
1030
|
+
}
|
|
921
1031
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
let
|
|
1032
|
+
if (!obj) {
|
|
1033
|
+
return undefined
|
|
1034
|
+
}
|
|
1035
|
+
let willReturn = obj;
|
|
1036
|
+
let counter = 0;
|
|
926
1037
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1038
|
+
const pathArrValue = createPath(pathInput);
|
|
1039
|
+
|
|
1040
|
+
while (counter < pathArrValue.length) {
|
|
1041
|
+
if (willReturn === null || willReturn === undefined) {
|
|
1042
|
+
return undefined
|
|
932
1043
|
}
|
|
1044
|
+
if (willReturn[pathArrValue[counter]] === null) {
|
|
1045
|
+
return undefined
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
willReturn = willReturn[pathArrValue[counter]];
|
|
1049
|
+
counter++;
|
|
933
1050
|
}
|
|
934
1051
|
|
|
935
|
-
return
|
|
1052
|
+
return willReturn
|
|
936
1053
|
}
|
|
937
1054
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1055
|
+
/**
|
|
1056
|
+
* Source:
|
|
1057
|
+
* https://github.com/denoland/std/blob/main/collections/permutations.ts
|
|
1058
|
+
*/
|
|
1059
|
+
function permutations(inputArray) {
|
|
1060
|
+
const result = [];
|
|
1061
|
+
const array = cloneList$1(inputArray);
|
|
1062
|
+
const k = array.length;
|
|
1063
|
+
if (k === 0) {
|
|
1064
|
+
return result;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const c = new Array(k).fill(0);
|
|
1068
|
+
|
|
1069
|
+
result.push([...array]);
|
|
1070
|
+
|
|
1071
|
+
let i = 1;
|
|
1072
|
+
|
|
1073
|
+
while (i < k) {
|
|
1074
|
+
if (c[i] < i) {
|
|
1075
|
+
if (i % 2 === 0) {
|
|
1076
|
+
[array[0], array[i]] = [array[i], array[0]];
|
|
1077
|
+
} else {
|
|
1078
|
+
[array[c[i]], array[i]] = [array[i], array[c[i]]];
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
result.push([...array]);
|
|
1082
|
+
|
|
1083
|
+
c[i] += 1;
|
|
1084
|
+
i = 1;
|
|
1085
|
+
} else {
|
|
1086
|
+
c[i] = 0;
|
|
1087
|
+
i += 1;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
return result;
|
|
946
1092
|
}
|
|
947
1093
|
|
|
948
1094
|
function pick(propsToPick) {
|
|
@@ -1065,30 +1211,35 @@ function pipe(...inputs) {
|
|
|
1065
1211
|
}
|
|
1066
1212
|
|
|
1067
1213
|
async function pipeAsync(input, ...fnList) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1214
|
+
let willReturn = input;
|
|
1215
|
+
for (const fn of fnList) {
|
|
1216
|
+
const initialResult = fn(willReturn);
|
|
1217
|
+
willReturn =
|
|
1218
|
+
type(initialResult) === 'Promise' ? await initialResult : initialResult;
|
|
1219
|
+
}
|
|
1220
|
+
return willReturn
|
|
1074
1221
|
}
|
|
1075
1222
|
|
|
1076
1223
|
function pluck(property) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1224
|
+
return list => {
|
|
1225
|
+
const willReturn = [];
|
|
1079
1226
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1227
|
+
list.forEach(x => {
|
|
1228
|
+
if (x[property] !== undefined) {
|
|
1229
|
+
willReturn.push(x[property]);
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1085
1232
|
|
|
1086
|
-
|
|
1087
|
-
}
|
|
1233
|
+
return willReturn
|
|
1234
|
+
}
|
|
1088
1235
|
}
|
|
1089
1236
|
|
|
1090
1237
|
function prepend(x) {
|
|
1091
|
-
return list=> [x].concat(list)
|
|
1238
|
+
return list => [x].concat(list)
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
function prop(searchProperty) {
|
|
1242
|
+
return obj => (obj ? obj[searchProperty] : undefined)
|
|
1092
1243
|
}
|
|
1093
1244
|
|
|
1094
1245
|
function propEq(valueToMatch, propToFind) {
|
|
@@ -1112,30 +1263,49 @@ function propOr(defaultValue, property) {
|
|
|
1112
1263
|
}
|
|
1113
1264
|
|
|
1114
1265
|
function propSatisfies(predicate, property) {
|
|
1115
|
-
return obj => predicate(
|
|
1266
|
+
return obj => predicate(obj[property])
|
|
1116
1267
|
}
|
|
1117
1268
|
|
|
1118
|
-
function range(start){
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1269
|
+
function range(start) {
|
|
1270
|
+
return end => {
|
|
1271
|
+
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
1272
|
+
throw new TypeError('Both arguments to range must be numbers')
|
|
1273
|
+
}
|
|
1123
1274
|
|
|
1124
|
-
|
|
1275
|
+
if (end <= start) {
|
|
1276
|
+
return []
|
|
1277
|
+
}
|
|
1125
1278
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1279
|
+
const len = end - start;
|
|
1280
|
+
const willReturn = Array(len);
|
|
1128
1281
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1282
|
+
for (let i = 0; i < len + 1; i++) {
|
|
1283
|
+
willReturn[i] = start + i;
|
|
1284
|
+
}
|
|
1132
1285
|
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1286
|
+
return willReturn
|
|
1287
|
+
}
|
|
1135
1288
|
}
|
|
1136
1289
|
|
|
1137
|
-
function
|
|
1138
|
-
return
|
|
1290
|
+
function rangeDescending(start) {
|
|
1291
|
+
return end => {
|
|
1292
|
+
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
1293
|
+
throw new TypeError('Both arguments to range must be numbers')
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
if (end >= start) {
|
|
1297
|
+
return []
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
const len = start - end;
|
|
1301
|
+
const willReturn = Array(len);
|
|
1302
|
+
|
|
1303
|
+
for (let i = 0; i < len + 1; i++) {
|
|
1304
|
+
willReturn[i] = start - i;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
return willReturn
|
|
1308
|
+
}
|
|
1139
1309
|
}
|
|
1140
1310
|
|
|
1141
1311
|
function replace(pattern, replacer) {
|
|
@@ -1149,30 +1319,60 @@ function replaceItemAtIndex(index, replaceFn) {
|
|
|
1149
1319
|
return list
|
|
1150
1320
|
}
|
|
1151
1321
|
|
|
1152
|
-
const clone = cloneList(list);
|
|
1322
|
+
const clone = cloneList$1(list);
|
|
1153
1323
|
clone[actualIndex] = replaceFn(clone[actualIndex]);
|
|
1154
1324
|
|
|
1155
1325
|
return clone
|
|
1156
1326
|
}
|
|
1157
1327
|
}
|
|
1158
1328
|
|
|
1159
|
-
function
|
|
1160
|
-
|
|
1329
|
+
function shuffle(listInput) {
|
|
1330
|
+
const list = cloneList(listInput);
|
|
1331
|
+
let counter = list.length;
|
|
1332
|
+
while (counter > 0) {
|
|
1333
|
+
const index = Math.floor(Math.random() * counter);
|
|
1334
|
+
counter--;
|
|
1335
|
+
const temp = list[counter];
|
|
1336
|
+
list[counter] = list[index];
|
|
1337
|
+
list[index] = temp;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
return list
|
|
1161
1341
|
}
|
|
1162
1342
|
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1165
|
-
|
|
1343
|
+
function sort(sortFn) {
|
|
1344
|
+
return list => cloneList$1(list).sort(sortFn)
|
|
1345
|
+
}
|
|
1166
1346
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const
|
|
1347
|
+
function sortBy(sortFn) {
|
|
1348
|
+
return list => {
|
|
1349
|
+
const clone = cloneList$1(list);
|
|
1170
1350
|
|
|
1171
|
-
|
|
1351
|
+
return clone.sort((a, b) => {
|
|
1352
|
+
const aSortResult = sortFn(a);
|
|
1353
|
+
const bSortResult = sortFn(b);
|
|
1172
1354
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1355
|
+
if (aSortResult === bSortResult) {
|
|
1356
|
+
return 0
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
return aSortResult < bSortResult ? -1 : 1
|
|
1360
|
+
})
|
|
1361
|
+
}
|
|
1175
1362
|
}
|
|
1363
|
+
|
|
1364
|
+
function sortObject(predicate) {
|
|
1365
|
+
return obj => {
|
|
1366
|
+
const keys = Object.keys(obj);
|
|
1367
|
+
const sortedKeys = sort((a, b) => predicate(a, b, obj[a], obj[b]))(keys);
|
|
1368
|
+
|
|
1369
|
+
const toReturn = {};
|
|
1370
|
+
sortedKeys.forEach(singleKey => {
|
|
1371
|
+
toReturn[singleKey] = obj[singleKey];
|
|
1372
|
+
});
|
|
1373
|
+
|
|
1374
|
+
return toReturn
|
|
1375
|
+
}
|
|
1176
1376
|
}
|
|
1177
1377
|
|
|
1178
1378
|
function sortHelper(a, b, listOfSortingFns) {
|
|
@@ -1187,37 +1387,37 @@ function sortHelper(a, b, listOfSortingFns) {
|
|
|
1187
1387
|
}
|
|
1188
1388
|
|
|
1189
1389
|
function sortWith(listOfSortingFns) {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1390
|
+
return list => {
|
|
1391
|
+
if (Array.isArray(list) === false) {
|
|
1392
|
+
return []
|
|
1393
|
+
}
|
|
1194
1394
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1395
|
+
const clone = list.slice();
|
|
1396
|
+
clone.sort((a, b) => sortHelper(a, b, listOfSortingFns));
|
|
1197
1397
|
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1398
|
+
return clone
|
|
1399
|
+
}
|
|
1200
1400
|
}
|
|
1201
1401
|
|
|
1202
|
-
function split(separator){
|
|
1203
|
-
|
|
1402
|
+
function split(separator) {
|
|
1403
|
+
return str => str.split(separator)
|
|
1204
1404
|
}
|
|
1205
1405
|
|
|
1206
1406
|
function splitEvery(sliceLength) {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1407
|
+
return list => {
|
|
1408
|
+
if (sliceLength < 1) {
|
|
1409
|
+
throw new Error('First argument to splitEvery must be a positive integer')
|
|
1410
|
+
}
|
|
1211
1411
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1412
|
+
const willReturn = [];
|
|
1413
|
+
let counter = 0;
|
|
1214
1414
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1415
|
+
while (counter < list.length) {
|
|
1416
|
+
willReturn.push(list.slice(counter, (counter += sliceLength)));
|
|
1417
|
+
}
|
|
1218
1418
|
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1419
|
+
return willReturn
|
|
1420
|
+
}
|
|
1221
1421
|
}
|
|
1222
1422
|
|
|
1223
1423
|
function symmetricDifference(x) {
|
|
@@ -1263,24 +1463,24 @@ function takeLast(numberOfItems) {
|
|
|
1263
1463
|
}
|
|
1264
1464
|
|
|
1265
1465
|
function takeLastWhile(predicate) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1466
|
+
return input => {
|
|
1467
|
+
if (input.length === 0) {
|
|
1468
|
+
return input
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
const toReturn = [];
|
|
1472
|
+
let counter = input.length;
|
|
1473
|
+
|
|
1474
|
+
while (counter) {
|
|
1475
|
+
const item = input[--counter];
|
|
1476
|
+
if (!predicate(item)) {
|
|
1477
|
+
break
|
|
1478
|
+
}
|
|
1479
|
+
toReturn.push(item);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
return toReturn.reverse()
|
|
1483
|
+
}
|
|
1284
1484
|
}
|
|
1285
1485
|
|
|
1286
1486
|
function takeWhile(predicate) {
|
|
@@ -1300,15 +1500,15 @@ function takeWhile(predicate) {
|
|
|
1300
1500
|
}
|
|
1301
1501
|
|
|
1302
1502
|
function tap(fn) {
|
|
1303
|
-
|
|
1304
|
-
|
|
1503
|
+
return x => {
|
|
1504
|
+
fn(x);
|
|
1305
1505
|
|
|
1306
|
-
|
|
1307
|
-
}
|
|
1506
|
+
return x
|
|
1507
|
+
}
|
|
1308
1508
|
}
|
|
1309
1509
|
|
|
1310
1510
|
function test(pattern) {
|
|
1311
|
-
|
|
1511
|
+
return str => str.search(pattern) !== -1
|
|
1312
1512
|
}
|
|
1313
1513
|
|
|
1314
1514
|
function tryCatch(fn, fallback) {
|
|
@@ -1323,7 +1523,7 @@ function tryCatch(fn, fallback) {
|
|
|
1323
1523
|
|
|
1324
1524
|
function union(x) {
|
|
1325
1525
|
return y => {
|
|
1326
|
-
const toReturn = cloneList(x);
|
|
1526
|
+
const toReturn = cloneList$1(x);
|
|
1327
1527
|
|
|
1328
1528
|
y.forEach(yInstance => {
|
|
1329
1529
|
if (!includes(yInstance)(x)) {
|
|
@@ -1387,11 +1587,11 @@ function uniq(list) {
|
|
|
1387
1587
|
}
|
|
1388
1588
|
|
|
1389
1589
|
function uniqBy(fn) {
|
|
1390
|
-
|
|
1391
|
-
|
|
1590
|
+
return list => {
|
|
1591
|
+
const set = new _Set();
|
|
1392
1592
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1593
|
+
return list.filter(item => set.checkUniqueness(fn(item)))
|
|
1594
|
+
}
|
|
1395
1595
|
}
|
|
1396
1596
|
|
|
1397
1597
|
function includesWith(predicate, target, list) {
|
|
@@ -1410,20 +1610,20 @@ function includesWith(predicate, target, list) {
|
|
|
1410
1610
|
}
|
|
1411
1611
|
|
|
1412
1612
|
function uniqWith(predicate) {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1613
|
+
return list => {
|
|
1614
|
+
let index = -1;
|
|
1615
|
+
const willReturn = [];
|
|
1416
1616
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1617
|
+
while (++index < list.length) {
|
|
1618
|
+
const value = list[index];
|
|
1419
1619
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1620
|
+
if (!includesWith(predicate, value, willReturn)) {
|
|
1621
|
+
willReturn.push(value);
|
|
1622
|
+
}
|
|
1422
1623
|
}
|
|
1423
|
-
}
|
|
1424
1624
|
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1625
|
+
return willReturn
|
|
1626
|
+
}
|
|
1427
1627
|
}
|
|
1428
1628
|
|
|
1429
1629
|
function unless(predicate, whenFalseFn) {
|
|
@@ -1445,17 +1645,6 @@ function unwind(property) {
|
|
|
1445
1645
|
}
|
|
1446
1646
|
}
|
|
1447
1647
|
|
|
1448
|
-
function update(index, newValue) {
|
|
1449
|
-
return list => {
|
|
1450
|
-
const clone = cloneList(list);
|
|
1451
|
-
if (index === -1) {
|
|
1452
|
-
return clone.fill(newValue, index)
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
return clone.fill(newValue, index, index + 1)
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
1648
|
function when(predicate, whenTrueFn) {
|
|
1460
1649
|
return input => {
|
|
1461
1650
|
if (!predicate(input)) {
|
|
@@ -1486,104 +1675,4 @@ function zipWith(fn, x) {
|
|
|
1486
1675
|
)
|
|
1487
1676
|
}
|
|
1488
1677
|
|
|
1489
|
-
|
|
1490
|
-
exports._includes = _includes;
|
|
1491
|
-
exports._indexOf = _indexOf;
|
|
1492
|
-
exports._lastIndexOf = _lastIndexOf;
|
|
1493
|
-
exports.all = all;
|
|
1494
|
-
exports.allPass = allPass;
|
|
1495
|
-
exports.any = any;
|
|
1496
|
-
exports.anyPass = anyPass;
|
|
1497
|
-
exports.append = append;
|
|
1498
|
-
exports.checkObjectWithSpec = checkObjectWithSpec;
|
|
1499
|
-
exports.complement = complement;
|
|
1500
|
-
exports.concat = concat;
|
|
1501
|
-
exports.count = count;
|
|
1502
|
-
exports.countBy = countBy;
|
|
1503
|
-
exports.defaultTo = defaultTo;
|
|
1504
|
-
exports.drop = drop;
|
|
1505
|
-
exports.dropLast = dropLast;
|
|
1506
|
-
exports.dropLastWhile = dropLastWhile;
|
|
1507
|
-
exports.dropWhile = dropWhile;
|
|
1508
|
-
exports.eqBy = eqBy;
|
|
1509
|
-
exports.eqProps = eqProps;
|
|
1510
|
-
exports.equals = equals;
|
|
1511
|
-
exports.equalsFn = equalsFn;
|
|
1512
|
-
exports.evolve = evolve;
|
|
1513
|
-
exports.evolveFn = evolveFn;
|
|
1514
|
-
exports.excludes = excludes;
|
|
1515
|
-
exports.filter = filter;
|
|
1516
|
-
exports.filterObject = filterObject;
|
|
1517
|
-
exports.find = find;
|
|
1518
|
-
exports.findIndex = findIndex;
|
|
1519
|
-
exports.findLast = findLast;
|
|
1520
|
-
exports.findLastIndex = findLastIndex;
|
|
1521
|
-
exports.flatMap = flatMap;
|
|
1522
|
-
exports.flatten = flatten;
|
|
1523
|
-
exports.groupBy = groupBy;
|
|
1524
|
-
exports.head = head;
|
|
1525
|
-
exports.includes = includes;
|
|
1526
|
-
exports.indexOf = indexOf;
|
|
1527
|
-
exports.init = init;
|
|
1528
|
-
exports.innerJoin = innerJoin;
|
|
1529
|
-
exports.intersection = intersection;
|
|
1530
|
-
exports.intersperse = intersperse;
|
|
1531
|
-
exports.join = join;
|
|
1532
|
-
exports.last = last;
|
|
1533
|
-
exports.lastIndexOf = lastIndexOf;
|
|
1534
|
-
exports.map = map;
|
|
1535
|
-
exports.mapAsync = mapAsync;
|
|
1536
|
-
exports.mapObject = mapObject;
|
|
1537
|
-
exports.mapObjectAsync = mapObjectAsync;
|
|
1538
|
-
exports.match = match;
|
|
1539
|
-
exports.maxBy = maxBy;
|
|
1540
|
-
exports.merge = merge;
|
|
1541
|
-
exports.mergeTypes = mergeTypes;
|
|
1542
|
-
exports.minBy = minBy;
|
|
1543
|
-
exports.modifyPath = modifyPath;
|
|
1544
|
-
exports.none = none;
|
|
1545
|
-
exports.objOf = objOf;
|
|
1546
|
-
exports.omit = omit;
|
|
1547
|
-
exports.partition = partition;
|
|
1548
|
-
exports.partitionArray = partitionArray;
|
|
1549
|
-
exports.partitionObject = partitionObject;
|
|
1550
|
-
exports.path = path;
|
|
1551
|
-
exports.pick = pick;
|
|
1552
|
-
exports.pipe = pipe;
|
|
1553
|
-
exports.pipeAsync = pipeAsync;
|
|
1554
|
-
exports.pluck = pluck;
|
|
1555
|
-
exports.prepend = prepend;
|
|
1556
|
-
exports.prop = prop;
|
|
1557
|
-
exports.propEq = propEq;
|
|
1558
|
-
exports.propOr = propOr;
|
|
1559
|
-
exports.propSatisfies = propSatisfies;
|
|
1560
|
-
exports.range = range;
|
|
1561
|
-
exports.reduce = reduce;
|
|
1562
|
-
exports.reject = reject;
|
|
1563
|
-
exports.replace = replace;
|
|
1564
|
-
exports.replaceItemAtIndex = replaceItemAtIndex;
|
|
1565
|
-
exports.sort = sort;
|
|
1566
|
-
exports.sortBy = sortBy;
|
|
1567
|
-
exports.sortWith = sortWith;
|
|
1568
|
-
exports.split = split;
|
|
1569
|
-
exports.splitEvery = splitEvery;
|
|
1570
|
-
exports.symmetricDifference = symmetricDifference;
|
|
1571
|
-
exports.tail = tail;
|
|
1572
|
-
exports.take = take;
|
|
1573
|
-
exports.takeLast = takeLast;
|
|
1574
|
-
exports.takeLastWhile = takeLastWhile;
|
|
1575
|
-
exports.takeWhile = takeWhile;
|
|
1576
|
-
exports.tap = tap;
|
|
1577
|
-
exports.test = test;
|
|
1578
|
-
exports.tryCatch = tryCatch;
|
|
1579
|
-
exports.type = type;
|
|
1580
|
-
exports.union = union;
|
|
1581
|
-
exports.uniq = uniq;
|
|
1582
|
-
exports.uniqBy = uniqBy;
|
|
1583
|
-
exports.uniqWith = uniqWith;
|
|
1584
|
-
exports.unless = unless;
|
|
1585
|
-
exports.unwind = unwind;
|
|
1586
|
-
exports.update = update;
|
|
1587
|
-
exports.when = when;
|
|
1588
|
-
exports.zip = zip;
|
|
1589
|
-
exports.zipWith = zipWith;
|
|
1678
|
+
export { _arity, _includes, _indexOf, _lastIndexOf, addProp, all, allPass, any, anyPass, append, ascend, checkObjectWithSpec, compact, complement, concat, count, countBy, createCompareFunction, createObjectFromKeys, defaultTo, descend, drop, dropLast, dropLastWhile, dropWhile, eqBy, eqProps, equals, equalsFn, evolve, excludes, filter, filterObject, find, findIndex, findLast, findLastIndex, findNth, flatMap, flatten, groupBy, groupByFallback, head, includes, indexOf, init, innerJoin, interpolate, intersection, intersperse, join, last, lastIndexOf, map, mapAsync, mapKeys, mapObject, mapObjectAsync, mapParallelAsync, match, maxBy, merge, mergeTypes, minBy, modifyProp, none, objOf, objectIncludes, omit, partition, partitionObject, path, permutations, pick, pipe, pipeAsync, pluck, prepend, prop, propEq, propOr, propSatisfies, range, rangeDescending, reduce, reject, rejectObject, replace, replaceItemAtIndex, shuffle, sort, sortBy, sortObject, sortWith, split, splitEvery, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, tryCatch, type, union, uniq, uniqBy, uniqWith, unless, unwind, update, when, zip, zipWith };
|