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.umd.js
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.R = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function addProp(key, value) {
|
|
8
|
+
return obj => ({ ...obj, [key]: value })
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
function all(predicate) {
|
|
8
12
|
return list => {
|
|
9
13
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -58,15 +62,32 @@
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
const cloneList = list => Array.prototype.slice.call(list);
|
|
65
|
+
const cloneList$1 = list => Array.prototype.slice.call(list);
|
|
62
66
|
|
|
63
67
|
function append(x) {
|
|
64
|
-
return list=> {
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
return list => {
|
|
69
|
+
const clone = cloneList$1(list);
|
|
70
|
+
clone.push(x);
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
return clone
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function createCompareFunction(a, b, winner, loser) {
|
|
77
|
+
if (a === b) {
|
|
78
|
+
return 0
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return a < b ? winner : loser
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function ascend(getFunction) {
|
|
85
|
+
return (a, b) => {
|
|
86
|
+
const aValue = getFunction(a);
|
|
87
|
+
const bValue = getFunction(b);
|
|
88
|
+
|
|
89
|
+
return createCompareFunction(aValue, bValue, -1, 1)
|
|
90
|
+
}
|
|
70
91
|
}
|
|
71
92
|
|
|
72
93
|
function checkObjectWithSpec(conditions) {
|
|
@@ -86,41 +107,100 @@
|
|
|
86
107
|
}
|
|
87
108
|
}
|
|
88
109
|
|
|
110
|
+
const { isArray } = Array;
|
|
111
|
+
|
|
112
|
+
function filter(predicate) {
|
|
113
|
+
return list => {
|
|
114
|
+
if (!list) {
|
|
115
|
+
throw new Error('Incorrect iterable input')
|
|
116
|
+
}
|
|
117
|
+
let index = 0;
|
|
118
|
+
const len = list.length;
|
|
119
|
+
const willReturn = [];
|
|
120
|
+
|
|
121
|
+
while (index < len) {
|
|
122
|
+
if (predicate(list[index], index)) {
|
|
123
|
+
willReturn.push(list[index]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
index++;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return willReturn
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function reject(predicate) {
|
|
134
|
+
return list => filter(x => !predicate(x))(list)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function rejectObject(predicate) {
|
|
138
|
+
return obj => {
|
|
139
|
+
const willReturn = {};
|
|
140
|
+
|
|
141
|
+
for (const prop in obj) {
|
|
142
|
+
if (!predicate(obj[prop], prop, obj)) {
|
|
143
|
+
willReturn[prop] = obj[prop];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return willReturn
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const isNullOrUndefined = x => x === null || x === undefined;
|
|
152
|
+
|
|
153
|
+
function compact(input){
|
|
154
|
+
if(isArray(input)){
|
|
155
|
+
return reject(isNullOrUndefined)(input)
|
|
156
|
+
}
|
|
157
|
+
return rejectObject(isNullOrUndefined)(input)
|
|
158
|
+
}
|
|
159
|
+
|
|
89
160
|
function complement(fn) {
|
|
90
161
|
return (...input) => !fn(...input)
|
|
91
162
|
}
|
|
92
163
|
|
|
93
164
|
function concat(x) {
|
|
94
|
-
return y => typeof x === 'string' ? `${x}${y}` : [...x, ...y]
|
|
165
|
+
return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
|
|
95
166
|
}
|
|
96
167
|
|
|
97
|
-
|
|
168
|
+
function count(predicate) {
|
|
169
|
+
return list => {
|
|
170
|
+
if (!isArray(list)) {
|
|
171
|
+
return 0
|
|
172
|
+
}
|
|
98
173
|
|
|
99
|
-
|
|
100
|
-
return list => {
|
|
101
|
-
if (!isArray(list)) {
|
|
102
|
-
return 0
|
|
174
|
+
return list.filter(x => predicate(x)).length
|
|
103
175
|
}
|
|
104
|
-
|
|
105
|
-
return list.filter(x => predicate(x)).length
|
|
106
|
-
}
|
|
107
176
|
}
|
|
108
177
|
|
|
109
178
|
function countBy(fn) {
|
|
110
|
-
|
|
111
|
-
|
|
179
|
+
return list => {
|
|
180
|
+
const willReturn = {};
|
|
112
181
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
182
|
+
list.forEach(item => {
|
|
183
|
+
const key = fn(item);
|
|
184
|
+
if (!willReturn[key]) {
|
|
185
|
+
willReturn[key] = 1;
|
|
186
|
+
} else {
|
|
187
|
+
willReturn[key]++;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
121
190
|
|
|
122
|
-
|
|
191
|
+
return willReturn
|
|
192
|
+
}
|
|
123
193
|
}
|
|
194
|
+
|
|
195
|
+
function createObjectFromKeys(keys) {
|
|
196
|
+
return fn => {
|
|
197
|
+
const result = {};
|
|
198
|
+
keys.forEach((key, index) => {
|
|
199
|
+
result[key] = fn(key, index);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
return result
|
|
203
|
+
}
|
|
124
204
|
}
|
|
125
205
|
|
|
126
206
|
function isFalsy(input) {
|
|
@@ -135,6 +215,15 @@
|
|
|
135
215
|
return isFalsy(input) ? defaultArgument : input
|
|
136
216
|
}
|
|
137
217
|
|
|
218
|
+
function descend(getFunction) {
|
|
219
|
+
return (a, b) => {
|
|
220
|
+
const aValue = getFunction(a);
|
|
221
|
+
const bValue = getFunction(b);
|
|
222
|
+
|
|
223
|
+
return createCompareFunction(aValue, bValue, 1, -1)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
138
227
|
function drop(howManyToDrop, listOrString) {
|
|
139
228
|
if (arguments.length === 1) {
|
|
140
229
|
return _list => drop(howManyToDrop, _list)
|
|
@@ -144,9 +233,7 @@
|
|
|
144
233
|
}
|
|
145
234
|
|
|
146
235
|
function dropLast(numberItems) {
|
|
147
|
-
|
|
148
|
-
? list.slice(0, -numberItems)
|
|
149
|
-
: list.slice()
|
|
236
|
+
return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
|
|
150
237
|
}
|
|
151
238
|
|
|
152
239
|
function dropLastWhile(predicate) {
|
|
@@ -306,7 +393,7 @@
|
|
|
306
393
|
}
|
|
307
394
|
|
|
308
395
|
function equalsFn(a, b) {
|
|
309
|
-
|
|
396
|
+
if (Object.is(a, b)) {
|
|
310
397
|
return true
|
|
311
398
|
}
|
|
312
399
|
|
|
@@ -415,19 +502,15 @@
|
|
|
415
502
|
return false
|
|
416
503
|
}
|
|
417
504
|
function equals(a) {
|
|
418
|
-
|
|
505
|
+
return b => equalsFn(a, b)
|
|
419
506
|
}
|
|
420
507
|
|
|
421
508
|
function eqBy(fn, a) {
|
|
422
509
|
return b => equalsFn(fn(a), fn(b))
|
|
423
510
|
}
|
|
424
511
|
|
|
425
|
-
function prop(searchProperty) {
|
|
426
|
-
return obj => (obj ? obj[searchProperty] : undefined)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
512
|
function eqProps(property, objA) {
|
|
430
|
-
return objB => equalsFn(
|
|
513
|
+
return objB => equalsFn( objA[property], objB[property] )
|
|
431
514
|
}
|
|
432
515
|
|
|
433
516
|
const { keys } = Object;
|
|
@@ -449,73 +532,30 @@
|
|
|
449
532
|
}
|
|
450
533
|
}
|
|
451
534
|
|
|
452
|
-
function evolveFn(rules, obj) {
|
|
453
|
-
return mapObject((x, prop) => {
|
|
454
|
-
if (type(x) === 'Object') {
|
|
455
|
-
const typeRule = type(rules[prop]);
|
|
456
|
-
if (typeRule === 'Function') {
|
|
457
|
-
return rules[prop](x)
|
|
458
|
-
}
|
|
459
|
-
if (typeRule === 'Object') {
|
|
460
|
-
return evolveFn(rules[prop], x)
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return x
|
|
464
|
-
}
|
|
465
|
-
if (type(rules[prop]) === 'Function') {
|
|
466
|
-
return rules[prop](x)
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return x
|
|
470
|
-
})(obj)
|
|
471
|
-
}
|
|
472
|
-
|
|
473
535
|
function evolve(rules) {
|
|
474
|
-
return
|
|
475
|
-
|
|
536
|
+
return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
|
|
537
|
+
}
|
|
476
538
|
|
|
477
539
|
function includes(valueToFind) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
540
|
+
return iterable => {
|
|
541
|
+
if (typeof iterable === 'string') {
|
|
542
|
+
return iterable.includes(valueToFind)
|
|
543
|
+
}
|
|
544
|
+
if (!iterable) {
|
|
545
|
+
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
|
|
546
|
+
}
|
|
547
|
+
if (!isArray(iterable)) {
|
|
548
|
+
return false
|
|
549
|
+
}
|
|
489
550
|
|
|
490
|
-
|
|
491
|
-
|
|
551
|
+
return _indexOf(valueToFind, iterable) > -1
|
|
552
|
+
}
|
|
492
553
|
}
|
|
493
554
|
|
|
494
555
|
function excludes(valueToFind) {
|
|
495
556
|
return iterable => !includes(valueToFind)(iterable)
|
|
496
557
|
}
|
|
497
558
|
|
|
498
|
-
function filter(predicate) {
|
|
499
|
-
return list => {
|
|
500
|
-
if (!list) {
|
|
501
|
-
throw new Error('Incorrect iterable input')
|
|
502
|
-
}
|
|
503
|
-
let index = 0;
|
|
504
|
-
const len = list.length;
|
|
505
|
-
const willReturn = [];
|
|
506
|
-
|
|
507
|
-
while (index < len) {
|
|
508
|
-
if (predicate(list[index], index)) {
|
|
509
|
-
willReturn.push(list[index]);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
index++;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
return willReturn
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
559
|
function filterObject(predicate) {
|
|
520
560
|
return obj => {
|
|
521
561
|
const willReturn = {};
|
|
@@ -531,62 +571,79 @@
|
|
|
531
571
|
}
|
|
532
572
|
|
|
533
573
|
function find(predicate) {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
574
|
+
return list => {
|
|
575
|
+
let index = 0;
|
|
576
|
+
const len = list.length;
|
|
537
577
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
578
|
+
while (index < len) {
|
|
579
|
+
const x = list[index];
|
|
580
|
+
if (predicate(x)) {
|
|
581
|
+
return x
|
|
582
|
+
}
|
|
543
583
|
|
|
544
|
-
|
|
584
|
+
index++;
|
|
585
|
+
}
|
|
545
586
|
}
|
|
546
587
|
}
|
|
547
|
-
}
|
|
548
588
|
|
|
549
589
|
function findIndex(predicate) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
590
|
+
return list => {
|
|
591
|
+
const len = list.length;
|
|
592
|
+
let index = -1;
|
|
553
593
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
594
|
+
while (++index < len) {
|
|
595
|
+
if (predicate(list[index])) {
|
|
596
|
+
return index
|
|
597
|
+
}
|
|
557
598
|
}
|
|
558
|
-
}
|
|
559
599
|
|
|
560
|
-
|
|
561
|
-
|
|
600
|
+
return -1
|
|
601
|
+
}
|
|
562
602
|
}
|
|
563
603
|
|
|
564
604
|
function findLast(predicate) {
|
|
565
|
-
|
|
566
|
-
|
|
605
|
+
return list => {
|
|
606
|
+
let index = list.length;
|
|
567
607
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
608
|
+
while (--index >= 0) {
|
|
609
|
+
if (predicate(list[index])) {
|
|
610
|
+
return list[index]
|
|
611
|
+
}
|
|
571
612
|
}
|
|
572
|
-
}
|
|
573
613
|
|
|
574
|
-
|
|
575
|
-
|
|
614
|
+
return undefined
|
|
615
|
+
}
|
|
576
616
|
}
|
|
577
617
|
|
|
578
618
|
function findLastIndex(fn) {
|
|
579
|
-
|
|
580
|
-
|
|
619
|
+
return list => {
|
|
620
|
+
let index = list.length;
|
|
581
621
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
622
|
+
while (--index >= 0) {
|
|
623
|
+
if (fn(list[index])) {
|
|
624
|
+
return index
|
|
625
|
+
}
|
|
585
626
|
}
|
|
586
|
-
}
|
|
587
627
|
|
|
588
|
-
|
|
628
|
+
return -1
|
|
629
|
+
}
|
|
589
630
|
}
|
|
631
|
+
|
|
632
|
+
function findNth(predicate, nth) {
|
|
633
|
+
return list => {
|
|
634
|
+
let index = 0;
|
|
635
|
+
const len = list.length;
|
|
636
|
+
|
|
637
|
+
while (index < len) {
|
|
638
|
+
const x = list[index];
|
|
639
|
+
if (predicate(x)) {
|
|
640
|
+
if (nth === 0) return x
|
|
641
|
+
nth--;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
index++;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
590
647
|
}
|
|
591
648
|
|
|
592
649
|
function flatMap(fn) {
|
|
@@ -607,24 +664,25 @@
|
|
|
607
664
|
return willReturn
|
|
608
665
|
}
|
|
609
666
|
|
|
610
|
-
function
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
667
|
+
function groupByFallback(groupFn, list) {
|
|
668
|
+
const result = {};
|
|
669
|
+
for (let i = 0; i < list.length; i++) {
|
|
670
|
+
const item = list[i];
|
|
671
|
+
const key = groupFn(item);
|
|
614
672
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const key = groupFn(item);
|
|
673
|
+
if (!result[key]) {
|
|
674
|
+
result[key] = [];
|
|
675
|
+
}
|
|
619
676
|
|
|
620
|
-
|
|
621
|
-
result[key] = [];
|
|
677
|
+
result[key].push(item);
|
|
622
678
|
}
|
|
623
679
|
|
|
624
|
-
result
|
|
625
|
-
|
|
680
|
+
return result
|
|
681
|
+
}
|
|
626
682
|
|
|
627
|
-
|
|
683
|
+
|
|
684
|
+
function groupBy(groupFn) {
|
|
685
|
+
return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
|
|
628
686
|
}
|
|
629
687
|
|
|
630
688
|
function head(listOrString) {
|
|
@@ -701,30 +759,60 @@
|
|
|
701
759
|
return ys => _filter(x => _includesWith(pred, x, ys), xs)
|
|
702
760
|
}
|
|
703
761
|
|
|
762
|
+
const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g);
|
|
763
|
+
const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '');
|
|
764
|
+
|
|
765
|
+
const replace$1 = ({ inputHolder, prop, replacer }) => {
|
|
766
|
+
const regexBase = `{{${prop}}}`;
|
|
767
|
+
const regex = new RegExp(regexBase, 'g');
|
|
768
|
+
return inputHolder.replace(regex, replacer)
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
function interpolate(input) {
|
|
772
|
+
return templateInput => {
|
|
773
|
+
const occurrences = getOccurrences(input);
|
|
774
|
+
if (occurrences === null) {
|
|
775
|
+
return input
|
|
776
|
+
}
|
|
777
|
+
let inputHolder = input;
|
|
778
|
+
|
|
779
|
+
for (const occurrence of occurrences) {
|
|
780
|
+
const prop = getOccurrenceProp(occurrence);
|
|
781
|
+
inputHolder = replace$1({
|
|
782
|
+
inputHolder,
|
|
783
|
+
prop,
|
|
784
|
+
replacer: templateInput[prop],
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
return inputHolder
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
704
792
|
function intersection(listA) {
|
|
705
|
-
return listB =>filter(x => includes(x)(listA))(listB)
|
|
793
|
+
return listB => filter(x => includes(x)(listA))(listB)
|
|
706
794
|
}
|
|
707
795
|
|
|
708
796
|
function intersperse(separator) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
797
|
+
return list => {
|
|
798
|
+
let index = -1;
|
|
799
|
+
const len = list.length;
|
|
800
|
+
const willReturn = [];
|
|
713
801
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
802
|
+
while (++index < len) {
|
|
803
|
+
if (index === len - 1) {
|
|
804
|
+
willReturn.push(list[index]);
|
|
805
|
+
} else {
|
|
806
|
+
willReturn.push(list[index], separator);
|
|
807
|
+
}
|
|
719
808
|
}
|
|
720
|
-
}
|
|
721
809
|
|
|
722
|
-
|
|
723
|
-
|
|
810
|
+
return willReturn
|
|
811
|
+
}
|
|
724
812
|
}
|
|
725
813
|
|
|
726
814
|
function join(glue) {
|
|
727
|
-
return list=> list.join(glue)
|
|
815
|
+
return list => list.join(glue)
|
|
728
816
|
}
|
|
729
817
|
|
|
730
818
|
function last(listOrString) {
|
|
@@ -752,34 +840,50 @@
|
|
|
752
840
|
}
|
|
753
841
|
|
|
754
842
|
function mapAsync(fn) {
|
|
755
|
-
|
|
756
|
-
|
|
843
|
+
return async list => {
|
|
844
|
+
const willReturn = [];
|
|
757
845
|
let i = 0;
|
|
758
846
|
for (const a of list) {
|
|
759
847
|
willReturn.push(await fn(a, i++));
|
|
760
848
|
}
|
|
761
849
|
|
|
762
850
|
return willReturn
|
|
763
|
-
|
|
851
|
+
}
|
|
764
852
|
}
|
|
765
853
|
|
|
766
|
-
function
|
|
767
|
-
|
|
854
|
+
function mapKeys(fn) {
|
|
855
|
+
return obj => {
|
|
768
856
|
const willReturn = {};
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
857
|
+
|
|
858
|
+
Object.keys(obj).forEach(key => {
|
|
859
|
+
willReturn[fn(key, obj[key])] = obj[key];
|
|
860
|
+
});
|
|
861
|
+
|
|
773
862
|
return willReturn
|
|
774
863
|
}
|
|
775
864
|
}
|
|
776
865
|
|
|
866
|
+
function mapObjectAsync(fn) {
|
|
867
|
+
return async obj => {
|
|
868
|
+
const willReturn = {};
|
|
869
|
+
for (const prop in obj) {
|
|
870
|
+
willReturn[prop] = await fn(obj[prop], prop);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
return willReturn
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function mapParallelAsync(fn) {
|
|
878
|
+
return async list => Promise.all(list.map((x, i) => fn(x, i)))
|
|
879
|
+
}
|
|
880
|
+
|
|
777
881
|
function match(pattern) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
882
|
+
return input => {
|
|
883
|
+
const willReturn = input.match(pattern);
|
|
884
|
+
|
|
885
|
+
return willReturn === null ? [] : willReturn
|
|
886
|
+
}
|
|
783
887
|
}
|
|
784
888
|
|
|
785
889
|
function maxBy(compareFn, x) {
|
|
@@ -799,66 +903,33 @@
|
|
|
799
903
|
return y => (compareFn(y) < compareFn(x) ? y : x)
|
|
800
904
|
}
|
|
801
905
|
|
|
802
|
-
function
|
|
803
|
-
return
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
function path(pathInput, obj) {
|
|
809
|
-
if (arguments.length === 1) {
|
|
810
|
-
return _obj => path(pathInput, _obj)
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
if (!obj) {
|
|
814
|
-
return undefined
|
|
815
|
-
}
|
|
816
|
-
let willReturn = obj;
|
|
817
|
-
let counter = 0;
|
|
818
|
-
|
|
819
|
-
const pathArrValue = createPath(pathInput);
|
|
820
|
-
|
|
821
|
-
while (counter < pathArrValue.length) {
|
|
822
|
-
if (willReturn === null || willReturn === undefined) {
|
|
823
|
-
return undefined
|
|
824
|
-
}
|
|
825
|
-
if (willReturn[pathArrValue[counter]] === null) {
|
|
826
|
-
return undefined
|
|
906
|
+
function update(index, newValue) {
|
|
907
|
+
return list => {
|
|
908
|
+
const clone = cloneList$1(list);
|
|
909
|
+
if (index === -1) {
|
|
910
|
+
return clone.fill(newValue, index)
|
|
827
911
|
}
|
|
828
912
|
|
|
829
|
-
|
|
830
|
-
counter++;
|
|
913
|
+
return clone.fill(newValue, index, index + 1)
|
|
831
914
|
}
|
|
832
|
-
|
|
833
|
-
return willReturn
|
|
834
915
|
}
|
|
835
916
|
|
|
836
|
-
function
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return {
|
|
844
|
-
...obj,
|
|
845
|
-
[path$1[0]]: fn(obj[path$1[0]]),
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (path(path$1)(obj) === undefined) {
|
|
849
|
-
return obj
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
const val = modifyPathFn(Array.prototype.slice.call(path$1, 1), fn, obj[path$1[0]]);
|
|
853
|
-
if (val === obj[path$1[0]]) {
|
|
854
|
-
return obj
|
|
855
|
-
}
|
|
917
|
+
function modifyFn(property, fn, list) {
|
|
918
|
+
if (list[property] === undefined) {
|
|
919
|
+
return list
|
|
920
|
+
}
|
|
921
|
+
if (isArray(list)) {
|
|
922
|
+
return update(property, fn(list[property]))(list)
|
|
923
|
+
}
|
|
856
924
|
|
|
857
|
-
|
|
925
|
+
return {
|
|
926
|
+
...list,
|
|
927
|
+
[property]: fn(list[property]),
|
|
928
|
+
}
|
|
858
929
|
}
|
|
859
930
|
|
|
860
|
-
function
|
|
861
|
-
return obj =>
|
|
931
|
+
function modifyProp(property, fn) {
|
|
932
|
+
return obj => modifyFn(property, fn, obj)
|
|
862
933
|
}
|
|
863
934
|
|
|
864
935
|
function none(predicate) {
|
|
@@ -877,6 +948,22 @@
|
|
|
877
948
|
return value => ({ [key]: value })
|
|
878
949
|
}
|
|
879
950
|
|
|
951
|
+
function objectIncludes(condition) {
|
|
952
|
+
return obj => {
|
|
953
|
+
const result = filterObject((conditionValue, conditionProp) =>
|
|
954
|
+
equals(conditionValue)(obj[conditionProp]),
|
|
955
|
+
)(condition);
|
|
956
|
+
|
|
957
|
+
return Object.keys(result).length === Object.keys(condition).length
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function createPath(path, delimiter = '.') {
|
|
962
|
+
return typeof path === 'string'
|
|
963
|
+
? path.split(delimiter).map(x => (Number.isInteger(Number(x)) ? Number(x) : x))
|
|
964
|
+
: path
|
|
965
|
+
}
|
|
966
|
+
|
|
880
967
|
function _includes(x, list) {
|
|
881
968
|
let index = -1;
|
|
882
969
|
const { length } = list;
|
|
@@ -909,10 +996,29 @@
|
|
|
909
996
|
}
|
|
910
997
|
}
|
|
911
998
|
|
|
912
|
-
function
|
|
999
|
+
function partition(predicate) {
|
|
1000
|
+
return list => {
|
|
1001
|
+
const yes = [];
|
|
1002
|
+
const no = [];
|
|
1003
|
+
let counter = -1;
|
|
1004
|
+
|
|
1005
|
+
while (counter++ < list.length - 1) {
|
|
1006
|
+
if (predicate(list[counter], counter)) {
|
|
1007
|
+
yes.push(list[counter]);
|
|
1008
|
+
} else {
|
|
1009
|
+
no.push(list[counter]);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return [yes, no]
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function partitionObject(predicate) {
|
|
1018
|
+
return obj => {
|
|
913
1019
|
const yes = {};
|
|
914
1020
|
const no = {};
|
|
915
|
-
Object.entries(
|
|
1021
|
+
Object.entries(obj).forEach(([prop, value]) => {
|
|
916
1022
|
if (predicate(value, prop)) {
|
|
917
1023
|
yes[prop] = value;
|
|
918
1024
|
} else {
|
|
@@ -922,31 +1028,73 @@
|
|
|
922
1028
|
|
|
923
1029
|
return [yes, no]
|
|
924
1030
|
}
|
|
1031
|
+
}
|
|
925
1032
|
|
|
926
|
-
function
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1033
|
+
function path(pathInput, obj) {
|
|
1034
|
+
if (arguments.length === 1) {
|
|
1035
|
+
return _obj => path(pathInput, _obj)
|
|
1036
|
+
}
|
|
930
1037
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1038
|
+
if (!obj) {
|
|
1039
|
+
return undefined
|
|
1040
|
+
}
|
|
1041
|
+
let willReturn = obj;
|
|
1042
|
+
let counter = 0;
|
|
1043
|
+
|
|
1044
|
+
const pathArrValue = createPath(pathInput);
|
|
1045
|
+
|
|
1046
|
+
while (counter < pathArrValue.length) {
|
|
1047
|
+
if (willReturn === null || willReturn === undefined) {
|
|
1048
|
+
return undefined
|
|
1049
|
+
}
|
|
1050
|
+
if (willReturn[pathArrValue[counter]] === null) {
|
|
1051
|
+
return undefined
|
|
936
1052
|
}
|
|
1053
|
+
|
|
1054
|
+
willReturn = willReturn[pathArrValue[counter]];
|
|
1055
|
+
counter++;
|
|
937
1056
|
}
|
|
938
1057
|
|
|
939
|
-
return
|
|
1058
|
+
return willReturn
|
|
940
1059
|
}
|
|
941
1060
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1061
|
+
/**
|
|
1062
|
+
* Source:
|
|
1063
|
+
* https://github.com/denoland/std/blob/main/collections/permutations.ts
|
|
1064
|
+
*/
|
|
1065
|
+
function permutations(inputArray) {
|
|
1066
|
+
const result = [];
|
|
1067
|
+
const array = cloneList$1(inputArray);
|
|
1068
|
+
const k = array.length;
|
|
1069
|
+
if (k === 0) {
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
const c = new Array(k).fill(0);
|
|
1074
|
+
|
|
1075
|
+
result.push([...array]);
|
|
1076
|
+
|
|
1077
|
+
let i = 1;
|
|
1078
|
+
|
|
1079
|
+
while (i < k) {
|
|
1080
|
+
if (c[i] < i) {
|
|
1081
|
+
if (i % 2 === 0) {
|
|
1082
|
+
[array[0], array[i]] = [array[i], array[0]];
|
|
1083
|
+
} else {
|
|
1084
|
+
[array[c[i]], array[i]] = [array[i], array[c[i]]];
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
result.push([...array]);
|
|
1088
|
+
|
|
1089
|
+
c[i] += 1;
|
|
1090
|
+
i = 1;
|
|
1091
|
+
} else {
|
|
1092
|
+
c[i] = 0;
|
|
1093
|
+
i += 1;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
return result;
|
|
950
1098
|
}
|
|
951
1099
|
|
|
952
1100
|
function pick(propsToPick) {
|
|
@@ -1069,30 +1217,35 @@
|
|
|
1069
1217
|
}
|
|
1070
1218
|
|
|
1071
1219
|
async function pipeAsync(input, ...fnList) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1220
|
+
let willReturn = input;
|
|
1221
|
+
for (const fn of fnList) {
|
|
1222
|
+
const initialResult = fn(willReturn);
|
|
1223
|
+
willReturn =
|
|
1224
|
+
type(initialResult) === 'Promise' ? await initialResult : initialResult;
|
|
1225
|
+
}
|
|
1226
|
+
return willReturn
|
|
1078
1227
|
}
|
|
1079
1228
|
|
|
1080
1229
|
function pluck(property) {
|
|
1081
|
-
|
|
1082
|
-
|
|
1230
|
+
return list => {
|
|
1231
|
+
const willReturn = [];
|
|
1083
1232
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1233
|
+
list.forEach(x => {
|
|
1234
|
+
if (x[property] !== undefined) {
|
|
1235
|
+
willReturn.push(x[property]);
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1089
1238
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1239
|
+
return willReturn
|
|
1240
|
+
}
|
|
1092
1241
|
}
|
|
1093
1242
|
|
|
1094
1243
|
function prepend(x) {
|
|
1095
|
-
return list=> [x].concat(list)
|
|
1244
|
+
return list => [x].concat(list)
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
function prop(searchProperty) {
|
|
1248
|
+
return obj => (obj ? obj[searchProperty] : undefined)
|
|
1096
1249
|
}
|
|
1097
1250
|
|
|
1098
1251
|
function propEq(valueToMatch, propToFind) {
|
|
@@ -1116,30 +1269,49 @@
|
|
|
1116
1269
|
}
|
|
1117
1270
|
|
|
1118
1271
|
function propSatisfies(predicate, property) {
|
|
1119
|
-
return obj => predicate(
|
|
1272
|
+
return obj => predicate(obj[property])
|
|
1120
1273
|
}
|
|
1121
1274
|
|
|
1122
|
-
function range(start){
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1275
|
+
function range(start) {
|
|
1276
|
+
return end => {
|
|
1277
|
+
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
1278
|
+
throw new TypeError('Both arguments to range must be numbers')
|
|
1279
|
+
}
|
|
1127
1280
|
|
|
1128
|
-
|
|
1281
|
+
if (end <= start) {
|
|
1282
|
+
return []
|
|
1283
|
+
}
|
|
1129
1284
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1285
|
+
const len = end - start;
|
|
1286
|
+
const willReturn = Array(len);
|
|
1132
1287
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1288
|
+
for (let i = 0; i < len + 1; i++) {
|
|
1289
|
+
willReturn[i] = start + i;
|
|
1290
|
+
}
|
|
1136
1291
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1292
|
+
return willReturn
|
|
1293
|
+
}
|
|
1139
1294
|
}
|
|
1140
1295
|
|
|
1141
|
-
function
|
|
1142
|
-
return
|
|
1296
|
+
function rangeDescending(start) {
|
|
1297
|
+
return end => {
|
|
1298
|
+
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
1299
|
+
throw new TypeError('Both arguments to range must be numbers')
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
if (end >= start) {
|
|
1303
|
+
return []
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
const len = start - end;
|
|
1307
|
+
const willReturn = Array(len);
|
|
1308
|
+
|
|
1309
|
+
for (let i = 0; i < len + 1; i++) {
|
|
1310
|
+
willReturn[i] = start - i;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
return willReturn
|
|
1314
|
+
}
|
|
1143
1315
|
}
|
|
1144
1316
|
|
|
1145
1317
|
function replace(pattern, replacer) {
|
|
@@ -1153,30 +1325,60 @@
|
|
|
1153
1325
|
return list
|
|
1154
1326
|
}
|
|
1155
1327
|
|
|
1156
|
-
const clone = cloneList(list);
|
|
1328
|
+
const clone = cloneList$1(list);
|
|
1157
1329
|
clone[actualIndex] = replaceFn(clone[actualIndex]);
|
|
1158
1330
|
|
|
1159
1331
|
return clone
|
|
1160
1332
|
}
|
|
1161
1333
|
}
|
|
1162
1334
|
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1335
|
+
function shuffle(listInput) {
|
|
1336
|
+
const list = cloneList(listInput);
|
|
1337
|
+
let counter = list.length;
|
|
1338
|
+
while (counter > 0) {
|
|
1339
|
+
const index = Math.floor(Math.random() * counter);
|
|
1340
|
+
counter--;
|
|
1341
|
+
const temp = list[counter];
|
|
1342
|
+
list[counter] = list[index];
|
|
1343
|
+
list[index] = temp;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
return list
|
|
1165
1347
|
}
|
|
1166
1348
|
|
|
1167
|
-
function
|
|
1168
|
-
|
|
1169
|
-
|
|
1349
|
+
function sort(sortFn) {
|
|
1350
|
+
return list => cloneList$1(list).sort(sortFn)
|
|
1351
|
+
}
|
|
1170
1352
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1353
|
+
function sortBy(sortFn) {
|
|
1354
|
+
return list => {
|
|
1355
|
+
const clone = cloneList$1(list);
|
|
1174
1356
|
|
|
1175
|
-
|
|
1357
|
+
return clone.sort((a, b) => {
|
|
1358
|
+
const aSortResult = sortFn(a);
|
|
1359
|
+
const bSortResult = sortFn(b);
|
|
1176
1360
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1361
|
+
if (aSortResult === bSortResult) {
|
|
1362
|
+
return 0
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
return aSortResult < bSortResult ? -1 : 1
|
|
1366
|
+
})
|
|
1367
|
+
}
|
|
1179
1368
|
}
|
|
1369
|
+
|
|
1370
|
+
function sortObject(predicate) {
|
|
1371
|
+
return obj => {
|
|
1372
|
+
const keys = Object.keys(obj);
|
|
1373
|
+
const sortedKeys = sort((a, b) => predicate(a, b, obj[a], obj[b]))(keys);
|
|
1374
|
+
|
|
1375
|
+
const toReturn = {};
|
|
1376
|
+
sortedKeys.forEach(singleKey => {
|
|
1377
|
+
toReturn[singleKey] = obj[singleKey];
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
return toReturn
|
|
1381
|
+
}
|
|
1180
1382
|
}
|
|
1181
1383
|
|
|
1182
1384
|
function sortHelper(a, b, listOfSortingFns) {
|
|
@@ -1191,37 +1393,37 @@
|
|
|
1191
1393
|
}
|
|
1192
1394
|
|
|
1193
1395
|
function sortWith(listOfSortingFns) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1396
|
+
return list => {
|
|
1397
|
+
if (Array.isArray(list) === false) {
|
|
1398
|
+
return []
|
|
1399
|
+
}
|
|
1198
1400
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1401
|
+
const clone = list.slice();
|
|
1402
|
+
clone.sort((a, b) => sortHelper(a, b, listOfSortingFns));
|
|
1201
1403
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1404
|
+
return clone
|
|
1405
|
+
}
|
|
1204
1406
|
}
|
|
1205
1407
|
|
|
1206
|
-
function split(separator){
|
|
1207
|
-
|
|
1408
|
+
function split(separator) {
|
|
1409
|
+
return str => str.split(separator)
|
|
1208
1410
|
}
|
|
1209
1411
|
|
|
1210
1412
|
function splitEvery(sliceLength) {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1413
|
+
return list => {
|
|
1414
|
+
if (sliceLength < 1) {
|
|
1415
|
+
throw new Error('First argument to splitEvery must be a positive integer')
|
|
1416
|
+
}
|
|
1215
1417
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1418
|
+
const willReturn = [];
|
|
1419
|
+
let counter = 0;
|
|
1218
1420
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1421
|
+
while (counter < list.length) {
|
|
1422
|
+
willReturn.push(list.slice(counter, (counter += sliceLength)));
|
|
1423
|
+
}
|
|
1222
1424
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1425
|
+
return willReturn
|
|
1426
|
+
}
|
|
1225
1427
|
}
|
|
1226
1428
|
|
|
1227
1429
|
function symmetricDifference(x) {
|
|
@@ -1267,24 +1469,24 @@
|
|
|
1267
1469
|
}
|
|
1268
1470
|
|
|
1269
1471
|
function takeLastWhile(predicate) {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1472
|
+
return input => {
|
|
1473
|
+
if (input.length === 0) {
|
|
1474
|
+
return input
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
const toReturn = [];
|
|
1478
|
+
let counter = input.length;
|
|
1479
|
+
|
|
1480
|
+
while (counter) {
|
|
1481
|
+
const item = input[--counter];
|
|
1482
|
+
if (!predicate(item)) {
|
|
1483
|
+
break
|
|
1484
|
+
}
|
|
1485
|
+
toReturn.push(item);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
return toReturn.reverse()
|
|
1489
|
+
}
|
|
1288
1490
|
}
|
|
1289
1491
|
|
|
1290
1492
|
function takeWhile(predicate) {
|
|
@@ -1304,15 +1506,15 @@
|
|
|
1304
1506
|
}
|
|
1305
1507
|
|
|
1306
1508
|
function tap(fn) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1509
|
+
return x => {
|
|
1510
|
+
fn(x);
|
|
1309
1511
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1512
|
+
return x
|
|
1513
|
+
}
|
|
1312
1514
|
}
|
|
1313
1515
|
|
|
1314
1516
|
function test(pattern) {
|
|
1315
|
-
|
|
1517
|
+
return str => str.search(pattern) !== -1
|
|
1316
1518
|
}
|
|
1317
1519
|
|
|
1318
1520
|
function tryCatch(fn, fallback) {
|
|
@@ -1327,7 +1529,7 @@
|
|
|
1327
1529
|
|
|
1328
1530
|
function union(x) {
|
|
1329
1531
|
return y => {
|
|
1330
|
-
const toReturn = cloneList(x);
|
|
1532
|
+
const toReturn = cloneList$1(x);
|
|
1331
1533
|
|
|
1332
1534
|
y.forEach(yInstance => {
|
|
1333
1535
|
if (!includes(yInstance)(x)) {
|
|
@@ -1391,11 +1593,11 @@
|
|
|
1391
1593
|
}
|
|
1392
1594
|
|
|
1393
1595
|
function uniqBy(fn) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1596
|
+
return list => {
|
|
1597
|
+
const set = new _Set();
|
|
1396
1598
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1599
|
+
return list.filter(item => set.checkUniqueness(fn(item)))
|
|
1600
|
+
}
|
|
1399
1601
|
}
|
|
1400
1602
|
|
|
1401
1603
|
function includesWith(predicate, target, list) {
|
|
@@ -1414,20 +1616,20 @@
|
|
|
1414
1616
|
}
|
|
1415
1617
|
|
|
1416
1618
|
function uniqWith(predicate) {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1619
|
+
return list => {
|
|
1620
|
+
let index = -1;
|
|
1621
|
+
const willReturn = [];
|
|
1420
1622
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1623
|
+
while (++index < list.length) {
|
|
1624
|
+
const value = list[index];
|
|
1423
1625
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1626
|
+
if (!includesWith(predicate, value, willReturn)) {
|
|
1627
|
+
willReturn.push(value);
|
|
1628
|
+
}
|
|
1426
1629
|
}
|
|
1427
|
-
}
|
|
1428
1630
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1631
|
+
return willReturn
|
|
1632
|
+
}
|
|
1431
1633
|
}
|
|
1432
1634
|
|
|
1433
1635
|
function unless(predicate, whenFalseFn) {
|
|
@@ -1449,17 +1651,6 @@
|
|
|
1449
1651
|
}
|
|
1450
1652
|
}
|
|
1451
1653
|
|
|
1452
|
-
function update(index, newValue) {
|
|
1453
|
-
return list => {
|
|
1454
|
-
const clone = cloneList(list);
|
|
1455
|
-
if (index === -1) {
|
|
1456
|
-
return clone.fill(newValue, index)
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
return clone.fill(newValue, index, index + 1)
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
1654
|
function when(predicate, whenTrueFn) {
|
|
1464
1655
|
return input => {
|
|
1465
1656
|
if (!predicate(input)) {
|
|
@@ -1494,17 +1685,23 @@
|
|
|
1494
1685
|
exports._includes = _includes;
|
|
1495
1686
|
exports._indexOf = _indexOf;
|
|
1496
1687
|
exports._lastIndexOf = _lastIndexOf;
|
|
1688
|
+
exports.addProp = addProp;
|
|
1497
1689
|
exports.all = all;
|
|
1498
1690
|
exports.allPass = allPass;
|
|
1499
1691
|
exports.any = any;
|
|
1500
1692
|
exports.anyPass = anyPass;
|
|
1501
1693
|
exports.append = append;
|
|
1694
|
+
exports.ascend = ascend;
|
|
1502
1695
|
exports.checkObjectWithSpec = checkObjectWithSpec;
|
|
1696
|
+
exports.compact = compact;
|
|
1503
1697
|
exports.complement = complement;
|
|
1504
1698
|
exports.concat = concat;
|
|
1505
1699
|
exports.count = count;
|
|
1506
1700
|
exports.countBy = countBy;
|
|
1701
|
+
exports.createCompareFunction = createCompareFunction;
|
|
1702
|
+
exports.createObjectFromKeys = createObjectFromKeys;
|
|
1507
1703
|
exports.defaultTo = defaultTo;
|
|
1704
|
+
exports.descend = descend;
|
|
1508
1705
|
exports.drop = drop;
|
|
1509
1706
|
exports.dropLast = dropLast;
|
|
1510
1707
|
exports.dropLastWhile = dropLastWhile;
|
|
@@ -1514,7 +1711,6 @@
|
|
|
1514
1711
|
exports.equals = equals;
|
|
1515
1712
|
exports.equalsFn = equalsFn;
|
|
1516
1713
|
exports.evolve = evolve;
|
|
1517
|
-
exports.evolveFn = evolveFn;
|
|
1518
1714
|
exports.excludes = excludes;
|
|
1519
1715
|
exports.filter = filter;
|
|
1520
1716
|
exports.filterObject = filterObject;
|
|
@@ -1522,14 +1718,17 @@
|
|
|
1522
1718
|
exports.findIndex = findIndex;
|
|
1523
1719
|
exports.findLast = findLast;
|
|
1524
1720
|
exports.findLastIndex = findLastIndex;
|
|
1721
|
+
exports.findNth = findNth;
|
|
1525
1722
|
exports.flatMap = flatMap;
|
|
1526
1723
|
exports.flatten = flatten;
|
|
1527
1724
|
exports.groupBy = groupBy;
|
|
1725
|
+
exports.groupByFallback = groupByFallback;
|
|
1528
1726
|
exports.head = head;
|
|
1529
1727
|
exports.includes = includes;
|
|
1530
1728
|
exports.indexOf = indexOf;
|
|
1531
1729
|
exports.init = init;
|
|
1532
1730
|
exports.innerJoin = innerJoin;
|
|
1731
|
+
exports.interpolate = interpolate;
|
|
1533
1732
|
exports.intersection = intersection;
|
|
1534
1733
|
exports.intersperse = intersperse;
|
|
1535
1734
|
exports.join = join;
|
|
@@ -1537,21 +1736,24 @@
|
|
|
1537
1736
|
exports.lastIndexOf = lastIndexOf;
|
|
1538
1737
|
exports.map = map;
|
|
1539
1738
|
exports.mapAsync = mapAsync;
|
|
1739
|
+
exports.mapKeys = mapKeys;
|
|
1540
1740
|
exports.mapObject = mapObject;
|
|
1541
1741
|
exports.mapObjectAsync = mapObjectAsync;
|
|
1742
|
+
exports.mapParallelAsync = mapParallelAsync;
|
|
1542
1743
|
exports.match = match;
|
|
1543
1744
|
exports.maxBy = maxBy;
|
|
1544
1745
|
exports.merge = merge;
|
|
1545
1746
|
exports.mergeTypes = mergeTypes;
|
|
1546
1747
|
exports.minBy = minBy;
|
|
1547
|
-
exports.
|
|
1748
|
+
exports.modifyProp = modifyProp;
|
|
1548
1749
|
exports.none = none;
|
|
1549
1750
|
exports.objOf = objOf;
|
|
1751
|
+
exports.objectIncludes = objectIncludes;
|
|
1550
1752
|
exports.omit = omit;
|
|
1551
1753
|
exports.partition = partition;
|
|
1552
|
-
exports.partitionArray = partitionArray;
|
|
1553
1754
|
exports.partitionObject = partitionObject;
|
|
1554
1755
|
exports.path = path;
|
|
1756
|
+
exports.permutations = permutations;
|
|
1555
1757
|
exports.pick = pick;
|
|
1556
1758
|
exports.pipe = pipe;
|
|
1557
1759
|
exports.pipeAsync = pipeAsync;
|
|
@@ -1562,12 +1764,16 @@
|
|
|
1562
1764
|
exports.propOr = propOr;
|
|
1563
1765
|
exports.propSatisfies = propSatisfies;
|
|
1564
1766
|
exports.range = range;
|
|
1767
|
+
exports.rangeDescending = rangeDescending;
|
|
1565
1768
|
exports.reduce = reduce;
|
|
1566
1769
|
exports.reject = reject;
|
|
1770
|
+
exports.rejectObject = rejectObject;
|
|
1567
1771
|
exports.replace = replace;
|
|
1568
1772
|
exports.replaceItemAtIndex = replaceItemAtIndex;
|
|
1773
|
+
exports.shuffle = shuffle;
|
|
1569
1774
|
exports.sort = sort;
|
|
1570
1775
|
exports.sortBy = sortBy;
|
|
1776
|
+
exports.sortObject = sortObject;
|
|
1571
1777
|
exports.sortWith = sortWith;
|
|
1572
1778
|
exports.split = split;
|
|
1573
1779
|
exports.splitEvery = splitEvery;
|