rambda 8.2.0 → 8.4.0
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 +34 -0
- package/README.md +523 -334
- package/dist/rambda.js +286 -279
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +83 -31
- package/index.d.ts +83 -31
- package/package.json +106 -105
- package/rambda.js +7 -0
- package/src/_internals/_arity.js +64 -0
- package/src/_internals/compare.js +3 -0
- package/src/_internals/createPath.js +5 -1
- package/src/_internals/createPathInput.js +7 -0
- package/src/_internals/includes.js +12 -0
- package/src/_internals/isInteger.js +5 -0
- package/src/assoc.js +1 -1
- package/src/assocPath.js +9 -13
- package/src/binary.js +5 -0
- package/src/call.js +1 -0
- package/src/collectBy.js +27 -0
- package/src/comparator.js +5 -0
- package/src/composeWith.js +33 -0
- package/src/curryN.js +2 -65
- package/src/dissocPath.js +47 -0
- package/src/equals.js +40 -52
- package/src/omit.js +4 -6
- package/src/partial.js +9 -3
- package/src/pipe.js +1 -67
- package/src/removeIndex.js +7 -0
package/dist/rambda.js
CHANGED
|
@@ -33,26 +33,7 @@ function _concat(set1, set2) {
|
|
|
33
33
|
return result;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function
|
|
37
|
-
return function () {
|
|
38
|
-
let ci = 0;
|
|
39
|
-
let ai = 0;
|
|
40
|
-
const cl = cache.length;
|
|
41
|
-
const al = arguments.length;
|
|
42
|
-
const args = new Array(cl + al);
|
|
43
|
-
while (ci < cl) {
|
|
44
|
-
args[ci] = cache[ci];
|
|
45
|
-
ci++;
|
|
46
|
-
}
|
|
47
|
-
while (ai < al) {
|
|
48
|
-
args[cl + ai] = arguments[ai];
|
|
49
|
-
ai++;
|
|
50
|
-
}
|
|
51
|
-
const remaining = n - args.length;
|
|
52
|
-
return args.length >= n ? fn.apply(this, args) : _arity$1(remaining, _curryN(n, args, fn));
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function _arity$1(n, fn) {
|
|
36
|
+
function _arity(n, fn) {
|
|
56
37
|
switch (n) {
|
|
57
38
|
case 0:
|
|
58
39
|
return function () {
|
|
@@ -100,12 +81,32 @@ function _arity$1(n, fn) {
|
|
|
100
81
|
};
|
|
101
82
|
}
|
|
102
83
|
}
|
|
84
|
+
|
|
85
|
+
function _curryN(n, cache, fn) {
|
|
86
|
+
return function () {
|
|
87
|
+
let ci = 0;
|
|
88
|
+
let ai = 0;
|
|
89
|
+
const cl = cache.length;
|
|
90
|
+
const al = arguments.length;
|
|
91
|
+
const args = new Array(cl + al);
|
|
92
|
+
while (ci < cl) {
|
|
93
|
+
args[ci] = cache[ci];
|
|
94
|
+
ci++;
|
|
95
|
+
}
|
|
96
|
+
while (ai < al) {
|
|
97
|
+
args[cl + ai] = arguments[ai];
|
|
98
|
+
ai++;
|
|
99
|
+
}
|
|
100
|
+
const remaining = n - args.length;
|
|
101
|
+
return args.length >= n ? fn.apply(this, args) : _arity(remaining, _curryN(n, args, fn));
|
|
102
|
+
};
|
|
103
|
+
}
|
|
103
104
|
function curryN(n, fn) {
|
|
104
105
|
if (arguments.length === 1) return _fn => curryN(n, _fn);
|
|
105
106
|
if (n > 10) {
|
|
106
107
|
throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
|
|
107
108
|
}
|
|
108
|
-
return _arity
|
|
109
|
+
return _arity(n, _curryN(n, [], fn));
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
function addIndex(originalFunction, initialIndexFn = () => 0, loopIndexChange = x => x + 1) {
|
|
@@ -335,27 +336,35 @@ function _isInteger(n) {
|
|
|
335
336
|
return n << 0 === n;
|
|
336
337
|
}
|
|
337
338
|
const isInteger = Number.isInteger || _isInteger;
|
|
339
|
+
const isIndexInteger = index => Number.isInteger(Number(index));
|
|
340
|
+
|
|
341
|
+
function createPath(path, delimiter = '.') {
|
|
342
|
+
return typeof path === 'string' ? path.split(delimiter).map(x => isInteger(x) ? Number(x) : x) : path;
|
|
343
|
+
}
|
|
338
344
|
|
|
339
345
|
function assocPathFn(path, newValue, input) {
|
|
340
|
-
const pathArrValue =
|
|
341
|
-
if (pathArrValue.length === 0)
|
|
342
|
-
return newValue;
|
|
343
|
-
}
|
|
346
|
+
const pathArrValue = createPath(path);
|
|
347
|
+
if (pathArrValue.length === 0) return newValue;
|
|
344
348
|
const index = pathArrValue[0];
|
|
345
349
|
if (pathArrValue.length > 1) {
|
|
346
350
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
347
|
-
const nextInput = condition ?
|
|
351
|
+
const nextInput = condition ? isIndexInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
348
352
|
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
|
|
349
353
|
}
|
|
350
|
-
if (
|
|
354
|
+
if (isIndexInteger(index) && isArray(input)) {
|
|
351
355
|
const arr = cloneList(input);
|
|
352
356
|
arr[index] = newValue;
|
|
353
357
|
return arr;
|
|
354
358
|
}
|
|
355
|
-
return
|
|
359
|
+
return assocFn(index, newValue, input);
|
|
356
360
|
}
|
|
357
361
|
const assocPath = curry(assocPathFn);
|
|
358
362
|
|
|
363
|
+
function binary(fn) {
|
|
364
|
+
if (fn.length <= 2) return fn;
|
|
365
|
+
return (a, b) => fn(a, b);
|
|
366
|
+
}
|
|
367
|
+
|
|
359
368
|
function bind(fn, thisObj) {
|
|
360
369
|
if (arguments.length === 1) {
|
|
361
370
|
return _thisObj => bind(fn, _thisObj);
|
|
@@ -368,6 +377,8 @@ function both(f, g) {
|
|
|
368
377
|
return (...input) => f(...input) && g(...input);
|
|
369
378
|
}
|
|
370
379
|
|
|
380
|
+
const call = (fn, ...inputs) => fn(...inputs);
|
|
381
|
+
|
|
371
382
|
function chain(fn, list) {
|
|
372
383
|
if (arguments.length === 1) {
|
|
373
384
|
return _list => chain(fn, _list);
|
|
@@ -395,10 +406,6 @@ function clone(input) {
|
|
|
395
406
|
return out;
|
|
396
407
|
}
|
|
397
408
|
|
|
398
|
-
function complement(fn) {
|
|
399
|
-
return (...input) => !fn(...input);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
409
|
class ReduceStopper {
|
|
403
410
|
constructor(value) {
|
|
404
411
|
this.value = value;
|
|
@@ -425,56 +432,35 @@ function reduceFn(reducer, acc, list) {
|
|
|
425
432
|
const reduce = curry(reduceFn);
|
|
426
433
|
const reduceStopper = value => new ReduceStopper(value);
|
|
427
434
|
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return function (a0, a1, a2) {
|
|
444
|
-
return fn.apply(this, arguments);
|
|
445
|
-
};
|
|
446
|
-
case 4:
|
|
447
|
-
return function (a0, a1, a2, a3) {
|
|
448
|
-
return fn.apply(this, arguments);
|
|
449
|
-
};
|
|
450
|
-
case 5:
|
|
451
|
-
return function (a0, a1, a2, a3, a4) {
|
|
452
|
-
return fn.apply(this, arguments);
|
|
453
|
-
};
|
|
454
|
-
case 6:
|
|
455
|
-
return function (a0, a1, a2, a3, a4, a5) {
|
|
456
|
-
return fn.apply(this, arguments);
|
|
457
|
-
};
|
|
458
|
-
case 7:
|
|
459
|
-
return function (a0, a1, a2, a3, a4, a5, a6) {
|
|
460
|
-
return fn.apply(this, arguments);
|
|
461
|
-
};
|
|
462
|
-
case 8:
|
|
463
|
-
return function (a0, a1, a2, a3, a4, a5, a6, a7) {
|
|
464
|
-
return fn.apply(this, arguments);
|
|
465
|
-
};
|
|
466
|
-
case 9:
|
|
467
|
-
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
468
|
-
return fn.apply(this, arguments);
|
|
469
|
-
};
|
|
470
|
-
case 10:
|
|
471
|
-
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
472
|
-
return fn.apply(this, arguments);
|
|
473
|
-
};
|
|
474
|
-
default:
|
|
475
|
-
throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
|
|
435
|
+
function collectBy(fn, list) {
|
|
436
|
+
if (arguments.length === 1) {
|
|
437
|
+
return _list => collectBy(fn, _list);
|
|
438
|
+
}
|
|
439
|
+
const group = reduce((o, x) => {
|
|
440
|
+
const tag = fn(x);
|
|
441
|
+
if (o[tag] === undefined) {
|
|
442
|
+
o[tag] = [];
|
|
443
|
+
}
|
|
444
|
+
o[tag].push(x);
|
|
445
|
+
return o;
|
|
446
|
+
}, {}, list);
|
|
447
|
+
const newList = [];
|
|
448
|
+
for (const tag in group) {
|
|
449
|
+
newList.push(group[tag]);
|
|
476
450
|
}
|
|
451
|
+
return newList;
|
|
477
452
|
}
|
|
453
|
+
|
|
454
|
+
function comparator(fn) {
|
|
455
|
+
return function (a, b) {
|
|
456
|
+
return fn(a, b) ? -1 : fn(b, a) ? 1 : 0;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function complement(fn) {
|
|
461
|
+
return (...input) => !fn(...input);
|
|
462
|
+
}
|
|
463
|
+
|
|
478
464
|
function _pipe(f, g) {
|
|
479
465
|
return function () {
|
|
480
466
|
return g.call(this, f.apply(this, arguments));
|
|
@@ -494,6 +480,49 @@ function compose() {
|
|
|
494
480
|
return pipe.apply(this, Array.prototype.slice.call(arguments, 0).reverse());
|
|
495
481
|
}
|
|
496
482
|
|
|
483
|
+
function head(listOrString) {
|
|
484
|
+
if (typeof listOrString === 'string') return listOrString[0] || '';
|
|
485
|
+
return listOrString[0];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function identity(x) {
|
|
489
|
+
return x;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function reverse(listOrString) {
|
|
493
|
+
if (typeof listOrString === 'string') {
|
|
494
|
+
return listOrString.split('').reverse().join('');
|
|
495
|
+
}
|
|
496
|
+
const clone = listOrString.slice();
|
|
497
|
+
return clone.reverse();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function drop(howManyToDrop, listOrString) {
|
|
501
|
+
if (arguments.length === 1) return _list => drop(howManyToDrop, _list);
|
|
502
|
+
return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function tail(listOrString) {
|
|
506
|
+
return drop(1, listOrString);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function pipeWith(xf, list) {
|
|
510
|
+
if (list.length <= 0) {
|
|
511
|
+
return identity;
|
|
512
|
+
}
|
|
513
|
+
const headList = head(list);
|
|
514
|
+
const tailList = tail(list);
|
|
515
|
+
return _arity(headList.length, function () {
|
|
516
|
+
return reduce(function (result, f) {
|
|
517
|
+
return xf.call(this, f, result);
|
|
518
|
+
}, headList.apply(this, arguments), tailList);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function composeWith(xf, list) {
|
|
522
|
+
if (arguments.length === 1) return _list => composeWith(xf, _list);
|
|
523
|
+
return pipeWith.apply(this, [xf, reverse(list)]);
|
|
524
|
+
}
|
|
525
|
+
|
|
497
526
|
function concat(x, y) {
|
|
498
527
|
if (arguments.length === 1) return _y => concat(x, _y);
|
|
499
528
|
return typeof x === 'string' ? `${x}${y}` : [...x, ...y];
|
|
@@ -624,62 +653,46 @@ function type(input) {
|
|
|
624
653
|
}
|
|
625
654
|
|
|
626
655
|
function _lastIndexOf(valueToFind, list) {
|
|
627
|
-
if (!isArray(list)) {
|
|
628
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
629
|
-
}
|
|
656
|
+
if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
630
657
|
const typeOfValue = type(valueToFind);
|
|
631
|
-
if (!['
|
|
658
|
+
if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
|
|
632
659
|
const {
|
|
633
660
|
length
|
|
634
661
|
} = list;
|
|
635
662
|
let index = length;
|
|
636
663
|
let foundIndex = -1;
|
|
637
|
-
while (--index > -1 && foundIndex === -1)
|
|
638
|
-
if (equals(list[index], valueToFind)) {
|
|
639
|
-
foundIndex = index;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
664
|
+
while (--index > -1 && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
|
|
642
665
|
return foundIndex;
|
|
643
666
|
}
|
|
644
667
|
function _indexOf(valueToFind, list) {
|
|
645
|
-
if (!isArray(list)) {
|
|
646
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
647
|
-
}
|
|
668
|
+
if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
648
669
|
const typeOfValue = type(valueToFind);
|
|
649
|
-
if (!['
|
|
670
|
+
if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
|
|
650
671
|
let index = -1;
|
|
651
672
|
let foundIndex = -1;
|
|
652
673
|
const {
|
|
653
674
|
length
|
|
654
675
|
} = list;
|
|
655
|
-
while (++index < length && foundIndex === -1)
|
|
656
|
-
if (equals(list[index], valueToFind)) {
|
|
657
|
-
foundIndex = index;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
676
|
+
while (++index < length && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
|
|
660
677
|
return foundIndex;
|
|
661
678
|
}
|
|
662
679
|
function _arrayFromIterator(iter) {
|
|
663
680
|
const list = [];
|
|
664
681
|
let next;
|
|
665
|
-
while (!(next = iter.next()).done)
|
|
666
|
-
list.push(next.value);
|
|
667
|
-
}
|
|
682
|
+
while (!(next = iter.next()).done) list.push(next.value);
|
|
668
683
|
return list;
|
|
669
684
|
}
|
|
670
|
-
function
|
|
671
|
-
if (a.size !== b.size)
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
685
|
+
function _compareSets(a, b) {
|
|
686
|
+
if (a.size !== b.size) return false;
|
|
674
687
|
const aList = _arrayFromIterator(a.values());
|
|
675
688
|
const bList = _arrayFromIterator(b.values());
|
|
676
689
|
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
|
|
677
690
|
return filtered.length === 0;
|
|
678
691
|
}
|
|
679
|
-
function
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
return
|
|
692
|
+
function compareErrors(a, b) {
|
|
693
|
+
if (a.message !== b.message) return false;
|
|
694
|
+
if (a.toString !== b.toString) return false;
|
|
695
|
+
return a.toString() === b.toString();
|
|
683
696
|
}
|
|
684
697
|
function parseDate(maybeDate) {
|
|
685
698
|
if (!maybeDate.toDateString) return [false];
|
|
@@ -693,64 +706,43 @@ function equals(a, b) {
|
|
|
693
706
|
if (arguments.length === 1) return _b => equals(a, _b);
|
|
694
707
|
const aType = type(a);
|
|
695
708
|
if (aType !== type(b)) return false;
|
|
696
|
-
if (aType === 'Function')
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
if (['NaN', 'Undefined', 'Null'].includes(aType)) return true;
|
|
700
|
-
if (aType === 'Number') {
|
|
709
|
+
if (aType === 'Function') return a.name === undefined ? false : a.name === b.name;
|
|
710
|
+
if (['NaN', 'Null', 'Undefined'].includes(aType)) return true;
|
|
711
|
+
if (['BigInt', 'Number'].includes(aType)) {
|
|
701
712
|
if (Object.is(-0, a) !== Object.is(-0, b)) return false;
|
|
702
713
|
return a.toString() === b.toString();
|
|
703
714
|
}
|
|
704
|
-
if (['
|
|
705
|
-
return a.toString() === b.toString();
|
|
706
|
-
}
|
|
715
|
+
if (['Boolean', 'String'].includes(aType)) return a.toString() === b.toString();
|
|
707
716
|
if (aType === 'Array') {
|
|
708
717
|
const aClone = Array.from(a);
|
|
709
718
|
const bClone = Array.from(b);
|
|
710
|
-
if (aClone.toString() !== bClone.toString())
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
719
|
+
if (aClone.toString() !== bClone.toString()) return false;
|
|
713
720
|
let loopArrayFlag = true;
|
|
714
721
|
aClone.forEach((aCloneInstance, aCloneIndex) => {
|
|
715
|
-
if (loopArrayFlag)
|
|
716
|
-
if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) {
|
|
717
|
-
loopArrayFlag = false;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
722
|
+
if (loopArrayFlag) if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) loopArrayFlag = false;
|
|
720
723
|
});
|
|
721
724
|
return loopArrayFlag;
|
|
722
725
|
}
|
|
723
726
|
const aRegex = parseRegex(a);
|
|
724
727
|
const bRegex = parseRegex(b);
|
|
725
|
-
if (aRegex[0])
|
|
726
|
-
return bRegex[0] ? aRegex[1] === bRegex[1] : false;
|
|
727
|
-
} else if (bRegex[0]) return false;
|
|
728
|
+
if (aRegex[0]) return bRegex[0] ? aRegex[1] === bRegex[1] : false;else if (bRegex[0]) return false;
|
|
728
729
|
const aDate = parseDate(a);
|
|
729
730
|
const bDate = parseDate(b);
|
|
730
|
-
if (aDate[0])
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
const bError = parseError(b);
|
|
735
|
-
if (aError[0]) {
|
|
736
|
-
return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
|
|
737
|
-
}
|
|
738
|
-
if (aType === 'Set') {
|
|
739
|
-
return _equalsSets(a, b);
|
|
731
|
+
if (aDate[0]) return bDate[0] ? aDate[1] === bDate[1] : false;else if (bDate[0]) return false;
|
|
732
|
+
if (a instanceof Error) {
|
|
733
|
+
if (!(b instanceof Error)) return false;
|
|
734
|
+
return compareErrors(a, b);
|
|
740
735
|
}
|
|
736
|
+
if (aType === 'Set') return _compareSets(a, b);
|
|
741
737
|
if (aType === 'Object') {
|
|
742
738
|
const aKeys = Object.keys(a);
|
|
743
|
-
if (aKeys.length !== Object.keys(b).length)
|
|
744
|
-
return false;
|
|
745
|
-
}
|
|
739
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
746
740
|
let loopObjectFlag = true;
|
|
747
741
|
aKeys.forEach(aKeyInstance => {
|
|
748
742
|
if (loopObjectFlag) {
|
|
749
743
|
const aValue = a[aKeyInstance];
|
|
750
744
|
const bValue = b[aKeyInstance];
|
|
751
|
-
if (aValue !== bValue && !equals(aValue, bValue))
|
|
752
|
-
loopObjectFlag = false;
|
|
753
|
-
}
|
|
745
|
+
if (aValue !== bValue && !equals(aValue, bValue)) loopObjectFlag = false;
|
|
754
746
|
}
|
|
755
747
|
});
|
|
756
748
|
return loopObjectFlag;
|
|
@@ -758,8 +750,8 @@ function equals(a, b) {
|
|
|
758
750
|
return false;
|
|
759
751
|
}
|
|
760
752
|
|
|
761
|
-
function includes(valueToFind, iterable) {
|
|
762
|
-
if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
|
|
753
|
+
function includes$1(valueToFind, iterable) {
|
|
754
|
+
if (arguments.length === 1) return _iterable => includes$1(valueToFind, _iterable);
|
|
763
755
|
if (typeof iterable === 'string') {
|
|
764
756
|
return iterable.includes(valueToFind);
|
|
765
757
|
}
|
|
@@ -814,7 +806,7 @@ function uniq(list) {
|
|
|
814
806
|
|
|
815
807
|
function difference(a, b) {
|
|
816
808
|
if (arguments.length === 1) return _b => difference(a, _b);
|
|
817
|
-
return uniq(a).filter(aInstance => !includes(aInstance, b));
|
|
809
|
+
return uniq(a).filter(aInstance => !includes$1(aInstance, b));
|
|
818
810
|
}
|
|
819
811
|
|
|
820
812
|
function differenceWithFn(fn, a, b) {
|
|
@@ -841,16 +833,140 @@ function dissoc(prop, obj) {
|
|
|
841
833
|
return willReturn;
|
|
842
834
|
}
|
|
843
835
|
|
|
836
|
+
function ownKeys(object, enumerableOnly) {
|
|
837
|
+
var keys = Object.keys(object);
|
|
838
|
+
if (Object.getOwnPropertySymbols) {
|
|
839
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
840
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
841
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
842
|
+
})), keys.push.apply(keys, symbols);
|
|
843
|
+
}
|
|
844
|
+
return keys;
|
|
845
|
+
}
|
|
846
|
+
function _objectSpread2(target) {
|
|
847
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
848
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
849
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
850
|
+
_defineProperty(target, key, source[key]);
|
|
851
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
852
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
return target;
|
|
856
|
+
}
|
|
857
|
+
function _defineProperty(obj, key, value) {
|
|
858
|
+
key = _toPropertyKey(key);
|
|
859
|
+
if (key in obj) {
|
|
860
|
+
Object.defineProperty(obj, key, {
|
|
861
|
+
value: value,
|
|
862
|
+
enumerable: true,
|
|
863
|
+
configurable: true,
|
|
864
|
+
writable: true
|
|
865
|
+
});
|
|
866
|
+
} else {
|
|
867
|
+
obj[key] = value;
|
|
868
|
+
}
|
|
869
|
+
return obj;
|
|
870
|
+
}
|
|
871
|
+
function _toPrimitive(input, hint) {
|
|
872
|
+
if (typeof input !== "object" || input === null) return input;
|
|
873
|
+
var prim = input[Symbol.toPrimitive];
|
|
874
|
+
if (prim !== undefined) {
|
|
875
|
+
var res = prim.call(input, hint || "default");
|
|
876
|
+
if (typeof res !== "object") return res;
|
|
877
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
878
|
+
}
|
|
879
|
+
return (hint === "string" ? String : Number)(input);
|
|
880
|
+
}
|
|
881
|
+
function _toPropertyKey(arg) {
|
|
882
|
+
var key = _toPrimitive(arg, "string");
|
|
883
|
+
return typeof key === "symbol" ? key : String(key);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function compare(a, b) {
|
|
887
|
+
return String(a) === String(b);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
function includes(a, list) {
|
|
891
|
+
let index = -1;
|
|
892
|
+
const {
|
|
893
|
+
length
|
|
894
|
+
} = list;
|
|
895
|
+
while (++index < length) if (compare(list[index], a)) return true;
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function omit(propsToOmit, obj) {
|
|
900
|
+
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj);
|
|
901
|
+
if (obj === null || obj === undefined) return undefined;
|
|
902
|
+
const propsToOmitValue = createPath(propsToOmit, ',');
|
|
903
|
+
const willReturn = {};
|
|
904
|
+
for (const key in obj) if (!includes(key, propsToOmitValue)) willReturn[key] = obj[key];
|
|
905
|
+
return willReturn;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function pathFn(pathInput, obj) {
|
|
909
|
+
let willReturn = obj;
|
|
910
|
+
let counter = 0;
|
|
911
|
+
const pathArrValue = createPath(pathInput);
|
|
912
|
+
while (counter < pathArrValue.length) {
|
|
913
|
+
if (willReturn === null || willReturn === undefined) {
|
|
914
|
+
return undefined;
|
|
915
|
+
}
|
|
916
|
+
if (willReturn[pathArrValue[counter]] === null) return undefined;
|
|
917
|
+
willReturn = willReturn[pathArrValue[counter]];
|
|
918
|
+
counter++;
|
|
919
|
+
}
|
|
920
|
+
return willReturn;
|
|
921
|
+
}
|
|
922
|
+
function path(pathInput, obj) {
|
|
923
|
+
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
924
|
+
if (obj === null || obj === undefined) {
|
|
925
|
+
return undefined;
|
|
926
|
+
}
|
|
927
|
+
return pathFn(pathInput, obj);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function removeIndex(index, list) {
|
|
931
|
+
if (arguments.length === 1) return _list => removeIndex(index, _list);
|
|
932
|
+
if (index <= 0) return list.slice(1);
|
|
933
|
+
if (index >= list.length - 1) return list.slice(0, list.length - 1);
|
|
934
|
+
return [...list.slice(0, index), ...list.slice(index + 1)];
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function updateFn(index, newValue, list) {
|
|
938
|
+
const clone = cloneList(list);
|
|
939
|
+
if (index === -1) return clone.fill(newValue, index);
|
|
940
|
+
return clone.fill(newValue, index, index + 1);
|
|
941
|
+
}
|
|
942
|
+
const update = curry(updateFn);
|
|
943
|
+
|
|
944
|
+
function dissocPath(pathInput, input) {
|
|
945
|
+
if (arguments.length === 1) return _obj => dissocPath(pathInput, _obj);
|
|
946
|
+
const pathArrValue = createPath(pathInput);
|
|
947
|
+
if (pathArrValue.length === 0) return input;
|
|
948
|
+
const pathResult = path(pathArrValue, input);
|
|
949
|
+
if (pathResult === undefined) return input;
|
|
950
|
+
const index = pathArrValue[0];
|
|
951
|
+
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
952
|
+
if (pathArrValue.length > 1) {
|
|
953
|
+
const nextInput = condition ? isIndexInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
954
|
+
const nextPathInput = Array.prototype.slice.call(pathArrValue, 1);
|
|
955
|
+
const intermediateResult = dissocPath(nextPathInput, nextInput, input);
|
|
956
|
+
if (isArray(input)) return update(index, intermediateResult, input);
|
|
957
|
+
return _objectSpread2(_objectSpread2({}, input), {}, {
|
|
958
|
+
[index]: intermediateResult
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
if (isArray(input)) return removeIndex(index, input);
|
|
962
|
+
return omit([index], input);
|
|
963
|
+
}
|
|
964
|
+
|
|
844
965
|
function divide(a, b) {
|
|
845
966
|
if (arguments.length === 1) return _b => divide(a, _b);
|
|
846
967
|
return a / b;
|
|
847
968
|
}
|
|
848
969
|
|
|
849
|
-
function drop(howManyToDrop, listOrString) {
|
|
850
|
-
if (arguments.length === 1) return _list => drop(howManyToDrop, _list);
|
|
851
|
-
return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
970
|
function dropLast(howManyToDrop, listOrString) {
|
|
855
971
|
if (arguments.length === 1) {
|
|
856
972
|
return _listOrString => dropLast(howManyToDrop, _listOrString);
|
|
@@ -1211,32 +1327,6 @@ function has(prop, obj) {
|
|
|
1211
1327
|
return obj.hasOwnProperty(prop);
|
|
1212
1328
|
}
|
|
1213
1329
|
|
|
1214
|
-
function createPath(path, delimiter = '.') {
|
|
1215
|
-
return typeof path === 'string' ? path.split(delimiter) : path;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
function pathFn(pathInput, obj) {
|
|
1219
|
-
let willReturn = obj;
|
|
1220
|
-
let counter = 0;
|
|
1221
|
-
const pathArrValue = createPath(pathInput);
|
|
1222
|
-
while (counter < pathArrValue.length) {
|
|
1223
|
-
if (willReturn === null || willReturn === undefined) {
|
|
1224
|
-
return undefined;
|
|
1225
|
-
}
|
|
1226
|
-
if (willReturn[pathArrValue[counter]] === null) return undefined;
|
|
1227
|
-
willReturn = willReturn[pathArrValue[counter]];
|
|
1228
|
-
counter++;
|
|
1229
|
-
}
|
|
1230
|
-
return willReturn;
|
|
1231
|
-
}
|
|
1232
|
-
function path(pathInput, obj) {
|
|
1233
|
-
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
1234
|
-
if (obj === null || obj === undefined) {
|
|
1235
|
-
return undefined;
|
|
1236
|
-
}
|
|
1237
|
-
return pathFn(pathInput, obj);
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
1330
|
function hasPath(pathInput, obj) {
|
|
1241
1331
|
if (arguments.length === 1) {
|
|
1242
1332
|
return objHolder => hasPath(pathInput, objHolder);
|
|
@@ -1244,11 +1334,6 @@ function hasPath(pathInput, obj) {
|
|
|
1244
1334
|
return path(pathInput, obj) !== undefined;
|
|
1245
1335
|
}
|
|
1246
1336
|
|
|
1247
|
-
function head(listOrString) {
|
|
1248
|
-
if (typeof listOrString === 'string') return listOrString[0] || '';
|
|
1249
|
-
return listOrString[0];
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
1337
|
function _objectIs(a, b) {
|
|
1253
1338
|
if (a === b) {
|
|
1254
1339
|
return a !== 0 || 1 / a === 1 / b;
|
|
@@ -1262,10 +1347,6 @@ function identical(a, b) {
|
|
|
1262
1347
|
return objectIs(a, b);
|
|
1263
1348
|
}
|
|
1264
1349
|
|
|
1265
|
-
function identity(x) {
|
|
1266
|
-
return x;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
1350
|
function ifElseFn(condition, onTrue, onFalse) {
|
|
1270
1351
|
return (...input) => {
|
|
1271
1352
|
const conditionResult = typeof condition === 'boolean' ? condition : condition(...input);
|
|
@@ -1334,7 +1415,7 @@ function init(listOrString) {
|
|
|
1334
1415
|
|
|
1335
1416
|
function intersection(listA, listB) {
|
|
1336
1417
|
if (arguments.length === 1) return _list => intersection(listA, _list);
|
|
1337
|
-
return filter(x => includes(x, listA), listB);
|
|
1418
|
+
return filter(x => includes$1(x, listA), listB);
|
|
1338
1419
|
}
|
|
1339
1420
|
|
|
1340
1421
|
function intersperse(separator, list) {
|
|
@@ -1421,13 +1502,6 @@ function nth(index, input) {
|
|
|
1421
1502
|
return Object.prototype.toString.call(input) === '[object String]' ? input.charAt(idx) : input[idx];
|
|
1422
1503
|
}
|
|
1423
1504
|
|
|
1424
|
-
function updateFn(index, newValue, list) {
|
|
1425
|
-
const clone = cloneList(list);
|
|
1426
|
-
if (index === -1) return clone.fill(newValue, index);
|
|
1427
|
-
return clone.fill(newValue, index, index + 1);
|
|
1428
|
-
}
|
|
1429
|
-
const update = curry(updateFn);
|
|
1430
|
-
|
|
1431
1505
|
function lensIndex(index) {
|
|
1432
1506
|
return lens(nth(index), update(index));
|
|
1433
1507
|
}
|
|
@@ -1546,56 +1620,6 @@ function minByFn(compareFn, x, y) {
|
|
|
1546
1620
|
}
|
|
1547
1621
|
const minBy = curry(minByFn);
|
|
1548
1622
|
|
|
1549
|
-
function ownKeys(object, enumerableOnly) {
|
|
1550
|
-
var keys = Object.keys(object);
|
|
1551
|
-
if (Object.getOwnPropertySymbols) {
|
|
1552
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
1553
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1554
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1555
|
-
})), keys.push.apply(keys, symbols);
|
|
1556
|
-
}
|
|
1557
|
-
return keys;
|
|
1558
|
-
}
|
|
1559
|
-
function _objectSpread2(target) {
|
|
1560
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
1561
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
1562
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
1563
|
-
_defineProperty(target, key, source[key]);
|
|
1564
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
1565
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
return target;
|
|
1569
|
-
}
|
|
1570
|
-
function _defineProperty(obj, key, value) {
|
|
1571
|
-
key = _toPropertyKey(key);
|
|
1572
|
-
if (key in obj) {
|
|
1573
|
-
Object.defineProperty(obj, key, {
|
|
1574
|
-
value: value,
|
|
1575
|
-
enumerable: true,
|
|
1576
|
-
configurable: true,
|
|
1577
|
-
writable: true
|
|
1578
|
-
});
|
|
1579
|
-
} else {
|
|
1580
|
-
obj[key] = value;
|
|
1581
|
-
}
|
|
1582
|
-
return obj;
|
|
1583
|
-
}
|
|
1584
|
-
function _toPrimitive(input, hint) {
|
|
1585
|
-
if (typeof input !== "object" || input === null) return input;
|
|
1586
|
-
var prim = input[Symbol.toPrimitive];
|
|
1587
|
-
if (prim !== undefined) {
|
|
1588
|
-
var res = prim.call(input, hint || "default");
|
|
1589
|
-
if (typeof res !== "object") return res;
|
|
1590
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1591
|
-
}
|
|
1592
|
-
return (hint === "string" ? String : Number)(input);
|
|
1593
|
-
}
|
|
1594
|
-
function _toPropertyKey(arg) {
|
|
1595
|
-
var key = _toPrimitive(arg, "string");
|
|
1596
|
-
return typeof key === "symbol" ? key : String(key);
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
1623
|
function isIterable(input) {
|
|
1600
1624
|
return Array.isArray(input) || type(input) === 'Object';
|
|
1601
1625
|
}
|
|
@@ -1679,21 +1703,6 @@ function of(value) {
|
|
|
1679
1703
|
return [value];
|
|
1680
1704
|
}
|
|
1681
1705
|
|
|
1682
|
-
function omit(propsToOmit, obj) {
|
|
1683
|
-
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj);
|
|
1684
|
-
if (obj === null || obj === undefined) {
|
|
1685
|
-
return undefined;
|
|
1686
|
-
}
|
|
1687
|
-
const propsToOmitValue = createPath(propsToOmit, ',');
|
|
1688
|
-
const willReturn = {};
|
|
1689
|
-
for (const key in obj) {
|
|
1690
|
-
if (!propsToOmitValue.includes(key)) {
|
|
1691
|
-
willReturn[key] = obj[key];
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
return willReturn;
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
1706
|
function on(binaryFn, unaryFn, a, b) {
|
|
1698
1707
|
if (arguments.length === 3) {
|
|
1699
1708
|
return _b => on(binaryFn, unaryFn, a, _b);
|
|
@@ -1738,11 +1747,12 @@ const over = curry(overFn);
|
|
|
1738
1747
|
|
|
1739
1748
|
function partial(fn, ...args) {
|
|
1740
1749
|
const len = fn.length;
|
|
1750
|
+
const argList = args.length === 1 && isArray(args[0]) ? args[0] : args;
|
|
1741
1751
|
return (...rest) => {
|
|
1742
|
-
if (
|
|
1743
|
-
return fn(...
|
|
1752
|
+
if (argList.length + rest.length >= len) {
|
|
1753
|
+
return fn(...argList, ...rest);
|
|
1744
1754
|
}
|
|
1745
|
-
return partial(fn, ...[...
|
|
1755
|
+
return partial(fn, ...[...argList, ...rest]);
|
|
1746
1756
|
};
|
|
1747
1757
|
}
|
|
1748
1758
|
|
|
@@ -1918,14 +1928,6 @@ function replaceFn(pattern, replacer, str) {
|
|
|
1918
1928
|
}
|
|
1919
1929
|
const replace = curry(replaceFn);
|
|
1920
1930
|
|
|
1921
|
-
function reverse(listOrString) {
|
|
1922
|
-
if (typeof listOrString === 'string') {
|
|
1923
|
-
return listOrString.split('').reverse().join('');
|
|
1924
|
-
}
|
|
1925
|
-
const clone = listOrString.slice();
|
|
1926
|
-
return clone.reverse();
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
1931
|
function setFn(lens, replacer, x) {
|
|
1930
1932
|
return over(lens, always(replacer), x);
|
|
1931
1933
|
}
|
|
@@ -2042,11 +2044,7 @@ function symmetricDifference(x, y) {
|
|
|
2042
2044
|
if (arguments.length === 1) {
|
|
2043
2045
|
return _y => symmetricDifference(x, _y);
|
|
2044
2046
|
}
|
|
2045
|
-
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));
|
|
2046
|
-
}
|
|
2047
|
-
|
|
2048
|
-
function tail(listOrString) {
|
|
2049
|
-
return drop(1, listOrString);
|
|
2047
|
+
return concat(filter(value => !includes$1(value, y), x), filter(value => !includes$1(value, x), y));
|
|
2050
2048
|
}
|
|
2051
2049
|
|
|
2052
2050
|
function takeLast(howMany, listOrString) {
|
|
@@ -2170,7 +2168,7 @@ function union(x, y) {
|
|
|
2170
2168
|
if (arguments.length === 1) return _y => union(x, _y);
|
|
2171
2169
|
const toReturn = cloneList(x);
|
|
2172
2170
|
y.forEach(yInstance => {
|
|
2173
|
-
if (!includes(yInstance, x)) toReturn.push(yInstance);
|
|
2171
|
+
if (!includes$1(yInstance, x)) toReturn.push(yInstance);
|
|
2174
2172
|
});
|
|
2175
2173
|
return toReturn;
|
|
2176
2174
|
}
|
|
@@ -2326,7 +2324,6 @@ const zipWith = curry(zipWithFn);
|
|
|
2326
2324
|
exports.F = F;
|
|
2327
2325
|
exports.T = T;
|
|
2328
2326
|
exports.__findHighestArity = __findHighestArity;
|
|
2329
|
-
exports._arity = _arity;
|
|
2330
2327
|
exports._indexOf = _indexOf;
|
|
2331
2328
|
exports._lastIndexOf = _lastIndexOf;
|
|
2332
2329
|
exports._pipe = _pipe;
|
|
@@ -2348,14 +2345,21 @@ exports.applySpec = applySpec;
|
|
|
2348
2345
|
exports.applyTo = applyTo;
|
|
2349
2346
|
exports.ascend = ascend;
|
|
2350
2347
|
exports.assoc = assoc;
|
|
2348
|
+
exports.assocFn = assocFn;
|
|
2351
2349
|
exports.assocPath = assocPath;
|
|
2350
|
+
exports.assocPathFn = assocPathFn;
|
|
2351
|
+
exports.binary = binary;
|
|
2352
2352
|
exports.bind = bind;
|
|
2353
2353
|
exports.both = both;
|
|
2354
|
+
exports.call = call;
|
|
2354
2355
|
exports.chain = chain;
|
|
2355
2356
|
exports.clamp = clamp;
|
|
2356
2357
|
exports.clone = clone;
|
|
2358
|
+
exports.collectBy = collectBy;
|
|
2359
|
+
exports.comparator = comparator;
|
|
2357
2360
|
exports.complement = complement;
|
|
2358
2361
|
exports.compose = compose;
|
|
2362
|
+
exports.composeWith = composeWith;
|
|
2359
2363
|
exports.concat = concat;
|
|
2360
2364
|
exports.cond = cond;
|
|
2361
2365
|
exports.converge = converge;
|
|
@@ -2371,6 +2375,7 @@ exports.difference = difference;
|
|
|
2371
2375
|
exports.differenceWith = differenceWith;
|
|
2372
2376
|
exports.differenceWithFn = differenceWithFn;
|
|
2373
2377
|
exports.dissoc = dissoc;
|
|
2378
|
+
exports.dissocPath = dissocPath;
|
|
2374
2379
|
exports.divide = divide;
|
|
2375
2380
|
exports.drop = drop;
|
|
2376
2381
|
exports.dropLast = dropLast;
|
|
@@ -2405,7 +2410,7 @@ exports.identical = identical;
|
|
|
2405
2410
|
exports.identity = identity;
|
|
2406
2411
|
exports.ifElse = ifElse;
|
|
2407
2412
|
exports.inc = inc;
|
|
2408
|
-
exports.includes = includes;
|
|
2413
|
+
exports.includes = includes$1;
|
|
2409
2414
|
exports.indexBy = indexBy;
|
|
2410
2415
|
exports.indexOf = indexOf;
|
|
2411
2416
|
exports.init = init;
|
|
@@ -2474,6 +2479,7 @@ exports.paths = paths;
|
|
|
2474
2479
|
exports.pick = pick;
|
|
2475
2480
|
exports.pickAll = pickAll;
|
|
2476
2481
|
exports.pipe = pipe;
|
|
2482
|
+
exports.pipeWith = pipeWith;
|
|
2477
2483
|
exports.pluck = pluck;
|
|
2478
2484
|
exports.prepend = prepend;
|
|
2479
2485
|
exports.product = product;
|
|
@@ -2488,6 +2494,7 @@ exports.reduce = reduce;
|
|
|
2488
2494
|
exports.reduceFn = reduceFn;
|
|
2489
2495
|
exports.reduceStopper = reduceStopper;
|
|
2490
2496
|
exports.reject = reject;
|
|
2497
|
+
exports.removeIndex = removeIndex;
|
|
2491
2498
|
exports.repeat = repeat;
|
|
2492
2499
|
exports.replace = replace;
|
|
2493
2500
|
exports.reverse = reverse;
|