rambda 8.3.0 → 8.5.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 +38 -0
- package/README.md +510 -350
- package/dist/rambda.js +246 -207
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +62 -17
- package/index.d.ts +62 -17
- package/package.json +107 -106
- package/rambda.js +5 -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/dissocPath.js +47 -0
- package/src/dropRepeatsBy.js +21 -0
- package/src/empty.js +15 -0
- package/src/eqBy.js +10 -0
- package/src/equals.js +40 -52
- package/src/forEach.js +30 -20
- package/src/mergeWith.js +5 -11
- package/src/omit.js +4 -6
- package/src/partial.js +9 -3
- package/src/removeIndex.js +7 -0
package/dist/rambda.js
CHANGED
|
@@ -336,24 +336,27 @@ function _isInteger(n) {
|
|
|
336
336
|
return n << 0 === n;
|
|
337
337
|
}
|
|
338
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
|
+
}
|
|
339
344
|
|
|
340
345
|
function assocPathFn(path, newValue, input) {
|
|
341
|
-
const pathArrValue =
|
|
342
|
-
if (pathArrValue.length === 0)
|
|
343
|
-
return newValue;
|
|
344
|
-
}
|
|
346
|
+
const pathArrValue = createPath(path);
|
|
347
|
+
if (pathArrValue.length === 0) return newValue;
|
|
345
348
|
const index = pathArrValue[0];
|
|
346
349
|
if (pathArrValue.length > 1) {
|
|
347
350
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
348
|
-
const nextInput = condition ?
|
|
351
|
+
const nextInput = condition ? isIndexInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
349
352
|
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
|
|
350
353
|
}
|
|
351
|
-
if (
|
|
354
|
+
if (isIndexInteger(index) && isArray(input)) {
|
|
352
355
|
const arr = cloneList(input);
|
|
353
356
|
arr[index] = newValue;
|
|
354
357
|
return arr;
|
|
355
358
|
}
|
|
356
|
-
return
|
|
359
|
+
return assocFn(index, newValue, input);
|
|
357
360
|
}
|
|
358
361
|
const assocPath = curry(assocPathFn);
|
|
359
362
|
|
|
@@ -650,62 +653,46 @@ function type(input) {
|
|
|
650
653
|
}
|
|
651
654
|
|
|
652
655
|
function _lastIndexOf(valueToFind, list) {
|
|
653
|
-
if (!isArray(list)) {
|
|
654
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
655
|
-
}
|
|
656
|
+
if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
656
657
|
const typeOfValue = type(valueToFind);
|
|
657
|
-
if (!['
|
|
658
|
+
if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
|
|
658
659
|
const {
|
|
659
660
|
length
|
|
660
661
|
} = list;
|
|
661
662
|
let index = length;
|
|
662
663
|
let foundIndex = -1;
|
|
663
|
-
while (--index > -1 && foundIndex === -1)
|
|
664
|
-
if (equals(list[index], valueToFind)) {
|
|
665
|
-
foundIndex = index;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
664
|
+
while (--index > -1 && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
|
|
668
665
|
return foundIndex;
|
|
669
666
|
}
|
|
670
667
|
function _indexOf(valueToFind, list) {
|
|
671
|
-
if (!isArray(list)) {
|
|
672
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
673
|
-
}
|
|
668
|
+
if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
674
669
|
const typeOfValue = type(valueToFind);
|
|
675
|
-
if (!['
|
|
670
|
+
if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
|
|
676
671
|
let index = -1;
|
|
677
672
|
let foundIndex = -1;
|
|
678
673
|
const {
|
|
679
674
|
length
|
|
680
675
|
} = list;
|
|
681
|
-
while (++index < length && foundIndex === -1)
|
|
682
|
-
if (equals(list[index], valueToFind)) {
|
|
683
|
-
foundIndex = index;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
676
|
+
while (++index < length && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
|
|
686
677
|
return foundIndex;
|
|
687
678
|
}
|
|
688
679
|
function _arrayFromIterator(iter) {
|
|
689
680
|
const list = [];
|
|
690
681
|
let next;
|
|
691
|
-
while (!(next = iter.next()).done)
|
|
692
|
-
list.push(next.value);
|
|
693
|
-
}
|
|
682
|
+
while (!(next = iter.next()).done) list.push(next.value);
|
|
694
683
|
return list;
|
|
695
684
|
}
|
|
696
|
-
function
|
|
697
|
-
if (a.size !== b.size)
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
685
|
+
function _compareSets(a, b) {
|
|
686
|
+
if (a.size !== b.size) return false;
|
|
700
687
|
const aList = _arrayFromIterator(a.values());
|
|
701
688
|
const bList = _arrayFromIterator(b.values());
|
|
702
689
|
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
|
|
703
690
|
return filtered.length === 0;
|
|
704
691
|
}
|
|
705
|
-
function
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
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();
|
|
709
696
|
}
|
|
710
697
|
function parseDate(maybeDate) {
|
|
711
698
|
if (!maybeDate.toDateString) return [false];
|
|
@@ -719,64 +706,43 @@ function equals(a, b) {
|
|
|
719
706
|
if (arguments.length === 1) return _b => equals(a, _b);
|
|
720
707
|
const aType = type(a);
|
|
721
708
|
if (aType !== type(b)) return false;
|
|
722
|
-
if (aType === 'Function')
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (['NaN', 'Undefined', 'Null'].includes(aType)) return true;
|
|
726
|
-
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)) {
|
|
727
712
|
if (Object.is(-0, a) !== Object.is(-0, b)) return false;
|
|
728
713
|
return a.toString() === b.toString();
|
|
729
714
|
}
|
|
730
|
-
if (['
|
|
731
|
-
return a.toString() === b.toString();
|
|
732
|
-
}
|
|
715
|
+
if (['Boolean', 'String'].includes(aType)) return a.toString() === b.toString();
|
|
733
716
|
if (aType === 'Array') {
|
|
734
717
|
const aClone = Array.from(a);
|
|
735
718
|
const bClone = Array.from(b);
|
|
736
|
-
if (aClone.toString() !== bClone.toString())
|
|
737
|
-
return false;
|
|
738
|
-
}
|
|
719
|
+
if (aClone.toString() !== bClone.toString()) return false;
|
|
739
720
|
let loopArrayFlag = true;
|
|
740
721
|
aClone.forEach((aCloneInstance, aCloneIndex) => {
|
|
741
|
-
if (loopArrayFlag)
|
|
742
|
-
if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) {
|
|
743
|
-
loopArrayFlag = false;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
722
|
+
if (loopArrayFlag) if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) loopArrayFlag = false;
|
|
746
723
|
});
|
|
747
724
|
return loopArrayFlag;
|
|
748
725
|
}
|
|
749
726
|
const aRegex = parseRegex(a);
|
|
750
727
|
const bRegex = parseRegex(b);
|
|
751
|
-
if (aRegex[0])
|
|
752
|
-
return bRegex[0] ? aRegex[1] === bRegex[1] : false;
|
|
753
|
-
} else if (bRegex[0]) return false;
|
|
728
|
+
if (aRegex[0]) return bRegex[0] ? aRegex[1] === bRegex[1] : false;else if (bRegex[0]) return false;
|
|
754
729
|
const aDate = parseDate(a);
|
|
755
730
|
const bDate = parseDate(b);
|
|
756
|
-
if (aDate[0])
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const bError = parseError(b);
|
|
761
|
-
if (aError[0]) {
|
|
762
|
-
return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
|
|
763
|
-
}
|
|
764
|
-
if (aType === 'Set') {
|
|
765
|
-
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);
|
|
766
735
|
}
|
|
736
|
+
if (aType === 'Set') return _compareSets(a, b);
|
|
767
737
|
if (aType === 'Object') {
|
|
768
738
|
const aKeys = Object.keys(a);
|
|
769
|
-
if (aKeys.length !== Object.keys(b).length)
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
739
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
772
740
|
let loopObjectFlag = true;
|
|
773
741
|
aKeys.forEach(aKeyInstance => {
|
|
774
742
|
if (loopObjectFlag) {
|
|
775
743
|
const aValue = a[aKeyInstance];
|
|
776
744
|
const bValue = b[aKeyInstance];
|
|
777
|
-
if (aValue !== bValue && !equals(aValue, bValue))
|
|
778
|
-
loopObjectFlag = false;
|
|
779
|
-
}
|
|
745
|
+
if (aValue !== bValue && !equals(aValue, bValue)) loopObjectFlag = false;
|
|
780
746
|
}
|
|
781
747
|
});
|
|
782
748
|
return loopObjectFlag;
|
|
@@ -784,8 +750,8 @@ function equals(a, b) {
|
|
|
784
750
|
return false;
|
|
785
751
|
}
|
|
786
752
|
|
|
787
|
-
function includes(valueToFind, iterable) {
|
|
788
|
-
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);
|
|
789
755
|
if (typeof iterable === 'string') {
|
|
790
756
|
return iterable.includes(valueToFind);
|
|
791
757
|
}
|
|
@@ -840,7 +806,7 @@ function uniq(list) {
|
|
|
840
806
|
|
|
841
807
|
function difference(a, b) {
|
|
842
808
|
if (arguments.length === 1) return _b => difference(a, _b);
|
|
843
|
-
return uniq(a).filter(aInstance => !includes(aInstance, b));
|
|
809
|
+
return uniq(a).filter(aInstance => !includes$1(aInstance, b));
|
|
844
810
|
}
|
|
845
811
|
|
|
846
812
|
function differenceWithFn(fn, a, b) {
|
|
@@ -867,6 +833,135 @@ function dissoc(prop, obj) {
|
|
|
867
833
|
return willReturn;
|
|
868
834
|
}
|
|
869
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
|
+
|
|
870
965
|
function divide(a, b) {
|
|
871
966
|
if (arguments.length === 1) return _b => divide(a, _b);
|
|
872
967
|
return a / b;
|
|
@@ -920,6 +1015,21 @@ function dropRepeats(list) {
|
|
|
920
1015
|
return toReturn;
|
|
921
1016
|
}
|
|
922
1017
|
|
|
1018
|
+
function dropRepeatsBy(fn, list) {
|
|
1019
|
+
if (arguments.length === 1) return _list => dropRepeatsBy(fn, _list);
|
|
1020
|
+
let lastEvaluated = null;
|
|
1021
|
+
return list.slice().filter(item => {
|
|
1022
|
+
if (lastEvaluated === null) {
|
|
1023
|
+
lastEvaluated = fn(item);
|
|
1024
|
+
return true;
|
|
1025
|
+
}
|
|
1026
|
+
const evaluatedResult = fn(item);
|
|
1027
|
+
if (equals(lastEvaluated, evaluatedResult)) return false;
|
|
1028
|
+
lastEvaluated = evaluatedResult;
|
|
1029
|
+
return true;
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
|
|
923
1033
|
function dropRepeatsWith(predicate, list) {
|
|
924
1034
|
if (arguments.length === 1) {
|
|
925
1035
|
return _iterable => dropRepeatsWith(predicate, _iterable);
|
|
@@ -971,6 +1081,19 @@ function either(firstPredicate, secondPredicate) {
|
|
|
971
1081
|
return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
|
|
972
1082
|
}
|
|
973
1083
|
|
|
1084
|
+
function empty(list) {
|
|
1085
|
+
if (typeof list === 'string') return '';
|
|
1086
|
+
if (Array.isArray(list)) {
|
|
1087
|
+
const {
|
|
1088
|
+
name
|
|
1089
|
+
} = list.constructor;
|
|
1090
|
+
if (name === 'Uint8Array') return Uint8Array.from('');
|
|
1091
|
+
if (name === 'Float32Array') return new Float32Array([]);
|
|
1092
|
+
return [];
|
|
1093
|
+
}
|
|
1094
|
+
if (type(list) === 'Object') return {};
|
|
1095
|
+
}
|
|
1096
|
+
|
|
974
1097
|
function endsWith(target, iterable) {
|
|
975
1098
|
if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
|
|
976
1099
|
if (typeof iterable === 'string') {
|
|
@@ -988,6 +1111,11 @@ function endsWith(target, iterable) {
|
|
|
988
1111
|
return filtered.length === target.length;
|
|
989
1112
|
}
|
|
990
1113
|
|
|
1114
|
+
function eqByFn(fn, a, b) {
|
|
1115
|
+
return equals(fn(a), fn(b));
|
|
1116
|
+
}
|
|
1117
|
+
const eqBy = curry(eqByFn);
|
|
1118
|
+
|
|
991
1119
|
function prop(propToFind, obj) {
|
|
992
1120
|
if (arguments.length === 1) return _obj => prop(propToFind, _obj);
|
|
993
1121
|
if (!obj) return undefined;
|
|
@@ -1151,29 +1279,34 @@ function flip(fn) {
|
|
|
1151
1279
|
return flipFn(fn);
|
|
1152
1280
|
}
|
|
1153
1281
|
|
|
1154
|
-
function
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1282
|
+
function forEachObjIndexedFn(fn, obj) {
|
|
1283
|
+
let index = 0;
|
|
1284
|
+
const listKeys = keys$1(obj);
|
|
1285
|
+
const len = listKeys.length;
|
|
1286
|
+
while (index < len) {
|
|
1287
|
+
const key = listKeys[index];
|
|
1288
|
+
fn(obj[key], key, obj);
|
|
1289
|
+
index++;
|
|
1158
1290
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1291
|
+
return obj;
|
|
1292
|
+
}
|
|
1293
|
+
function forEachObjIndexed(fn, list) {
|
|
1294
|
+
if (arguments.length === 1) return _list => forEachObjIndexed(fn, _list);
|
|
1295
|
+
if (list === undefined) return;
|
|
1296
|
+
return forEachObjIndexedFn(fn, list);
|
|
1297
|
+
}
|
|
1298
|
+
function forEach(fn, iterable) {
|
|
1299
|
+
if (arguments.length === 1) return _list => forEach(fn, _list);
|
|
1300
|
+
if (iterable === undefined) return;
|
|
1301
|
+
if (isArray(iterable)) {
|
|
1167
1302
|
let index = 0;
|
|
1168
|
-
const
|
|
1169
|
-
const len = listKeys.length;
|
|
1303
|
+
const len = iterable.length;
|
|
1170
1304
|
while (index < len) {
|
|
1171
|
-
|
|
1172
|
-
fn(list[key], key, list);
|
|
1305
|
+
fn(iterable[index]);
|
|
1173
1306
|
index++;
|
|
1174
1307
|
}
|
|
1175
|
-
}
|
|
1176
|
-
return
|
|
1308
|
+
} else return forEachObjIndexedFn(fn, iterable);
|
|
1309
|
+
return iterable;
|
|
1177
1310
|
}
|
|
1178
1311
|
|
|
1179
1312
|
function fromPairs(listOfPairs) {
|
|
@@ -1232,32 +1365,6 @@ function has(prop, obj) {
|
|
|
1232
1365
|
return obj.hasOwnProperty(prop);
|
|
1233
1366
|
}
|
|
1234
1367
|
|
|
1235
|
-
function createPath(path, delimiter = '.') {
|
|
1236
|
-
return typeof path === 'string' ? path.split(delimiter) : path;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
function pathFn(pathInput, obj) {
|
|
1240
|
-
let willReturn = obj;
|
|
1241
|
-
let counter = 0;
|
|
1242
|
-
const pathArrValue = createPath(pathInput);
|
|
1243
|
-
while (counter < pathArrValue.length) {
|
|
1244
|
-
if (willReturn === null || willReturn === undefined) {
|
|
1245
|
-
return undefined;
|
|
1246
|
-
}
|
|
1247
|
-
if (willReturn[pathArrValue[counter]] === null) return undefined;
|
|
1248
|
-
willReturn = willReturn[pathArrValue[counter]];
|
|
1249
|
-
counter++;
|
|
1250
|
-
}
|
|
1251
|
-
return willReturn;
|
|
1252
|
-
}
|
|
1253
|
-
function path(pathInput, obj) {
|
|
1254
|
-
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
1255
|
-
if (obj === null || obj === undefined) {
|
|
1256
|
-
return undefined;
|
|
1257
|
-
}
|
|
1258
|
-
return pathFn(pathInput, obj);
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
1368
|
function hasPath(pathInput, obj) {
|
|
1262
1369
|
if (arguments.length === 1) {
|
|
1263
1370
|
return objHolder => hasPath(pathInput, objHolder);
|
|
@@ -1346,7 +1453,7 @@ function init(listOrString) {
|
|
|
1346
1453
|
|
|
1347
1454
|
function intersection(listA, listB) {
|
|
1348
1455
|
if (arguments.length === 1) return _list => intersection(listA, _list);
|
|
1349
|
-
return filter(x => includes(x, listA), listB);
|
|
1456
|
+
return filter(x => includes$1(x, listA), listB);
|
|
1350
1457
|
}
|
|
1351
1458
|
|
|
1352
1459
|
function intersperse(separator, list) {
|
|
@@ -1433,13 +1540,6 @@ function nth(index, input) {
|
|
|
1433
1540
|
return Object.prototype.toString.call(input) === '[object String]' ? input.charAt(idx) : input[idx];
|
|
1434
1541
|
}
|
|
1435
1542
|
|
|
1436
|
-
function updateFn(index, newValue, list) {
|
|
1437
|
-
const clone = cloneList(list);
|
|
1438
|
-
if (index === -1) return clone.fill(newValue, index);
|
|
1439
|
-
return clone.fill(newValue, index, index + 1);
|
|
1440
|
-
}
|
|
1441
|
-
const update = curry(updateFn);
|
|
1442
|
-
|
|
1443
1543
|
function lensIndex(index) {
|
|
1444
1544
|
return lens(nth(index), update(index));
|
|
1445
1545
|
}
|
|
@@ -1530,19 +1630,11 @@ function mergeWithFn(mergeFn, aInput, bInput) {
|
|
|
1530
1630
|
const b = bInput !== null && bInput !== void 0 ? bInput : {};
|
|
1531
1631
|
const willReturn = {};
|
|
1532
1632
|
Object.keys(a).forEach(key => {
|
|
1533
|
-
if (b[key] === undefined)
|
|
1534
|
-
willReturn[key] = a[key];
|
|
1535
|
-
} else {
|
|
1536
|
-
willReturn[key] = mergeFn(a[key], b[key]);
|
|
1537
|
-
}
|
|
1633
|
+
if (b[key] === undefined) willReturn[key] = a[key];else willReturn[key] = mergeFn(a[key], b[key]);
|
|
1538
1634
|
});
|
|
1539
1635
|
Object.keys(b).forEach(key => {
|
|
1540
1636
|
if (willReturn[key] !== undefined) return;
|
|
1541
|
-
if (a[key] === undefined)
|
|
1542
|
-
willReturn[key] = b[key];
|
|
1543
|
-
} else {
|
|
1544
|
-
willReturn[key] = mergeFn(a[key], b[key]);
|
|
1545
|
-
}
|
|
1637
|
+
if (a[key] === undefined) willReturn[key] = b[key];else willReturn[key] = mergeFn(a[key], b[key]);
|
|
1546
1638
|
});
|
|
1547
1639
|
return willReturn;
|
|
1548
1640
|
}
|
|
@@ -1558,56 +1650,6 @@ function minByFn(compareFn, x, y) {
|
|
|
1558
1650
|
}
|
|
1559
1651
|
const minBy = curry(minByFn);
|
|
1560
1652
|
|
|
1561
|
-
function ownKeys(object, enumerableOnly) {
|
|
1562
|
-
var keys = Object.keys(object);
|
|
1563
|
-
if (Object.getOwnPropertySymbols) {
|
|
1564
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
1565
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1566
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1567
|
-
})), keys.push.apply(keys, symbols);
|
|
1568
|
-
}
|
|
1569
|
-
return keys;
|
|
1570
|
-
}
|
|
1571
|
-
function _objectSpread2(target) {
|
|
1572
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
1573
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
1574
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
1575
|
-
_defineProperty(target, key, source[key]);
|
|
1576
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
1577
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
return target;
|
|
1581
|
-
}
|
|
1582
|
-
function _defineProperty(obj, key, value) {
|
|
1583
|
-
key = _toPropertyKey(key);
|
|
1584
|
-
if (key in obj) {
|
|
1585
|
-
Object.defineProperty(obj, key, {
|
|
1586
|
-
value: value,
|
|
1587
|
-
enumerable: true,
|
|
1588
|
-
configurable: true,
|
|
1589
|
-
writable: true
|
|
1590
|
-
});
|
|
1591
|
-
} else {
|
|
1592
|
-
obj[key] = value;
|
|
1593
|
-
}
|
|
1594
|
-
return obj;
|
|
1595
|
-
}
|
|
1596
|
-
function _toPrimitive(input, hint) {
|
|
1597
|
-
if (typeof input !== "object" || input === null) return input;
|
|
1598
|
-
var prim = input[Symbol.toPrimitive];
|
|
1599
|
-
if (prim !== undefined) {
|
|
1600
|
-
var res = prim.call(input, hint || "default");
|
|
1601
|
-
if (typeof res !== "object") return res;
|
|
1602
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1603
|
-
}
|
|
1604
|
-
return (hint === "string" ? String : Number)(input);
|
|
1605
|
-
}
|
|
1606
|
-
function _toPropertyKey(arg) {
|
|
1607
|
-
var key = _toPrimitive(arg, "string");
|
|
1608
|
-
return typeof key === "symbol" ? key : String(key);
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
1653
|
function isIterable(input) {
|
|
1612
1654
|
return Array.isArray(input) || type(input) === 'Object';
|
|
1613
1655
|
}
|
|
@@ -1691,21 +1733,6 @@ function of(value) {
|
|
|
1691
1733
|
return [value];
|
|
1692
1734
|
}
|
|
1693
1735
|
|
|
1694
|
-
function omit(propsToOmit, obj) {
|
|
1695
|
-
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj);
|
|
1696
|
-
if (obj === null || obj === undefined) {
|
|
1697
|
-
return undefined;
|
|
1698
|
-
}
|
|
1699
|
-
const propsToOmitValue = createPath(propsToOmit, ',');
|
|
1700
|
-
const willReturn = {};
|
|
1701
|
-
for (const key in obj) {
|
|
1702
|
-
if (!propsToOmitValue.includes(key)) {
|
|
1703
|
-
willReturn[key] = obj[key];
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
return willReturn;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
1736
|
function on(binaryFn, unaryFn, a, b) {
|
|
1710
1737
|
if (arguments.length === 3) {
|
|
1711
1738
|
return _b => on(binaryFn, unaryFn, a, _b);
|
|
@@ -1750,11 +1777,12 @@ const over = curry(overFn);
|
|
|
1750
1777
|
|
|
1751
1778
|
function partial(fn, ...args) {
|
|
1752
1779
|
const len = fn.length;
|
|
1780
|
+
const argList = args.length === 1 && isArray(args[0]) ? args[0] : args;
|
|
1753
1781
|
return (...rest) => {
|
|
1754
|
-
if (
|
|
1755
|
-
return fn(...
|
|
1782
|
+
if (argList.length + rest.length >= len) {
|
|
1783
|
+
return fn(...argList, ...rest);
|
|
1756
1784
|
}
|
|
1757
|
-
return partial(fn, ...[...
|
|
1785
|
+
return partial(fn, ...[...argList, ...rest]);
|
|
1758
1786
|
};
|
|
1759
1787
|
}
|
|
1760
1788
|
|
|
@@ -2046,7 +2074,7 @@ function symmetricDifference(x, y) {
|
|
|
2046
2074
|
if (arguments.length === 1) {
|
|
2047
2075
|
return _y => symmetricDifference(x, _y);
|
|
2048
2076
|
}
|
|
2049
|
-
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));
|
|
2077
|
+
return concat(filter(value => !includes$1(value, y), x), filter(value => !includes$1(value, x), y));
|
|
2050
2078
|
}
|
|
2051
2079
|
|
|
2052
2080
|
function takeLast(howMany, listOrString) {
|
|
@@ -2170,7 +2198,7 @@ function union(x, y) {
|
|
|
2170
2198
|
if (arguments.length === 1) return _y => union(x, _y);
|
|
2171
2199
|
const toReturn = cloneList(x);
|
|
2172
2200
|
y.forEach(yInstance => {
|
|
2173
|
-
if (!includes(yInstance, x)) toReturn.push(yInstance);
|
|
2201
|
+
if (!includes$1(yInstance, x)) toReturn.push(yInstance);
|
|
2174
2202
|
});
|
|
2175
2203
|
return toReturn;
|
|
2176
2204
|
}
|
|
@@ -2347,7 +2375,9 @@ exports.applySpec = applySpec;
|
|
|
2347
2375
|
exports.applyTo = applyTo;
|
|
2348
2376
|
exports.ascend = ascend;
|
|
2349
2377
|
exports.assoc = assoc;
|
|
2378
|
+
exports.assocFn = assocFn;
|
|
2350
2379
|
exports.assocPath = assocPath;
|
|
2380
|
+
exports.assocPathFn = assocPathFn;
|
|
2351
2381
|
exports.binary = binary;
|
|
2352
2382
|
exports.bind = bind;
|
|
2353
2383
|
exports.both = both;
|
|
@@ -2375,15 +2405,20 @@ exports.difference = difference;
|
|
|
2375
2405
|
exports.differenceWith = differenceWith;
|
|
2376
2406
|
exports.differenceWithFn = differenceWithFn;
|
|
2377
2407
|
exports.dissoc = dissoc;
|
|
2408
|
+
exports.dissocPath = dissocPath;
|
|
2378
2409
|
exports.divide = divide;
|
|
2379
2410
|
exports.drop = drop;
|
|
2380
2411
|
exports.dropLast = dropLast;
|
|
2381
2412
|
exports.dropLastWhile = dropLastWhile;
|
|
2382
2413
|
exports.dropRepeats = dropRepeats;
|
|
2414
|
+
exports.dropRepeatsBy = dropRepeatsBy;
|
|
2383
2415
|
exports.dropRepeatsWith = dropRepeatsWith;
|
|
2384
2416
|
exports.dropWhile = dropWhile;
|
|
2385
2417
|
exports.either = either;
|
|
2418
|
+
exports.empty = empty;
|
|
2386
2419
|
exports.endsWith = endsWith;
|
|
2420
|
+
exports.eqBy = eqBy;
|
|
2421
|
+
exports.eqByFn = eqByFn;
|
|
2387
2422
|
exports.eqProps = eqProps;
|
|
2388
2423
|
exports.equals = equals;
|
|
2389
2424
|
exports.evolve = evolve;
|
|
@@ -2399,6 +2434,8 @@ exports.findLastIndex = findLastIndex;
|
|
|
2399
2434
|
exports.flatten = flatten;
|
|
2400
2435
|
exports.flip = flip;
|
|
2401
2436
|
exports.forEach = forEach;
|
|
2437
|
+
exports.forEachObjIndexed = forEachObjIndexed;
|
|
2438
|
+
exports.forEachObjIndexedFn = forEachObjIndexedFn;
|
|
2402
2439
|
exports.fromPairs = fromPairs;
|
|
2403
2440
|
exports.groupBy = groupBy;
|
|
2404
2441
|
exports.groupWith = groupWith;
|
|
@@ -2409,7 +2446,7 @@ exports.identical = identical;
|
|
|
2409
2446
|
exports.identity = identity;
|
|
2410
2447
|
exports.ifElse = ifElse;
|
|
2411
2448
|
exports.inc = inc;
|
|
2412
|
-
exports.includes = includes;
|
|
2449
|
+
exports.includes = includes$1;
|
|
2413
2450
|
exports.indexBy = indexBy;
|
|
2414
2451
|
exports.indexOf = indexOf;
|
|
2415
2452
|
exports.init = init;
|
|
@@ -2445,6 +2482,7 @@ exports.mergeDeepRight = mergeDeepRight;
|
|
|
2445
2482
|
exports.mergeLeft = mergeLeft;
|
|
2446
2483
|
exports.mergeRight = mergeRight;
|
|
2447
2484
|
exports.mergeWith = mergeWith;
|
|
2485
|
+
exports.mergeWithFn = mergeWithFn;
|
|
2448
2486
|
exports.min = min;
|
|
2449
2487
|
exports.minBy = minBy;
|
|
2450
2488
|
exports.minByFn = minByFn;
|
|
@@ -2493,6 +2531,7 @@ exports.reduce = reduce;
|
|
|
2493
2531
|
exports.reduceFn = reduceFn;
|
|
2494
2532
|
exports.reduceStopper = reduceStopper;
|
|
2495
2533
|
exports.reject = reject;
|
|
2534
|
+
exports.removeIndex = removeIndex;
|
|
2496
2535
|
exports.repeat = repeat;
|
|
2497
2536
|
exports.replace = replace;
|
|
2498
2537
|
exports.reverse = reverse;
|