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.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function F() {
|
|
2
|
+
return false;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function T() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
function add(a, b) {
|
|
2
10
|
if (arguments.length === 1) return _b => add(a, _b);
|
|
3
11
|
return Number(a) + Number(b);
|
|
@@ -101,7 +109,9 @@ function apply(fn, args) {
|
|
|
101
109
|
return fn.apply(this, args);
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
const
|
|
112
|
+
const {
|
|
113
|
+
isArray
|
|
114
|
+
} = Array;
|
|
105
115
|
|
|
106
116
|
function __findHighestArity(spec, max = 0) {
|
|
107
117
|
for (const key in spec) {
|
|
@@ -141,13 +151,13 @@ function __applySpecWithArity(spec, arity, cache) {
|
|
|
141
151
|
if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a));
|
|
142
152
|
if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
|
|
143
153
|
|
|
144
|
-
if (
|
|
154
|
+
if (isArray(spec)) {
|
|
145
155
|
const ret = [];
|
|
146
156
|
let i = 0;
|
|
147
157
|
const l = spec.length;
|
|
148
158
|
|
|
149
159
|
for (; i < l; i++) {
|
|
150
|
-
if (typeof spec[i] === 'object' ||
|
|
160
|
+
if (typeof spec[i] === 'object' || isArray(spec[i])) {
|
|
151
161
|
ret[i] = __applySpecWithArity(spec[i], arity, cache);
|
|
152
162
|
}
|
|
153
163
|
|
|
@@ -200,10 +210,11 @@ const assoc = curry(assocFn);
|
|
|
200
210
|
function _isInteger(n) {
|
|
201
211
|
return n << 0 === n;
|
|
202
212
|
}
|
|
203
|
-
|
|
213
|
+
|
|
214
|
+
const isInteger = Number.isInteger || _isInteger;
|
|
204
215
|
|
|
205
216
|
function assocPathFn(path, newValue, input) {
|
|
206
|
-
const pathArrValue = typeof path === 'string' ? path.split('.').map(x =>
|
|
217
|
+
const pathArrValue = typeof path === 'string' ? path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) : path;
|
|
207
218
|
|
|
208
219
|
if (pathArrValue.length === 0) {
|
|
209
220
|
return newValue;
|
|
@@ -213,11 +224,11 @@ function assocPathFn(path, newValue, input) {
|
|
|
213
224
|
|
|
214
225
|
if (pathArrValue.length > 1) {
|
|
215
226
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
216
|
-
const
|
|
217
|
-
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue,
|
|
227
|
+
const nextInput = condition ? isInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
228
|
+
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
|
|
218
229
|
}
|
|
219
230
|
|
|
220
|
-
if (
|
|
231
|
+
if (isInteger(index) && isArray(input)) {
|
|
221
232
|
const arr = cloneList(input);
|
|
222
233
|
arr[index] = newValue;
|
|
223
234
|
return arr;
|
|
@@ -354,7 +365,7 @@ function clampFn(min, max, input) {
|
|
|
354
365
|
const clamp = curry(clampFn);
|
|
355
366
|
|
|
356
367
|
function clone(input) {
|
|
357
|
-
const out =
|
|
368
|
+
const out = isArray(input) ? Array(input.length) : {};
|
|
358
369
|
if (input && input.getTime) return new Date(input.getTime());
|
|
359
370
|
|
|
360
371
|
for (const key in input) {
|
|
@@ -369,8 +380,6 @@ function complement(fn) {
|
|
|
369
380
|
return (...input) => !fn(...input);
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
const _keys = Object.keys;
|
|
373
|
-
|
|
374
383
|
class ReduceStopper {
|
|
375
384
|
constructor(value) {
|
|
376
385
|
this.value = value;
|
|
@@ -379,7 +388,7 @@ class ReduceStopper {
|
|
|
379
388
|
}
|
|
380
389
|
|
|
381
390
|
function reduceFn(reducer, acc, list) {
|
|
382
|
-
if (!
|
|
391
|
+
if (!isArray(list)) {
|
|
383
392
|
throw new TypeError('reduce: list must be array or iterable');
|
|
384
393
|
}
|
|
385
394
|
|
|
@@ -502,6 +511,10 @@ function cond(conditions) {
|
|
|
502
511
|
};
|
|
503
512
|
}
|
|
504
513
|
|
|
514
|
+
const {
|
|
515
|
+
keys: keys$1
|
|
516
|
+
} = Object;
|
|
517
|
+
|
|
505
518
|
function mapArray(fn, list, isIndexed = false) {
|
|
506
519
|
let index = 0;
|
|
507
520
|
const willReturn = Array(list.length);
|
|
@@ -519,14 +532,12 @@ function mapObject(fn, obj) {
|
|
|
519
532
|
}
|
|
520
533
|
|
|
521
534
|
let index = 0;
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
const len = keys.length;
|
|
535
|
+
const objKeys = keys$1(obj);
|
|
536
|
+
const len = objKeys.length;
|
|
526
537
|
const willReturn = {};
|
|
527
538
|
|
|
528
539
|
while (index < len) {
|
|
529
|
-
const key =
|
|
540
|
+
const key = objKeys[index];
|
|
530
541
|
willReturn[key] = fn(obj[key], key, obj);
|
|
531
542
|
index++;
|
|
532
543
|
}
|
|
@@ -538,10 +549,10 @@ function map(fn, iterable) {
|
|
|
538
549
|
if (arguments.length === 1) return _iterable => map(fn, _iterable);
|
|
539
550
|
|
|
540
551
|
if (!iterable) {
|
|
541
|
-
throw new Error(
|
|
552
|
+
throw new Error(INCORRECT_ITERABLE_INPUT);
|
|
542
553
|
}
|
|
543
554
|
|
|
544
|
-
if (
|
|
555
|
+
if (isArray(iterable)) return mapArray(fn, iterable);
|
|
545
556
|
return mapObject(fn, iterable);
|
|
546
557
|
}
|
|
547
558
|
|
|
@@ -563,7 +574,7 @@ function count(predicate, list) {
|
|
|
563
574
|
return _list => count(predicate, _list);
|
|
564
575
|
}
|
|
565
576
|
|
|
566
|
-
if (!
|
|
577
|
+
if (!isArray(list)) return 0;
|
|
567
578
|
return list.filter(x => predicate(x)).length;
|
|
568
579
|
}
|
|
569
580
|
|
|
@@ -613,7 +624,7 @@ function type(input) {
|
|
|
613
624
|
}
|
|
614
625
|
|
|
615
626
|
function _lastIndexOf(valueToFind, list) {
|
|
616
|
-
if (!
|
|
627
|
+
if (!isArray(list)) {
|
|
617
628
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
618
629
|
}
|
|
619
630
|
|
|
@@ -634,7 +645,7 @@ function _lastIndexOf(valueToFind, list) {
|
|
|
634
645
|
return foundIndex;
|
|
635
646
|
}
|
|
636
647
|
function _indexOf(valueToFind, list) {
|
|
637
|
-
if (!
|
|
648
|
+
if (!isArray(list)) {
|
|
638
649
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
639
650
|
}
|
|
640
651
|
|
|
@@ -795,7 +806,7 @@ function includes(valueToFind, iterable) {
|
|
|
795
806
|
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
|
|
796
807
|
}
|
|
797
808
|
|
|
798
|
-
if (!
|
|
809
|
+
if (!isArray(iterable)) return false;
|
|
799
810
|
return _indexOf(valueToFind, iterable) > -1;
|
|
800
811
|
}
|
|
801
812
|
|
|
@@ -891,14 +902,13 @@ function dropLastWhile(predicate, iterable) {
|
|
|
891
902
|
}
|
|
892
903
|
|
|
893
904
|
if (iterable.length === 0) return iterable;
|
|
894
|
-
|
|
895
|
-
const isArray = _isArray(iterable);
|
|
905
|
+
const isArray$1 = isArray(iterable);
|
|
896
906
|
|
|
897
907
|
if (typeof predicate !== 'function') {
|
|
898
908
|
throw new Error(`'predicate' is from wrong type ${typeof predicate}`);
|
|
899
909
|
}
|
|
900
910
|
|
|
901
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
911
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
902
912
|
throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
|
|
903
913
|
}
|
|
904
914
|
|
|
@@ -917,11 +927,11 @@ function dropLastWhile(predicate, iterable) {
|
|
|
917
927
|
}
|
|
918
928
|
}
|
|
919
929
|
|
|
920
|
-
return isArray ? toReturn.reverse() : toReturn.reverse().join('');
|
|
930
|
+
return isArray$1 ? toReturn.reverse() : toReturn.reverse().join('');
|
|
921
931
|
}
|
|
922
932
|
|
|
923
933
|
function dropRepeats(list) {
|
|
924
|
-
if (!
|
|
934
|
+
if (!isArray(list)) {
|
|
925
935
|
throw new Error(`${list} is not a list`);
|
|
926
936
|
}
|
|
927
937
|
|
|
@@ -941,7 +951,7 @@ function dropRepeatsWith(predicate, list) {
|
|
|
941
951
|
return _iterable => dropRepeatsWith(predicate, _iterable);
|
|
942
952
|
}
|
|
943
953
|
|
|
944
|
-
if (!
|
|
954
|
+
if (!isArray(list)) {
|
|
945
955
|
throw new Error(`${list} is not a list`);
|
|
946
956
|
}
|
|
947
957
|
|
|
@@ -966,9 +976,9 @@ function dropWhile(predicate, iterable) {
|
|
|
966
976
|
return _iterable => dropWhile(predicate, _iterable);
|
|
967
977
|
}
|
|
968
978
|
|
|
969
|
-
const isArray =
|
|
979
|
+
const isArray$1 = isArray(iterable);
|
|
970
980
|
|
|
971
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
981
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
972
982
|
throw new Error('`iterable` is neither list nor a string');
|
|
973
983
|
}
|
|
974
984
|
|
|
@@ -985,7 +995,7 @@ function dropWhile(predicate, iterable) {
|
|
|
985
995
|
}
|
|
986
996
|
}
|
|
987
997
|
|
|
988
|
-
return isArray ? holder : holder.join('');
|
|
998
|
+
return isArray$1 ? holder : holder.join('');
|
|
989
999
|
}
|
|
990
1000
|
|
|
991
1001
|
function either(firstPredicate, secondPredicate) {
|
|
@@ -1003,7 +1013,7 @@ function endsWith(target, iterable) {
|
|
|
1003
1013
|
return iterable.endsWith(target);
|
|
1004
1014
|
}
|
|
1005
1015
|
|
|
1006
|
-
if (!
|
|
1016
|
+
if (!isArray(target)) return false;
|
|
1007
1017
|
const diff = iterable.length - target.length;
|
|
1008
1018
|
let correct = true;
|
|
1009
1019
|
const filtered = target.filter((x, index) => {
|
|
@@ -1082,10 +1092,6 @@ function evolve(rules, iterable) {
|
|
|
1082
1092
|
return evolveArray(rules, iterable);
|
|
1083
1093
|
}
|
|
1084
1094
|
|
|
1085
|
-
function F() {
|
|
1086
|
-
return false;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
1095
|
function filterObject(predicate, obj) {
|
|
1090
1096
|
const willReturn = {};
|
|
1091
1097
|
|
|
@@ -1121,7 +1127,7 @@ function filter(predicate, iterable) {
|
|
|
1121
1127
|
throw new Error('Incorrect iterable input');
|
|
1122
1128
|
}
|
|
1123
1129
|
|
|
1124
|
-
if (
|
|
1130
|
+
if (isArray(iterable)) return filterArray(predicate, iterable, false);
|
|
1125
1131
|
return filterObject(predicate, iterable);
|
|
1126
1132
|
}
|
|
1127
1133
|
|
|
@@ -1185,7 +1191,7 @@ function flatten(list, input) {
|
|
|
1185
1191
|
const willReturn = input === undefined ? [] : input;
|
|
1186
1192
|
|
|
1187
1193
|
for (let i = 0; i < list.length; i++) {
|
|
1188
|
-
if (
|
|
1194
|
+
if (isArray(list[i])) {
|
|
1189
1195
|
flatten(list[i], willReturn);
|
|
1190
1196
|
} else {
|
|
1191
1197
|
willReturn.push(list[i]);
|
|
@@ -1222,7 +1228,7 @@ function forEach(fn, list) {
|
|
|
1222
1228
|
return;
|
|
1223
1229
|
}
|
|
1224
1230
|
|
|
1225
|
-
if (
|
|
1231
|
+
if (isArray(list)) {
|
|
1226
1232
|
let index = 0;
|
|
1227
1233
|
const len = list.length;
|
|
1228
1234
|
|
|
@@ -1232,13 +1238,11 @@ function forEach(fn, list) {
|
|
|
1232
1238
|
}
|
|
1233
1239
|
} else {
|
|
1234
1240
|
let index = 0;
|
|
1235
|
-
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
const len = keys.length;
|
|
1241
|
+
const listKeys = keys$1(list);
|
|
1242
|
+
const len = listKeys.length;
|
|
1239
1243
|
|
|
1240
1244
|
while (index < len) {
|
|
1241
|
-
const key =
|
|
1245
|
+
const key = listKeys[index];
|
|
1242
1246
|
fn(list[key], key, list);
|
|
1243
1247
|
index++;
|
|
1244
1248
|
}
|
|
@@ -1272,7 +1276,7 @@ function groupBy(groupFn, list) {
|
|
|
1272
1276
|
}
|
|
1273
1277
|
|
|
1274
1278
|
function groupWith(compareFn, list) {
|
|
1275
|
-
if (!
|
|
1279
|
+
if (!isArray(list)) throw new TypeError('list.reduce is not a function');
|
|
1276
1280
|
const clone = cloneList(list);
|
|
1277
1281
|
if (list.length === 1) return [clone];
|
|
1278
1282
|
const toReturn = [];
|
|
@@ -1358,11 +1362,12 @@ function _objectIs(a, b) {
|
|
|
1358
1362
|
|
|
1359
1363
|
return a !== a && b !== b;
|
|
1360
1364
|
}
|
|
1361
|
-
|
|
1365
|
+
|
|
1366
|
+
const objectIs = Object.is || _objectIs;
|
|
1362
1367
|
|
|
1363
1368
|
function identical(a, b) {
|
|
1364
1369
|
if (arguments.length === 1) return _b => identical(a, _b);
|
|
1365
|
-
return
|
|
1370
|
+
return objectIs(a, b);
|
|
1366
1371
|
}
|
|
1367
1372
|
|
|
1368
1373
|
function identity(x) {
|
|
@@ -1527,7 +1532,7 @@ function lastIndexOf(valueToFind, list) {
|
|
|
1527
1532
|
}
|
|
1528
1533
|
|
|
1529
1534
|
function length(x) {
|
|
1530
|
-
if (
|
|
1535
|
+
if (isArray(x)) return x.length;
|
|
1531
1536
|
if (typeof x === 'string') return x.length;
|
|
1532
1537
|
return NaN;
|
|
1533
1538
|
}
|
|
@@ -1551,7 +1556,6 @@ function updateFn(index, newValue, list) {
|
|
|
1551
1556
|
if (index === -1) return clone.fill(newValue, index);
|
|
1552
1557
|
return clone.fill(newValue, index, index + 1);
|
|
1553
1558
|
}
|
|
1554
|
-
|
|
1555
1559
|
const update = curry(updateFn);
|
|
1556
1560
|
|
|
1557
1561
|
function lensIndex(index) {
|
|
@@ -1574,7 +1578,7 @@ function match(pattern, input) {
|
|
|
1574
1578
|
|
|
1575
1579
|
function mathMod(x, y) {
|
|
1576
1580
|
if (arguments.length === 1) return _y => mathMod(x, _y);
|
|
1577
|
-
if (!
|
|
1581
|
+
if (!isInteger(x) || !isInteger(y) || y < 1) return NaN;
|
|
1578
1582
|
return (x % y + y) % y;
|
|
1579
1583
|
}
|
|
1580
1584
|
|
|
@@ -1620,7 +1624,7 @@ function mergeDeepRight(target, source) {
|
|
|
1620
1624
|
return sourceHolder => mergeDeepRight(target, sourceHolder);
|
|
1621
1625
|
}
|
|
1622
1626
|
|
|
1623
|
-
const willReturn =
|
|
1627
|
+
const willReturn = clone(target);
|
|
1624
1628
|
Object.keys(source).forEach(key => {
|
|
1625
1629
|
if (type(source[key]) === 'Object') {
|
|
1626
1630
|
if (type(target[key]) === 'Object') {
|
|
@@ -1714,6 +1718,25 @@ function _defineProperty(obj, key, value) {
|
|
|
1714
1718
|
return obj;
|
|
1715
1719
|
}
|
|
1716
1720
|
|
|
1721
|
+
function isIterable(input) {
|
|
1722
|
+
return Array.isArray(input) || type(input) === 'Object';
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
function modifyFn(property, fn, iterable) {
|
|
1726
|
+
if (!isIterable(iterable)) return iterable;
|
|
1727
|
+
if (iterable[property] === undefined) return iterable;
|
|
1728
|
+
|
|
1729
|
+
if (isArray(iterable)) {
|
|
1730
|
+
return updateFn(property, fn(iterable[property]), iterable);
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
return _objectSpread2(_objectSpread2({}, iterable), {}, {
|
|
1734
|
+
[property]: fn(iterable[property])
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
const modify = curry(modifyFn);
|
|
1739
|
+
|
|
1717
1740
|
function modifyPathFn(pathInput, fn, object) {
|
|
1718
1741
|
const path$1 = createPath(pathInput);
|
|
1719
1742
|
|
|
@@ -1870,15 +1893,7 @@ function partial(fn, ...args) {
|
|
|
1870
1893
|
}
|
|
1871
1894
|
|
|
1872
1895
|
function partialObject(fn, input) {
|
|
1873
|
-
return
|
|
1874
|
-
if (type(fn) === 'Async') {
|
|
1875
|
-
return new Promise((resolve, reject) => {
|
|
1876
|
-
fn(mergeDeepRight(rest, input)).then(resolve).catch(reject);
|
|
1877
|
-
});
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
return fn(mergeDeepRight(rest, input));
|
|
1881
|
-
};
|
|
1896
|
+
return nextInput => fn(mergeDeepRight(nextInput, input));
|
|
1882
1897
|
}
|
|
1883
1898
|
|
|
1884
1899
|
function partitionObject(predicate, iterable) {
|
|
@@ -1913,7 +1928,7 @@ function partition(predicate, iterable) {
|
|
|
1913
1928
|
return listHolder => partition(predicate, listHolder);
|
|
1914
1929
|
}
|
|
1915
1930
|
|
|
1916
|
-
if (!
|
|
1931
|
+
if (!isArray(iterable)) return partitionObject(predicate, iterable);
|
|
1917
1932
|
return partitionArray(predicate, iterable);
|
|
1918
1933
|
}
|
|
1919
1934
|
|
|
@@ -2022,24 +2037,24 @@ function propOrFn(defaultValue, property, obj) {
|
|
|
2022
2037
|
|
|
2023
2038
|
const propOr = curry(propOrFn);
|
|
2024
2039
|
|
|
2040
|
+
function propSatisfiesFn(predicate, property, obj) {
|
|
2041
|
+
return predicate(prop(property, obj));
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
const propSatisfies = curry(propSatisfiesFn);
|
|
2045
|
+
|
|
2025
2046
|
function props(propsToPick, obj) {
|
|
2026
2047
|
if (arguments.length === 1) {
|
|
2027
2048
|
return _obj => props(propsToPick, _obj);
|
|
2028
2049
|
}
|
|
2029
2050
|
|
|
2030
|
-
if (!
|
|
2051
|
+
if (!isArray(propsToPick)) {
|
|
2031
2052
|
throw new Error('propsToPick is not a list');
|
|
2032
2053
|
}
|
|
2033
2054
|
|
|
2034
2055
|
return mapArray(prop => obj[prop], propsToPick);
|
|
2035
2056
|
}
|
|
2036
2057
|
|
|
2037
|
-
function propSatisfiesFn(predicate, property, obj) {
|
|
2038
|
-
return predicate(prop(property, obj));
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
const propSatisfies = curry(propSatisfiesFn);
|
|
2042
|
-
|
|
2043
2058
|
function range(start, end) {
|
|
2044
2059
|
if (arguments.length === 1) return _end => range(start, _end);
|
|
2045
2060
|
|
|
@@ -2138,7 +2153,7 @@ function splitAt(index, input) {
|
|
|
2138
2153
|
}
|
|
2139
2154
|
|
|
2140
2155
|
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`);
|
|
2141
|
-
if (!
|
|
2156
|
+
if (!isArray(input) && typeof input !== 'string') return [[], []];
|
|
2142
2157
|
const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index);
|
|
2143
2158
|
return [take(correctIndex, input), drop(correctIndex, input)];
|
|
2144
2159
|
}
|
|
@@ -2194,7 +2209,7 @@ function startsWith(target, iterable) {
|
|
|
2194
2209
|
return iterable.startsWith(target);
|
|
2195
2210
|
}
|
|
2196
2211
|
|
|
2197
|
-
if (!
|
|
2212
|
+
if (!isArray(target)) return false;
|
|
2198
2213
|
let correct = true;
|
|
2199
2214
|
const filtered = target.filter((x, index) => {
|
|
2200
2215
|
if (!correct) return false;
|
|
@@ -2218,10 +2233,6 @@ function symmetricDifference(x, y) {
|
|
|
2218
2233
|
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));
|
|
2219
2234
|
}
|
|
2220
2235
|
|
|
2221
|
-
function T() {
|
|
2222
|
-
return true;
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
2236
|
function tail(listOrString) {
|
|
2226
2237
|
return drop(1, listOrString);
|
|
2227
2238
|
}
|
|
@@ -2256,7 +2267,7 @@ function takeLastWhile(predicate, input) {
|
|
|
2256
2267
|
}
|
|
2257
2268
|
}
|
|
2258
2269
|
|
|
2259
|
-
return
|
|
2270
|
+
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');
|
|
2260
2271
|
}
|
|
2261
2272
|
|
|
2262
2273
|
function takeWhile(predicate, iterable) {
|
|
@@ -2264,9 +2275,9 @@ function takeWhile(predicate, iterable) {
|
|
|
2264
2275
|
return _iterable => takeWhile(predicate, _iterable);
|
|
2265
2276
|
}
|
|
2266
2277
|
|
|
2267
|
-
const isArray =
|
|
2278
|
+
const isArray$1 = isArray(iterable);
|
|
2268
2279
|
|
|
2269
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
2280
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
2270
2281
|
throw new Error('`iterable` is neither list nor a string');
|
|
2271
2282
|
}
|
|
2272
2283
|
|
|
@@ -2281,7 +2292,7 @@ function takeWhile(predicate, iterable) {
|
|
|
2281
2292
|
holder.push(iterable[counter]);
|
|
2282
2293
|
}
|
|
2283
2294
|
}
|
|
2284
|
-
return isArray ? holder : holder.join('');
|
|
2295
|
+
return isArray$1 ? holder : holder.join('');
|
|
2285
2296
|
}
|
|
2286
2297
|
|
|
2287
2298
|
function tap(fn, x) {
|
|
@@ -2303,7 +2314,7 @@ function test(pattern, str) {
|
|
|
2303
2314
|
function times(fn, howMany) {
|
|
2304
2315
|
if (arguments.length === 1) return _howMany => times(fn, _howMany);
|
|
2305
2316
|
|
|
2306
|
-
if (!
|
|
2317
|
+
if (!isInteger(howMany) || howMany < 0) {
|
|
2307
2318
|
throw new RangeError('n must be an integer');
|
|
2308
2319
|
}
|
|
2309
2320
|
|
|
@@ -2328,7 +2339,7 @@ function toUpper(str) {
|
|
|
2328
2339
|
|
|
2329
2340
|
function transpose(array) {
|
|
2330
2341
|
return array.reduce((acc, el) => {
|
|
2331
|
-
el.forEach((nestedEl, i) =>
|
|
2342
|
+
el.forEach((nestedEl, i) => isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl]));
|
|
2332
2343
|
return acc;
|
|
2333
2344
|
}, []);
|
|
2334
2345
|
}
|
|
@@ -2426,7 +2437,7 @@ function unwind(property, obj) {
|
|
|
2426
2437
|
return _obj => unwind(property, _obj);
|
|
2427
2438
|
}
|
|
2428
2439
|
|
|
2429
|
-
if (!
|
|
2440
|
+
if (!isArray(obj[property])) return [obj];
|
|
2430
2441
|
return mapArray(x => _objectSpread2(_objectSpread2({}, obj), {}, {
|
|
2431
2442
|
[property]: x
|
|
2432
2443
|
}), obj[property]);
|
|
@@ -2462,6 +2473,7 @@ function where(conditions, input) {
|
|
|
2462
2473
|
let flag = true;
|
|
2463
2474
|
|
|
2464
2475
|
for (const prop in conditions) {
|
|
2476
|
+
if (!flag) continue;
|
|
2465
2477
|
const result = conditions[prop](input[prop]);
|
|
2466
2478
|
|
|
2467
2479
|
if (flag && result === false) {
|
|
@@ -2534,4 +2546,4 @@ function zipWithFn(fn, x, y) {
|
|
|
2534
2546
|
|
|
2535
2547
|
const zipWith = curry(zipWithFn);
|
|
2536
2548
|
|
|
2537
|
-
export { F, T, __findHighestArity, _arity, _indexOf, _lastIndexOf, _pipe, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, count, countBy, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, dropLastWhile, dropRepeats, dropRepeatsWith, dropWhile, either, endsWith, eqProps, equals, evolve, evolveArray, evolveObject, filter, filterArray, filterObject, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, juxt, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, mergeRight as merge, mergeAll, mergeDeepRight, mergeLeft, mergeRight, mergeWith, min, minBy, minByFn, modifyPath, modifyPathFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, on, once, or, over, partial, partialObject, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, propSatisfies, props, range, reduce, reduceFn, reduceStopper, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitAt, splitEvery, splitWhen, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, unapply, union, uniq, uniqBy, uniqWith, unless, unwind, update, values, view, when, where, whereAny, whereEq, without, xor, zip, zipObj, zipWith };
|
|
2549
|
+
export { F, T, __findHighestArity, _arity, _indexOf, _lastIndexOf, _pipe, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, count, countBy, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, dropLastWhile, dropRepeats, dropRepeatsWith, dropWhile, either, endsWith, eqProps, equals, evolve, evolveArray, evolveObject, filter, filterArray, filterObject, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, juxt, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, mergeRight as merge, mergeAll, mergeDeepRight, mergeLeft, mergeRight, mergeWith, min, minBy, minByFn, modify, modifyPath, modifyPathFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, on, once, or, over, partial, partialObject, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, propSatisfies, props, range, reduce, reduceFn, reduceStopper, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitAt, splitEvery, splitWhen, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, unapply, union, uniq, uniqBy, uniqWith, unless, unwind, update, updateFn, values, view, when, where, whereAny, whereEq, without, xor, zip, zipObj, zipWith };
|