rambda 7.2.0 → 7.3.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 +18 -0
- package/README.md +1615 -1474
- package/dist/rambda.js +96 -82
- package/dist/rambda.mjs +95 -83
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +15 -5
- package/index.d.ts +15 -5
- package/package.json +17 -14
- package/src/_internals/constants.js +1 -0
- package/src/_internals/isArray.js +1 -0
- package/src/_internals/isFalsy.js +2 -2
- package/src/_internals/isInteger.js +5 -0
- package/src/_internals/isIterable.js +5 -0
- package/src/_internals/isObject.js +1 -1
- package/src/_internals/isTruthy.js +2 -2
- package/src/_internals/keys.js +1 -0
- package/src/_internals/{_objectIs.js → objectIs.js} +2 -2
- package/src/applySpec.js +3 -3
- package/src/assocPath.js +7 -7
- package/src/clone.js +2 -2
- package/src/count.js +2 -2
- package/src/dropLastWhile.js +2 -2
- package/src/dropRepeats.js +2 -2
- package/src/dropRepeatsWith.js +2 -2
- package/src/dropWhile.js +2 -2
- package/src/endsWith.js +2 -2
- package/src/equals.js +3 -3
- package/src/evolve.js +1 -1
- package/src/filter.js +2 -2
- package/src/flatten.js +2 -2
- package/src/forEach.js +6 -6
- package/src/groupWith.js +2 -2
- package/src/identical.js +2 -2
- package/src/includes.js +2 -2
- package/src/isPromise.js +1 -1
- package/src/length.js +2 -2
- package/src/map.js +7 -7
- package/src/mathMod.js +2 -2
- package/src/merge.js +1 -1
- package/src/mergeDeepRight.js +2 -1
- package/src/mergeRight.js +2 -1
- package/src/modify.js +23 -0
- package/src/modifyPath.js +2 -2
- package/src/partialObject.js +1 -11
- package/src/partition.js +2 -2
- package/src/props.js +2 -2
- package/src/reduce.js +2 -3
- package/src/splitAt.js +2 -2
- package/src/startsWith.js +2 -2
- package/src/takeLastWhile.js +2 -2
- package/src/takeWhile.js +2 -2
- package/src/times.js +2 -1
- package/src/transpose.js +2 -2
- package/src/unwind.js +4 -3
- package/src/update.js +1 -1
- package/src/where.js +1 -0
- package/src/_internals/_isArray.js +0 -1
- package/src/_internals/_isInteger.js +0 -5
- package/src/_internals/_keys.js +0 -1
package/dist/rambda.js
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
function F() {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function T() {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
function add(a, b) {
|
|
6
14
|
if (arguments.length === 1) return _b => add(a, _b);
|
|
7
15
|
return Number(a) + Number(b);
|
|
@@ -105,7 +113,9 @@ function apply(fn, args) {
|
|
|
105
113
|
return fn.apply(this, args);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
const
|
|
116
|
+
const {
|
|
117
|
+
isArray
|
|
118
|
+
} = Array;
|
|
109
119
|
|
|
110
120
|
function __findHighestArity(spec, max = 0) {
|
|
111
121
|
for (const key in spec) {
|
|
@@ -145,13 +155,13 @@ function __applySpecWithArity(spec, arity, cache) {
|
|
|
145
155
|
if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a));
|
|
146
156
|
if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
|
|
147
157
|
|
|
148
|
-
if (
|
|
158
|
+
if (isArray(spec)) {
|
|
149
159
|
const ret = [];
|
|
150
160
|
let i = 0;
|
|
151
161
|
const l = spec.length;
|
|
152
162
|
|
|
153
163
|
for (; i < l; i++) {
|
|
154
|
-
if (typeof spec[i] === 'object' ||
|
|
164
|
+
if (typeof spec[i] === 'object' || isArray(spec[i])) {
|
|
155
165
|
ret[i] = __applySpecWithArity(spec[i], arity, cache);
|
|
156
166
|
}
|
|
157
167
|
|
|
@@ -204,10 +214,11 @@ const assoc = curry(assocFn);
|
|
|
204
214
|
function _isInteger(n) {
|
|
205
215
|
return n << 0 === n;
|
|
206
216
|
}
|
|
207
|
-
|
|
217
|
+
|
|
218
|
+
const isInteger = Number.isInteger || _isInteger;
|
|
208
219
|
|
|
209
220
|
function assocPathFn(path, newValue, input) {
|
|
210
|
-
const pathArrValue = typeof path === 'string' ? path.split('.').map(x =>
|
|
221
|
+
const pathArrValue = typeof path === 'string' ? path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) : path;
|
|
211
222
|
|
|
212
223
|
if (pathArrValue.length === 0) {
|
|
213
224
|
return newValue;
|
|
@@ -217,11 +228,11 @@ function assocPathFn(path, newValue, input) {
|
|
|
217
228
|
|
|
218
229
|
if (pathArrValue.length > 1) {
|
|
219
230
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
220
|
-
const
|
|
221
|
-
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue,
|
|
231
|
+
const nextInput = condition ? isInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
232
|
+
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
if (
|
|
235
|
+
if (isInteger(index) && isArray(input)) {
|
|
225
236
|
const arr = cloneList(input);
|
|
226
237
|
arr[index] = newValue;
|
|
227
238
|
return arr;
|
|
@@ -358,7 +369,7 @@ function clampFn(min, max, input) {
|
|
|
358
369
|
const clamp = curry(clampFn);
|
|
359
370
|
|
|
360
371
|
function clone(input) {
|
|
361
|
-
const out =
|
|
372
|
+
const out = isArray(input) ? Array(input.length) : {};
|
|
362
373
|
if (input && input.getTime) return new Date(input.getTime());
|
|
363
374
|
|
|
364
375
|
for (const key in input) {
|
|
@@ -373,8 +384,6 @@ function complement(fn) {
|
|
|
373
384
|
return (...input) => !fn(...input);
|
|
374
385
|
}
|
|
375
386
|
|
|
376
|
-
const _keys = Object.keys;
|
|
377
|
-
|
|
378
387
|
class ReduceStopper {
|
|
379
388
|
constructor(value) {
|
|
380
389
|
this.value = value;
|
|
@@ -383,7 +392,7 @@ class ReduceStopper {
|
|
|
383
392
|
}
|
|
384
393
|
|
|
385
394
|
function reduceFn(reducer, acc, list) {
|
|
386
|
-
if (!
|
|
395
|
+
if (!isArray(list)) {
|
|
387
396
|
throw new TypeError('reduce: list must be array or iterable');
|
|
388
397
|
}
|
|
389
398
|
|
|
@@ -506,6 +515,10 @@ function cond(conditions) {
|
|
|
506
515
|
};
|
|
507
516
|
}
|
|
508
517
|
|
|
518
|
+
const {
|
|
519
|
+
keys: keys$1
|
|
520
|
+
} = Object;
|
|
521
|
+
|
|
509
522
|
function mapArray(fn, list, isIndexed = false) {
|
|
510
523
|
let index = 0;
|
|
511
524
|
const willReturn = Array(list.length);
|
|
@@ -523,14 +536,12 @@ function mapObject(fn, obj) {
|
|
|
523
536
|
}
|
|
524
537
|
|
|
525
538
|
let index = 0;
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
const len = keys.length;
|
|
539
|
+
const objKeys = keys$1(obj);
|
|
540
|
+
const len = objKeys.length;
|
|
530
541
|
const willReturn = {};
|
|
531
542
|
|
|
532
543
|
while (index < len) {
|
|
533
|
-
const key =
|
|
544
|
+
const key = objKeys[index];
|
|
534
545
|
willReturn[key] = fn(obj[key], key, obj);
|
|
535
546
|
index++;
|
|
536
547
|
}
|
|
@@ -542,10 +553,10 @@ function map(fn, iterable) {
|
|
|
542
553
|
if (arguments.length === 1) return _iterable => map(fn, _iterable);
|
|
543
554
|
|
|
544
555
|
if (!iterable) {
|
|
545
|
-
throw new Error(
|
|
556
|
+
throw new Error(INCORRECT_ITERABLE_INPUT);
|
|
546
557
|
}
|
|
547
558
|
|
|
548
|
-
if (
|
|
559
|
+
if (isArray(iterable)) return mapArray(fn, iterable);
|
|
549
560
|
return mapObject(fn, iterable);
|
|
550
561
|
}
|
|
551
562
|
|
|
@@ -567,7 +578,7 @@ function count(predicate, list) {
|
|
|
567
578
|
return _list => count(predicate, _list);
|
|
568
579
|
}
|
|
569
580
|
|
|
570
|
-
if (!
|
|
581
|
+
if (!isArray(list)) return 0;
|
|
571
582
|
return list.filter(x => predicate(x)).length;
|
|
572
583
|
}
|
|
573
584
|
|
|
@@ -617,7 +628,7 @@ function type(input) {
|
|
|
617
628
|
}
|
|
618
629
|
|
|
619
630
|
function _lastIndexOf(valueToFind, list) {
|
|
620
|
-
if (!
|
|
631
|
+
if (!isArray(list)) {
|
|
621
632
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
622
633
|
}
|
|
623
634
|
|
|
@@ -638,7 +649,7 @@ function _lastIndexOf(valueToFind, list) {
|
|
|
638
649
|
return foundIndex;
|
|
639
650
|
}
|
|
640
651
|
function _indexOf(valueToFind, list) {
|
|
641
|
-
if (!
|
|
652
|
+
if (!isArray(list)) {
|
|
642
653
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
643
654
|
}
|
|
644
655
|
|
|
@@ -799,7 +810,7 @@ function includes(valueToFind, iterable) {
|
|
|
799
810
|
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
|
|
800
811
|
}
|
|
801
812
|
|
|
802
|
-
if (!
|
|
813
|
+
if (!isArray(iterable)) return false;
|
|
803
814
|
return _indexOf(valueToFind, iterable) > -1;
|
|
804
815
|
}
|
|
805
816
|
|
|
@@ -895,14 +906,13 @@ function dropLastWhile(predicate, iterable) {
|
|
|
895
906
|
}
|
|
896
907
|
|
|
897
908
|
if (iterable.length === 0) return iterable;
|
|
898
|
-
|
|
899
|
-
const isArray = _isArray(iterable);
|
|
909
|
+
const isArray$1 = isArray(iterable);
|
|
900
910
|
|
|
901
911
|
if (typeof predicate !== 'function') {
|
|
902
912
|
throw new Error(`'predicate' is from wrong type ${typeof predicate}`);
|
|
903
913
|
}
|
|
904
914
|
|
|
905
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
915
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
906
916
|
throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
|
|
907
917
|
}
|
|
908
918
|
|
|
@@ -921,11 +931,11 @@ function dropLastWhile(predicate, iterable) {
|
|
|
921
931
|
}
|
|
922
932
|
}
|
|
923
933
|
|
|
924
|
-
return isArray ? toReturn.reverse() : toReturn.reverse().join('');
|
|
934
|
+
return isArray$1 ? toReturn.reverse() : toReturn.reverse().join('');
|
|
925
935
|
}
|
|
926
936
|
|
|
927
937
|
function dropRepeats(list) {
|
|
928
|
-
if (!
|
|
938
|
+
if (!isArray(list)) {
|
|
929
939
|
throw new Error(`${list} is not a list`);
|
|
930
940
|
}
|
|
931
941
|
|
|
@@ -945,7 +955,7 @@ function dropRepeatsWith(predicate, list) {
|
|
|
945
955
|
return _iterable => dropRepeatsWith(predicate, _iterable);
|
|
946
956
|
}
|
|
947
957
|
|
|
948
|
-
if (!
|
|
958
|
+
if (!isArray(list)) {
|
|
949
959
|
throw new Error(`${list} is not a list`);
|
|
950
960
|
}
|
|
951
961
|
|
|
@@ -970,9 +980,9 @@ function dropWhile(predicate, iterable) {
|
|
|
970
980
|
return _iterable => dropWhile(predicate, _iterable);
|
|
971
981
|
}
|
|
972
982
|
|
|
973
|
-
const isArray =
|
|
983
|
+
const isArray$1 = isArray(iterable);
|
|
974
984
|
|
|
975
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
985
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
976
986
|
throw new Error('`iterable` is neither list nor a string');
|
|
977
987
|
}
|
|
978
988
|
|
|
@@ -989,7 +999,7 @@ function dropWhile(predicate, iterable) {
|
|
|
989
999
|
}
|
|
990
1000
|
}
|
|
991
1001
|
|
|
992
|
-
return isArray ? holder : holder.join('');
|
|
1002
|
+
return isArray$1 ? holder : holder.join('');
|
|
993
1003
|
}
|
|
994
1004
|
|
|
995
1005
|
function either(firstPredicate, secondPredicate) {
|
|
@@ -1007,7 +1017,7 @@ function endsWith(target, iterable) {
|
|
|
1007
1017
|
return iterable.endsWith(target);
|
|
1008
1018
|
}
|
|
1009
1019
|
|
|
1010
|
-
if (!
|
|
1020
|
+
if (!isArray(target)) return false;
|
|
1011
1021
|
const diff = iterable.length - target.length;
|
|
1012
1022
|
let correct = true;
|
|
1013
1023
|
const filtered = target.filter((x, index) => {
|
|
@@ -1086,10 +1096,6 @@ function evolve(rules, iterable) {
|
|
|
1086
1096
|
return evolveArray(rules, iterable);
|
|
1087
1097
|
}
|
|
1088
1098
|
|
|
1089
|
-
function F() {
|
|
1090
|
-
return false;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
1099
|
function filterObject(predicate, obj) {
|
|
1094
1100
|
const willReturn = {};
|
|
1095
1101
|
|
|
@@ -1125,7 +1131,7 @@ function filter(predicate, iterable) {
|
|
|
1125
1131
|
throw new Error('Incorrect iterable input');
|
|
1126
1132
|
}
|
|
1127
1133
|
|
|
1128
|
-
if (
|
|
1134
|
+
if (isArray(iterable)) return filterArray(predicate, iterable, false);
|
|
1129
1135
|
return filterObject(predicate, iterable);
|
|
1130
1136
|
}
|
|
1131
1137
|
|
|
@@ -1189,7 +1195,7 @@ function flatten(list, input) {
|
|
|
1189
1195
|
const willReturn = input === undefined ? [] : input;
|
|
1190
1196
|
|
|
1191
1197
|
for (let i = 0; i < list.length; i++) {
|
|
1192
|
-
if (
|
|
1198
|
+
if (isArray(list[i])) {
|
|
1193
1199
|
flatten(list[i], willReturn);
|
|
1194
1200
|
} else {
|
|
1195
1201
|
willReturn.push(list[i]);
|
|
@@ -1226,7 +1232,7 @@ function forEach(fn, list) {
|
|
|
1226
1232
|
return;
|
|
1227
1233
|
}
|
|
1228
1234
|
|
|
1229
|
-
if (
|
|
1235
|
+
if (isArray(list)) {
|
|
1230
1236
|
let index = 0;
|
|
1231
1237
|
const len = list.length;
|
|
1232
1238
|
|
|
@@ -1236,13 +1242,11 @@ function forEach(fn, list) {
|
|
|
1236
1242
|
}
|
|
1237
1243
|
} else {
|
|
1238
1244
|
let index = 0;
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
const len = keys.length;
|
|
1245
|
+
const listKeys = keys$1(list);
|
|
1246
|
+
const len = listKeys.length;
|
|
1243
1247
|
|
|
1244
1248
|
while (index < len) {
|
|
1245
|
-
const key =
|
|
1249
|
+
const key = listKeys[index];
|
|
1246
1250
|
fn(list[key], key, list);
|
|
1247
1251
|
index++;
|
|
1248
1252
|
}
|
|
@@ -1276,7 +1280,7 @@ function groupBy(groupFn, list) {
|
|
|
1276
1280
|
}
|
|
1277
1281
|
|
|
1278
1282
|
function groupWith(compareFn, list) {
|
|
1279
|
-
if (!
|
|
1283
|
+
if (!isArray(list)) throw new TypeError('list.reduce is not a function');
|
|
1280
1284
|
const clone = cloneList(list);
|
|
1281
1285
|
if (list.length === 1) return [clone];
|
|
1282
1286
|
const toReturn = [];
|
|
@@ -1362,11 +1366,12 @@ function _objectIs(a, b) {
|
|
|
1362
1366
|
|
|
1363
1367
|
return a !== a && b !== b;
|
|
1364
1368
|
}
|
|
1365
|
-
|
|
1369
|
+
|
|
1370
|
+
const objectIs = Object.is || _objectIs;
|
|
1366
1371
|
|
|
1367
1372
|
function identical(a, b) {
|
|
1368
1373
|
if (arguments.length === 1) return _b => identical(a, _b);
|
|
1369
|
-
return
|
|
1374
|
+
return objectIs(a, b);
|
|
1370
1375
|
}
|
|
1371
1376
|
|
|
1372
1377
|
function identity(x) {
|
|
@@ -1531,7 +1536,7 @@ function lastIndexOf(valueToFind, list) {
|
|
|
1531
1536
|
}
|
|
1532
1537
|
|
|
1533
1538
|
function length(x) {
|
|
1534
|
-
if (
|
|
1539
|
+
if (isArray(x)) return x.length;
|
|
1535
1540
|
if (typeof x === 'string') return x.length;
|
|
1536
1541
|
return NaN;
|
|
1537
1542
|
}
|
|
@@ -1555,7 +1560,6 @@ function updateFn(index, newValue, list) {
|
|
|
1555
1560
|
if (index === -1) return clone.fill(newValue, index);
|
|
1556
1561
|
return clone.fill(newValue, index, index + 1);
|
|
1557
1562
|
}
|
|
1558
|
-
|
|
1559
1563
|
const update = curry(updateFn);
|
|
1560
1564
|
|
|
1561
1565
|
function lensIndex(index) {
|
|
@@ -1578,7 +1582,7 @@ function match(pattern, input) {
|
|
|
1578
1582
|
|
|
1579
1583
|
function mathMod(x, y) {
|
|
1580
1584
|
if (arguments.length === 1) return _y => mathMod(x, _y);
|
|
1581
|
-
if (!
|
|
1585
|
+
if (!isInteger(x) || !isInteger(y) || y < 1) return NaN;
|
|
1582
1586
|
return (x % y + y) % y;
|
|
1583
1587
|
}
|
|
1584
1588
|
|
|
@@ -1624,7 +1628,7 @@ function mergeDeepRight(target, source) {
|
|
|
1624
1628
|
return sourceHolder => mergeDeepRight(target, sourceHolder);
|
|
1625
1629
|
}
|
|
1626
1630
|
|
|
1627
|
-
const willReturn =
|
|
1631
|
+
const willReturn = clone(target);
|
|
1628
1632
|
Object.keys(source).forEach(key => {
|
|
1629
1633
|
if (type(source[key]) === 'Object') {
|
|
1630
1634
|
if (type(target[key]) === 'Object') {
|
|
@@ -1718,6 +1722,25 @@ function _defineProperty(obj, key, value) {
|
|
|
1718
1722
|
return obj;
|
|
1719
1723
|
}
|
|
1720
1724
|
|
|
1725
|
+
function isIterable(input) {
|
|
1726
|
+
return Array.isArray(input) || type(input) === 'Object';
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
function modifyFn(property, fn, iterable) {
|
|
1730
|
+
if (!isIterable(iterable)) return iterable;
|
|
1731
|
+
if (iterable[property] === undefined) return iterable;
|
|
1732
|
+
|
|
1733
|
+
if (isArray(iterable)) {
|
|
1734
|
+
return updateFn(property, fn(iterable[property]), iterable);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
return _objectSpread2(_objectSpread2({}, iterable), {}, {
|
|
1738
|
+
[property]: fn(iterable[property])
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
const modify = curry(modifyFn);
|
|
1743
|
+
|
|
1721
1744
|
function modifyPathFn(pathInput, fn, object) {
|
|
1722
1745
|
const path$1 = createPath(pathInput);
|
|
1723
1746
|
|
|
@@ -1874,15 +1897,7 @@ function partial(fn, ...args) {
|
|
|
1874
1897
|
}
|
|
1875
1898
|
|
|
1876
1899
|
function partialObject(fn, input) {
|
|
1877
|
-
return
|
|
1878
|
-
if (type(fn) === 'Async') {
|
|
1879
|
-
return new Promise((resolve, reject) => {
|
|
1880
|
-
fn(mergeDeepRight(rest, input)).then(resolve).catch(reject);
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
return fn(mergeDeepRight(rest, input));
|
|
1885
|
-
};
|
|
1900
|
+
return nextInput => fn(mergeDeepRight(nextInput, input));
|
|
1886
1901
|
}
|
|
1887
1902
|
|
|
1888
1903
|
function partitionObject(predicate, iterable) {
|
|
@@ -1917,7 +1932,7 @@ function partition(predicate, iterable) {
|
|
|
1917
1932
|
return listHolder => partition(predicate, listHolder);
|
|
1918
1933
|
}
|
|
1919
1934
|
|
|
1920
|
-
if (!
|
|
1935
|
+
if (!isArray(iterable)) return partitionObject(predicate, iterable);
|
|
1921
1936
|
return partitionArray(predicate, iterable);
|
|
1922
1937
|
}
|
|
1923
1938
|
|
|
@@ -2026,24 +2041,24 @@ function propOrFn(defaultValue, property, obj) {
|
|
|
2026
2041
|
|
|
2027
2042
|
const propOr = curry(propOrFn);
|
|
2028
2043
|
|
|
2044
|
+
function propSatisfiesFn(predicate, property, obj) {
|
|
2045
|
+
return predicate(prop(property, obj));
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
const propSatisfies = curry(propSatisfiesFn);
|
|
2049
|
+
|
|
2029
2050
|
function props(propsToPick, obj) {
|
|
2030
2051
|
if (arguments.length === 1) {
|
|
2031
2052
|
return _obj => props(propsToPick, _obj);
|
|
2032
2053
|
}
|
|
2033
2054
|
|
|
2034
|
-
if (!
|
|
2055
|
+
if (!isArray(propsToPick)) {
|
|
2035
2056
|
throw new Error('propsToPick is not a list');
|
|
2036
2057
|
}
|
|
2037
2058
|
|
|
2038
2059
|
return mapArray(prop => obj[prop], propsToPick);
|
|
2039
2060
|
}
|
|
2040
2061
|
|
|
2041
|
-
function propSatisfiesFn(predicate, property, obj) {
|
|
2042
|
-
return predicate(prop(property, obj));
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
const propSatisfies = curry(propSatisfiesFn);
|
|
2046
|
-
|
|
2047
2062
|
function range(start, end) {
|
|
2048
2063
|
if (arguments.length === 1) return _end => range(start, _end);
|
|
2049
2064
|
|
|
@@ -2142,7 +2157,7 @@ function splitAt(index, input) {
|
|
|
2142
2157
|
}
|
|
2143
2158
|
|
|
2144
2159
|
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`);
|
|
2145
|
-
if (!
|
|
2160
|
+
if (!isArray(input) && typeof input !== 'string') return [[], []];
|
|
2146
2161
|
const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index);
|
|
2147
2162
|
return [take(correctIndex, input), drop(correctIndex, input)];
|
|
2148
2163
|
}
|
|
@@ -2198,7 +2213,7 @@ function startsWith(target, iterable) {
|
|
|
2198
2213
|
return iterable.startsWith(target);
|
|
2199
2214
|
}
|
|
2200
2215
|
|
|
2201
|
-
if (!
|
|
2216
|
+
if (!isArray(target)) return false;
|
|
2202
2217
|
let correct = true;
|
|
2203
2218
|
const filtered = target.filter((x, index) => {
|
|
2204
2219
|
if (!correct) return false;
|
|
@@ -2222,10 +2237,6 @@ function symmetricDifference(x, y) {
|
|
|
2222
2237
|
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));
|
|
2223
2238
|
}
|
|
2224
2239
|
|
|
2225
|
-
function T() {
|
|
2226
|
-
return true;
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
2240
|
function tail(listOrString) {
|
|
2230
2241
|
return drop(1, listOrString);
|
|
2231
2242
|
}
|
|
@@ -2260,7 +2271,7 @@ function takeLastWhile(predicate, input) {
|
|
|
2260
2271
|
}
|
|
2261
2272
|
}
|
|
2262
2273
|
|
|
2263
|
-
return
|
|
2274
|
+
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');
|
|
2264
2275
|
}
|
|
2265
2276
|
|
|
2266
2277
|
function takeWhile(predicate, iterable) {
|
|
@@ -2268,9 +2279,9 @@ function takeWhile(predicate, iterable) {
|
|
|
2268
2279
|
return _iterable => takeWhile(predicate, _iterable);
|
|
2269
2280
|
}
|
|
2270
2281
|
|
|
2271
|
-
const isArray =
|
|
2282
|
+
const isArray$1 = isArray(iterable);
|
|
2272
2283
|
|
|
2273
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
2284
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
2274
2285
|
throw new Error('`iterable` is neither list nor a string');
|
|
2275
2286
|
}
|
|
2276
2287
|
|
|
@@ -2285,7 +2296,7 @@ function takeWhile(predicate, iterable) {
|
|
|
2285
2296
|
holder.push(iterable[counter]);
|
|
2286
2297
|
}
|
|
2287
2298
|
}
|
|
2288
|
-
return isArray ? holder : holder.join('');
|
|
2299
|
+
return isArray$1 ? holder : holder.join('');
|
|
2289
2300
|
}
|
|
2290
2301
|
|
|
2291
2302
|
function tap(fn, x) {
|
|
@@ -2307,7 +2318,7 @@ function test(pattern, str) {
|
|
|
2307
2318
|
function times(fn, howMany) {
|
|
2308
2319
|
if (arguments.length === 1) return _howMany => times(fn, _howMany);
|
|
2309
2320
|
|
|
2310
|
-
if (!
|
|
2321
|
+
if (!isInteger(howMany) || howMany < 0) {
|
|
2311
2322
|
throw new RangeError('n must be an integer');
|
|
2312
2323
|
}
|
|
2313
2324
|
|
|
@@ -2332,7 +2343,7 @@ function toUpper(str) {
|
|
|
2332
2343
|
|
|
2333
2344
|
function transpose(array) {
|
|
2334
2345
|
return array.reduce((acc, el) => {
|
|
2335
|
-
el.forEach((nestedEl, i) =>
|
|
2346
|
+
el.forEach((nestedEl, i) => isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl]));
|
|
2336
2347
|
return acc;
|
|
2337
2348
|
}, []);
|
|
2338
2349
|
}
|
|
@@ -2430,7 +2441,7 @@ function unwind(property, obj) {
|
|
|
2430
2441
|
return _obj => unwind(property, _obj);
|
|
2431
2442
|
}
|
|
2432
2443
|
|
|
2433
|
-
if (!
|
|
2444
|
+
if (!isArray(obj[property])) return [obj];
|
|
2434
2445
|
return mapArray(x => _objectSpread2(_objectSpread2({}, obj), {}, {
|
|
2435
2446
|
[property]: x
|
|
2436
2447
|
}), obj[property]);
|
|
@@ -2466,6 +2477,7 @@ function where(conditions, input) {
|
|
|
2466
2477
|
let flag = true;
|
|
2467
2478
|
|
|
2468
2479
|
for (const prop in conditions) {
|
|
2480
|
+
if (!flag) continue;
|
|
2469
2481
|
const result = conditions[prop](input[prop]);
|
|
2470
2482
|
|
|
2471
2483
|
if (flag && result === false) {
|
|
@@ -2649,6 +2661,7 @@ exports.mergeWith = mergeWith;
|
|
|
2649
2661
|
exports.min = min;
|
|
2650
2662
|
exports.minBy = minBy;
|
|
2651
2663
|
exports.minByFn = minByFn;
|
|
2664
|
+
exports.modify = modify;
|
|
2652
2665
|
exports.modifyPath = modifyPath;
|
|
2653
2666
|
exports.modifyPathFn = modifyPathFn;
|
|
2654
2667
|
exports.modulo = modulo;
|
|
@@ -2730,6 +2743,7 @@ exports.uniqWith = uniqWith;
|
|
|
2730
2743
|
exports.unless = unless;
|
|
2731
2744
|
exports.unwind = unwind;
|
|
2732
2745
|
exports.update = update;
|
|
2746
|
+
exports.updateFn = updateFn;
|
|
2733
2747
|
exports.values = values;
|
|
2734
2748
|
exports.view = view;
|
|
2735
2749
|
exports.when = when;
|