rambda 7.2.1 → 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 +12 -0
- package/README.md +1597 -1458
- package/dist/rambda.js +82 -68
- package/dist/rambda.mjs +81 -69
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +15 -1
- package/index.d.ts +15 -1
- package/package.json +16 -13
- 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
|
@@ -113,7 +113,9 @@ function apply(fn, args) {
|
|
|
113
113
|
return fn.apply(this, args);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const
|
|
116
|
+
const {
|
|
117
|
+
isArray
|
|
118
|
+
} = Array;
|
|
117
119
|
|
|
118
120
|
function __findHighestArity(spec, max = 0) {
|
|
119
121
|
for (const key in spec) {
|
|
@@ -153,13 +155,13 @@ function __applySpecWithArity(spec, arity, cache) {
|
|
|
153
155
|
if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a));
|
|
154
156
|
if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
|
|
155
157
|
|
|
156
|
-
if (
|
|
158
|
+
if (isArray(spec)) {
|
|
157
159
|
const ret = [];
|
|
158
160
|
let i = 0;
|
|
159
161
|
const l = spec.length;
|
|
160
162
|
|
|
161
163
|
for (; i < l; i++) {
|
|
162
|
-
if (typeof spec[i] === 'object' ||
|
|
164
|
+
if (typeof spec[i] === 'object' || isArray(spec[i])) {
|
|
163
165
|
ret[i] = __applySpecWithArity(spec[i], arity, cache);
|
|
164
166
|
}
|
|
165
167
|
|
|
@@ -212,10 +214,11 @@ const assoc = curry(assocFn);
|
|
|
212
214
|
function _isInteger(n) {
|
|
213
215
|
return n << 0 === n;
|
|
214
216
|
}
|
|
215
|
-
|
|
217
|
+
|
|
218
|
+
const isInteger = Number.isInteger || _isInteger;
|
|
216
219
|
|
|
217
220
|
function assocPathFn(path, newValue, input) {
|
|
218
|
-
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;
|
|
219
222
|
|
|
220
223
|
if (pathArrValue.length === 0) {
|
|
221
224
|
return newValue;
|
|
@@ -225,11 +228,11 @@ function assocPathFn(path, newValue, input) {
|
|
|
225
228
|
|
|
226
229
|
if (pathArrValue.length > 1) {
|
|
227
230
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
228
|
-
const
|
|
229
|
-
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);
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
if (
|
|
235
|
+
if (isInteger(index) && isArray(input)) {
|
|
233
236
|
const arr = cloneList(input);
|
|
234
237
|
arr[index] = newValue;
|
|
235
238
|
return arr;
|
|
@@ -366,7 +369,7 @@ function clampFn(min, max, input) {
|
|
|
366
369
|
const clamp = curry(clampFn);
|
|
367
370
|
|
|
368
371
|
function clone(input) {
|
|
369
|
-
const out =
|
|
372
|
+
const out = isArray(input) ? Array(input.length) : {};
|
|
370
373
|
if (input && input.getTime) return new Date(input.getTime());
|
|
371
374
|
|
|
372
375
|
for (const key in input) {
|
|
@@ -381,8 +384,6 @@ function complement(fn) {
|
|
|
381
384
|
return (...input) => !fn(...input);
|
|
382
385
|
}
|
|
383
386
|
|
|
384
|
-
const _keys = Object.keys;
|
|
385
|
-
|
|
386
387
|
class ReduceStopper {
|
|
387
388
|
constructor(value) {
|
|
388
389
|
this.value = value;
|
|
@@ -391,7 +392,7 @@ class ReduceStopper {
|
|
|
391
392
|
}
|
|
392
393
|
|
|
393
394
|
function reduceFn(reducer, acc, list) {
|
|
394
|
-
if (!
|
|
395
|
+
if (!isArray(list)) {
|
|
395
396
|
throw new TypeError('reduce: list must be array or iterable');
|
|
396
397
|
}
|
|
397
398
|
|
|
@@ -514,6 +515,10 @@ function cond(conditions) {
|
|
|
514
515
|
};
|
|
515
516
|
}
|
|
516
517
|
|
|
518
|
+
const {
|
|
519
|
+
keys: keys$1
|
|
520
|
+
} = Object;
|
|
521
|
+
|
|
517
522
|
function mapArray(fn, list, isIndexed = false) {
|
|
518
523
|
let index = 0;
|
|
519
524
|
const willReturn = Array(list.length);
|
|
@@ -531,14 +536,12 @@ function mapObject(fn, obj) {
|
|
|
531
536
|
}
|
|
532
537
|
|
|
533
538
|
let index = 0;
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const len = keys.length;
|
|
539
|
+
const objKeys = keys$1(obj);
|
|
540
|
+
const len = objKeys.length;
|
|
538
541
|
const willReturn = {};
|
|
539
542
|
|
|
540
543
|
while (index < len) {
|
|
541
|
-
const key =
|
|
544
|
+
const key = objKeys[index];
|
|
542
545
|
willReturn[key] = fn(obj[key], key, obj);
|
|
543
546
|
index++;
|
|
544
547
|
}
|
|
@@ -550,10 +553,10 @@ function map(fn, iterable) {
|
|
|
550
553
|
if (arguments.length === 1) return _iterable => map(fn, _iterable);
|
|
551
554
|
|
|
552
555
|
if (!iterable) {
|
|
553
|
-
throw new Error(
|
|
556
|
+
throw new Error(INCORRECT_ITERABLE_INPUT);
|
|
554
557
|
}
|
|
555
558
|
|
|
556
|
-
if (
|
|
559
|
+
if (isArray(iterable)) return mapArray(fn, iterable);
|
|
557
560
|
return mapObject(fn, iterable);
|
|
558
561
|
}
|
|
559
562
|
|
|
@@ -575,7 +578,7 @@ function count(predicate, list) {
|
|
|
575
578
|
return _list => count(predicate, _list);
|
|
576
579
|
}
|
|
577
580
|
|
|
578
|
-
if (!
|
|
581
|
+
if (!isArray(list)) return 0;
|
|
579
582
|
return list.filter(x => predicate(x)).length;
|
|
580
583
|
}
|
|
581
584
|
|
|
@@ -625,7 +628,7 @@ function type(input) {
|
|
|
625
628
|
}
|
|
626
629
|
|
|
627
630
|
function _lastIndexOf(valueToFind, list) {
|
|
628
|
-
if (!
|
|
631
|
+
if (!isArray(list)) {
|
|
629
632
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
630
633
|
}
|
|
631
634
|
|
|
@@ -646,7 +649,7 @@ function _lastIndexOf(valueToFind, list) {
|
|
|
646
649
|
return foundIndex;
|
|
647
650
|
}
|
|
648
651
|
function _indexOf(valueToFind, list) {
|
|
649
|
-
if (!
|
|
652
|
+
if (!isArray(list)) {
|
|
650
653
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
651
654
|
}
|
|
652
655
|
|
|
@@ -807,7 +810,7 @@ function includes(valueToFind, iterable) {
|
|
|
807
810
|
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
|
|
808
811
|
}
|
|
809
812
|
|
|
810
|
-
if (!
|
|
813
|
+
if (!isArray(iterable)) return false;
|
|
811
814
|
return _indexOf(valueToFind, iterable) > -1;
|
|
812
815
|
}
|
|
813
816
|
|
|
@@ -903,14 +906,13 @@ function dropLastWhile(predicate, iterable) {
|
|
|
903
906
|
}
|
|
904
907
|
|
|
905
908
|
if (iterable.length === 0) return iterable;
|
|
906
|
-
|
|
907
|
-
const isArray = _isArray(iterable);
|
|
909
|
+
const isArray$1 = isArray(iterable);
|
|
908
910
|
|
|
909
911
|
if (typeof predicate !== 'function') {
|
|
910
912
|
throw new Error(`'predicate' is from wrong type ${typeof predicate}`);
|
|
911
913
|
}
|
|
912
914
|
|
|
913
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
915
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
914
916
|
throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
|
|
915
917
|
}
|
|
916
918
|
|
|
@@ -929,11 +931,11 @@ function dropLastWhile(predicate, iterable) {
|
|
|
929
931
|
}
|
|
930
932
|
}
|
|
931
933
|
|
|
932
|
-
return isArray ? toReturn.reverse() : toReturn.reverse().join('');
|
|
934
|
+
return isArray$1 ? toReturn.reverse() : toReturn.reverse().join('');
|
|
933
935
|
}
|
|
934
936
|
|
|
935
937
|
function dropRepeats(list) {
|
|
936
|
-
if (!
|
|
938
|
+
if (!isArray(list)) {
|
|
937
939
|
throw new Error(`${list} is not a list`);
|
|
938
940
|
}
|
|
939
941
|
|
|
@@ -953,7 +955,7 @@ function dropRepeatsWith(predicate, list) {
|
|
|
953
955
|
return _iterable => dropRepeatsWith(predicate, _iterable);
|
|
954
956
|
}
|
|
955
957
|
|
|
956
|
-
if (!
|
|
958
|
+
if (!isArray(list)) {
|
|
957
959
|
throw new Error(`${list} is not a list`);
|
|
958
960
|
}
|
|
959
961
|
|
|
@@ -978,9 +980,9 @@ function dropWhile(predicate, iterable) {
|
|
|
978
980
|
return _iterable => dropWhile(predicate, _iterable);
|
|
979
981
|
}
|
|
980
982
|
|
|
981
|
-
const isArray =
|
|
983
|
+
const isArray$1 = isArray(iterable);
|
|
982
984
|
|
|
983
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
985
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
984
986
|
throw new Error('`iterable` is neither list nor a string');
|
|
985
987
|
}
|
|
986
988
|
|
|
@@ -997,7 +999,7 @@ function dropWhile(predicate, iterable) {
|
|
|
997
999
|
}
|
|
998
1000
|
}
|
|
999
1001
|
|
|
1000
|
-
return isArray ? holder : holder.join('');
|
|
1002
|
+
return isArray$1 ? holder : holder.join('');
|
|
1001
1003
|
}
|
|
1002
1004
|
|
|
1003
1005
|
function either(firstPredicate, secondPredicate) {
|
|
@@ -1015,7 +1017,7 @@ function endsWith(target, iterable) {
|
|
|
1015
1017
|
return iterable.endsWith(target);
|
|
1016
1018
|
}
|
|
1017
1019
|
|
|
1018
|
-
if (!
|
|
1020
|
+
if (!isArray(target)) return false;
|
|
1019
1021
|
const diff = iterable.length - target.length;
|
|
1020
1022
|
let correct = true;
|
|
1021
1023
|
const filtered = target.filter((x, index) => {
|
|
@@ -1129,7 +1131,7 @@ function filter(predicate, iterable) {
|
|
|
1129
1131
|
throw new Error('Incorrect iterable input');
|
|
1130
1132
|
}
|
|
1131
1133
|
|
|
1132
|
-
if (
|
|
1134
|
+
if (isArray(iterable)) return filterArray(predicate, iterable, false);
|
|
1133
1135
|
return filterObject(predicate, iterable);
|
|
1134
1136
|
}
|
|
1135
1137
|
|
|
@@ -1193,7 +1195,7 @@ function flatten(list, input) {
|
|
|
1193
1195
|
const willReturn = input === undefined ? [] : input;
|
|
1194
1196
|
|
|
1195
1197
|
for (let i = 0; i < list.length; i++) {
|
|
1196
|
-
if (
|
|
1198
|
+
if (isArray(list[i])) {
|
|
1197
1199
|
flatten(list[i], willReturn);
|
|
1198
1200
|
} else {
|
|
1199
1201
|
willReturn.push(list[i]);
|
|
@@ -1230,7 +1232,7 @@ function forEach(fn, list) {
|
|
|
1230
1232
|
return;
|
|
1231
1233
|
}
|
|
1232
1234
|
|
|
1233
|
-
if (
|
|
1235
|
+
if (isArray(list)) {
|
|
1234
1236
|
let index = 0;
|
|
1235
1237
|
const len = list.length;
|
|
1236
1238
|
|
|
@@ -1240,13 +1242,11 @@ function forEach(fn, list) {
|
|
|
1240
1242
|
}
|
|
1241
1243
|
} else {
|
|
1242
1244
|
let index = 0;
|
|
1243
|
-
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
const len = keys.length;
|
|
1245
|
+
const listKeys = keys$1(list);
|
|
1246
|
+
const len = listKeys.length;
|
|
1247
1247
|
|
|
1248
1248
|
while (index < len) {
|
|
1249
|
-
const key =
|
|
1249
|
+
const key = listKeys[index];
|
|
1250
1250
|
fn(list[key], key, list);
|
|
1251
1251
|
index++;
|
|
1252
1252
|
}
|
|
@@ -1280,7 +1280,7 @@ function groupBy(groupFn, list) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
|
|
1282
1282
|
function groupWith(compareFn, list) {
|
|
1283
|
-
if (!
|
|
1283
|
+
if (!isArray(list)) throw new TypeError('list.reduce is not a function');
|
|
1284
1284
|
const clone = cloneList(list);
|
|
1285
1285
|
if (list.length === 1) return [clone];
|
|
1286
1286
|
const toReturn = [];
|
|
@@ -1366,11 +1366,12 @@ function _objectIs(a, b) {
|
|
|
1366
1366
|
|
|
1367
1367
|
return a !== a && b !== b;
|
|
1368
1368
|
}
|
|
1369
|
-
|
|
1369
|
+
|
|
1370
|
+
const objectIs = Object.is || _objectIs;
|
|
1370
1371
|
|
|
1371
1372
|
function identical(a, b) {
|
|
1372
1373
|
if (arguments.length === 1) return _b => identical(a, _b);
|
|
1373
|
-
return
|
|
1374
|
+
return objectIs(a, b);
|
|
1374
1375
|
}
|
|
1375
1376
|
|
|
1376
1377
|
function identity(x) {
|
|
@@ -1535,7 +1536,7 @@ function lastIndexOf(valueToFind, list) {
|
|
|
1535
1536
|
}
|
|
1536
1537
|
|
|
1537
1538
|
function length(x) {
|
|
1538
|
-
if (
|
|
1539
|
+
if (isArray(x)) return x.length;
|
|
1539
1540
|
if (typeof x === 'string') return x.length;
|
|
1540
1541
|
return NaN;
|
|
1541
1542
|
}
|
|
@@ -1559,7 +1560,6 @@ function updateFn(index, newValue, list) {
|
|
|
1559
1560
|
if (index === -1) return clone.fill(newValue, index);
|
|
1560
1561
|
return clone.fill(newValue, index, index + 1);
|
|
1561
1562
|
}
|
|
1562
|
-
|
|
1563
1563
|
const update = curry(updateFn);
|
|
1564
1564
|
|
|
1565
1565
|
function lensIndex(index) {
|
|
@@ -1582,7 +1582,7 @@ function match(pattern, input) {
|
|
|
1582
1582
|
|
|
1583
1583
|
function mathMod(x, y) {
|
|
1584
1584
|
if (arguments.length === 1) return _y => mathMod(x, _y);
|
|
1585
|
-
if (!
|
|
1585
|
+
if (!isInteger(x) || !isInteger(y) || y < 1) return NaN;
|
|
1586
1586
|
return (x % y + y) % y;
|
|
1587
1587
|
}
|
|
1588
1588
|
|
|
@@ -1628,7 +1628,7 @@ function mergeDeepRight(target, source) {
|
|
|
1628
1628
|
return sourceHolder => mergeDeepRight(target, sourceHolder);
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
|
-
const willReturn =
|
|
1631
|
+
const willReturn = clone(target);
|
|
1632
1632
|
Object.keys(source).forEach(key => {
|
|
1633
1633
|
if (type(source[key]) === 'Object') {
|
|
1634
1634
|
if (type(target[key]) === 'Object') {
|
|
@@ -1722,6 +1722,25 @@ function _defineProperty(obj, key, value) {
|
|
|
1722
1722
|
return obj;
|
|
1723
1723
|
}
|
|
1724
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
|
+
|
|
1725
1744
|
function modifyPathFn(pathInput, fn, object) {
|
|
1726
1745
|
const path$1 = createPath(pathInput);
|
|
1727
1746
|
|
|
@@ -1878,15 +1897,7 @@ function partial(fn, ...args) {
|
|
|
1878
1897
|
}
|
|
1879
1898
|
|
|
1880
1899
|
function partialObject(fn, input) {
|
|
1881
|
-
return
|
|
1882
|
-
if (type(fn) === 'Async') {
|
|
1883
|
-
return new Promise((resolve, reject) => {
|
|
1884
|
-
fn(mergeDeepRight(rest, input)).then(resolve).catch(reject);
|
|
1885
|
-
});
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
return fn(mergeDeepRight(rest, input));
|
|
1889
|
-
};
|
|
1900
|
+
return nextInput => fn(mergeDeepRight(nextInput, input));
|
|
1890
1901
|
}
|
|
1891
1902
|
|
|
1892
1903
|
function partitionObject(predicate, iterable) {
|
|
@@ -1921,7 +1932,7 @@ function partition(predicate, iterable) {
|
|
|
1921
1932
|
return listHolder => partition(predicate, listHolder);
|
|
1922
1933
|
}
|
|
1923
1934
|
|
|
1924
|
-
if (!
|
|
1935
|
+
if (!isArray(iterable)) return partitionObject(predicate, iterable);
|
|
1925
1936
|
return partitionArray(predicate, iterable);
|
|
1926
1937
|
}
|
|
1927
1938
|
|
|
@@ -2041,7 +2052,7 @@ function props(propsToPick, obj) {
|
|
|
2041
2052
|
return _obj => props(propsToPick, _obj);
|
|
2042
2053
|
}
|
|
2043
2054
|
|
|
2044
|
-
if (!
|
|
2055
|
+
if (!isArray(propsToPick)) {
|
|
2045
2056
|
throw new Error('propsToPick is not a list');
|
|
2046
2057
|
}
|
|
2047
2058
|
|
|
@@ -2146,7 +2157,7 @@ function splitAt(index, input) {
|
|
|
2146
2157
|
}
|
|
2147
2158
|
|
|
2148
2159
|
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`);
|
|
2149
|
-
if (!
|
|
2160
|
+
if (!isArray(input) && typeof input !== 'string') return [[], []];
|
|
2150
2161
|
const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index);
|
|
2151
2162
|
return [take(correctIndex, input), drop(correctIndex, input)];
|
|
2152
2163
|
}
|
|
@@ -2202,7 +2213,7 @@ function startsWith(target, iterable) {
|
|
|
2202
2213
|
return iterable.startsWith(target);
|
|
2203
2214
|
}
|
|
2204
2215
|
|
|
2205
|
-
if (!
|
|
2216
|
+
if (!isArray(target)) return false;
|
|
2206
2217
|
let correct = true;
|
|
2207
2218
|
const filtered = target.filter((x, index) => {
|
|
2208
2219
|
if (!correct) return false;
|
|
@@ -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;
|