rambda 6.9.0 → 7.0.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 +69 -1
- package/README.md +3811 -3385
- package/dist/rambda.esm.js +300 -207
- package/dist/rambda.js +303 -206
- package/dist/rambda.mjs +300 -207
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +192 -271
- package/index.d.ts +192 -271
- package/package.json +111 -98
- package/src/F.js +1 -1
- package/src/T.js +1 -1
- package/src/_internals/_isInteger.js +1 -1
- package/src/_internals/_objectIs.js +2 -2
- package/src/_internals/baseSlice.js +6 -8
- package/src/_internals/cloneList.js +3 -0
- package/src/_internals/isFalsy.js +5 -5
- package/src/_internals/isObject.js +3 -3
- package/src/_internals/isTruthy.js +5 -5
- package/src/_internals/set.js +4 -4
- package/src/add.js +1 -1
- package/src/adjust.js +5 -6
- package/src/all.js +3 -3
- package/src/allPass.js +4 -4
- package/src/always.js +1 -1
- package/src/and.js +1 -1
- package/src/any.js +3 -3
- package/src/anyPass.js +4 -4
- package/src/append.js +4 -2
- package/src/apply.js +7 -0
- package/src/applySpec.js +33 -59
- package/src/assoc.js +3 -7
- package/src/assocPath.js +22 -25
- package/src/bind.js +9 -0
- package/src/both.js +1 -1
- package/src/chain.js +2 -2
- package/src/clamp.js +6 -6
- package/src/clone.js +10 -10
- package/src/complement.js +1 -1
- package/src/compose.js +6 -6
- package/src/concat.js +2 -2
- package/src/cond.js +3 -3
- package/src/converge.js +11 -11
- package/src/curry.js +2 -2
- package/src/curryN.js +61 -81
- package/src/defaultTo.js +5 -8
- package/src/difference.js +3 -3
- package/src/dissoc.js +4 -4
- package/src/divide.js +1 -1
- package/src/drop.js +1 -1
- package/src/dropLast.js +5 -5
- package/src/dropLastWhile.js +12 -12
- package/src/dropRepeats.js +6 -6
- package/src/dropRepeatsWith.js +7 -7
- package/src/dropWhile.js +9 -9
- package/src/either.js +2 -2
- package/src/endsWith.js +20 -3
- package/src/eqProps.js +5 -10
- package/src/equals.js +119 -38
- package/src/evolve.js +23 -21
- package/src/filter.js +17 -17
- package/src/find.js +4 -4
- package/src/findIndex.js +3 -3
- package/src/findLast.js +4 -4
- package/src/findLastIndex.js +3 -3
- package/src/flatten.js +6 -6
- package/src/flip.js +11 -15
- package/src/forEach.js +10 -12
- package/src/fromPairs.js +2 -2
- package/src/groupBy.js +6 -6
- package/src/groupWith.js +11 -12
- package/src/hasPath.js +5 -5
- package/src/head.js +3 -3
- package/src/identical.js +1 -1
- package/src/identity.js +2 -2
- package/src/ifElse.js +3 -5
- package/src/includes.js +11 -10
- package/src/indexBy.js +11 -11
- package/src/indexOf.js +3 -25
- package/src/init.js +2 -4
- package/src/intersection.js +3 -3
- package/src/intersperse.js +5 -5
- package/src/is.js +2 -2
- package/src/isEmpty.js +5 -5
- package/src/isFunction.js +3 -3
- package/src/isNil.js +1 -1
- package/src/isPromise.js +3 -3
- package/src/join.js +1 -1
- package/src/keys.js +1 -1
- package/src/last.js +4 -4
- package/src/lastIndexOf.js +5 -11
- package/src/length.js +6 -5
- package/src/lens.js +3 -3
- package/src/lensIndex.js +4 -4
- package/src/lensProp.js +4 -4
- package/src/map.js +17 -18
- package/src/match.js +1 -1
- package/src/mathMod.js +2 -2
- package/src/max.js +1 -1
- package/src/maxBy.js +2 -4
- package/src/maybe.js +2 -4
- package/src/mean.js +2 -2
- package/src/median.js +12 -10
- package/src/merge.js +2 -4
- package/src/mergeAll.js +3 -3
- package/src/mergeDeepRight.js +8 -8
- package/src/mergeLeft.js +2 -2
- package/src/min.js +1 -1
- package/src/minBy.js +2 -4
- package/src/modulo.js +1 -1
- package/src/move.js +7 -8
- package/src/multiply.js +1 -1
- package/src/negate.js +1 -1
- package/src/none.js +3 -3
- package/src/not.js +1 -1
- package/src/nth.js +4 -4
- package/src/objOf.js +3 -3
- package/src/of.js +2 -2
- package/src/omit.js +5 -5
- package/src/once.js +6 -6
- package/src/or.js +1 -1
- package/src/over.js +3 -5
- package/src/partial.js +3 -3
- package/src/partition.js +17 -15
- package/src/path.js +6 -6
- package/src/pathEq.js +4 -6
- package/src/pathOr.js +5 -7
- package/src/paths.js +3 -3
- package/src/pick.js +5 -5
- package/src/pickAll.js +6 -6
- package/src/pipe.js +3 -3
- package/src/pluck.js +4 -4
- package/src/prepend.js +3 -3
- package/src/product.js +2 -2
- package/src/prop.js +2 -2
- package/src/propEq.js +3 -5
- package/src/propIs.js +4 -6
- package/src/propOr.js +4 -6
- package/src/props.js +6 -6
- package/src/range.js +4 -4
- package/src/reduce.js +7 -11
- package/src/reject.js +2 -2
- package/src/repeat.js +2 -2
- package/src/replace.js +2 -4
- package/src/reverse.js +3 -4
- package/src/set.js +5 -9
- package/src/slice.js +2 -4
- package/src/sort.js +4 -4
- package/src/sortBy.js +4 -2
- package/src/split.js +1 -1
- package/src/splitAt.js +9 -9
- package/src/splitEvery.js +8 -6
- package/src/splitWhen.js +10 -10
- package/src/startsWith.js +20 -3
- package/src/subtract.js +1 -1
- package/src/sum.js +1 -1
- package/src/symmetricDifference.js +9 -7
- package/src/tail.js +2 -2
- package/src/take.js +2 -4
- package/src/takeLast.js +2 -4
- package/src/takeLastWhile.js +7 -7
- package/src/takeWhile.js +8 -8
- package/src/tap.js +1 -1
- package/src/test.js +5 -3
- package/src/times.js +4 -4
- package/src/toLower.js +1 -1
- package/src/toPairs.js +1 -1
- package/src/toString.js +1 -1
- package/src/toUpper.js +1 -1
- package/src/transpose.js +4 -3
- package/src/trim.js +1 -1
- package/src/tryCatch.js +5 -5
- package/src/type.js +7 -29
- package/src/unapply.js +5 -0
- package/src/union.js +4 -3
- package/src/uniq.js +2 -2
- package/src/uniqWith.js +18 -7
- package/src/unless.js +3 -3
- package/src/update.js +6 -8
- package/src/values.js +2 -2
- package/src/view.js +2 -2
- package/src/when.js +2 -4
- package/src/where.js +5 -5
- package/src/whereEq.js +9 -7
- package/src/without.js +1 -1
- package/src/xor.js +2 -2
- package/src/zip.js +3 -3
- package/src/zipObj.js +4 -6
- package/src/zipWith.js +6 -7
package/dist/rambda.esm.js
CHANGED
|
@@ -15,10 +15,14 @@ function curry(fn, args = []) {
|
|
|
15
15
|
return (..._args) => (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([...args, ..._args]);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
const cloneList = list => {
|
|
19
|
+
return Array.prototype.slice.call(list);
|
|
20
|
+
};
|
|
21
|
+
|
|
18
22
|
function adjustFn(index, replaceFn, list) {
|
|
19
23
|
const actualIndex = index < 0 ? list.length + index : index;
|
|
20
24
|
if (index >= list.length || actualIndex < 0) return list;
|
|
21
|
-
const clone = list
|
|
25
|
+
const clone = cloneList(list);
|
|
22
26
|
clone[actualIndex] = replaceFn(clone[actualIndex]);
|
|
23
27
|
return clone;
|
|
24
28
|
}
|
|
@@ -36,11 +40,11 @@ function all(predicate, list) {
|
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
function allPass(predicates) {
|
|
39
|
-
return input => {
|
|
43
|
+
return (...input) => {
|
|
40
44
|
let counter = 0;
|
|
41
45
|
|
|
42
46
|
while (counter < predicates.length) {
|
|
43
|
-
if (!predicates[counter](input)) {
|
|
47
|
+
if (!predicates[counter](...input)) {
|
|
44
48
|
return false;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -76,11 +80,11 @@ function any(predicate, list) {
|
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
function anyPass(predicates) {
|
|
79
|
-
return input => {
|
|
83
|
+
return (...input) => {
|
|
80
84
|
let counter = 0;
|
|
81
85
|
|
|
82
86
|
while (counter < predicates.length) {
|
|
83
|
-
if (predicates[counter](input)) {
|
|
87
|
+
if (predicates[counter](...input)) {
|
|
84
88
|
return true;
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -94,11 +98,19 @@ function anyPass(predicates) {
|
|
|
94
98
|
function append(x, input) {
|
|
95
99
|
if (arguments.length === 1) return _input => append(x, _input);
|
|
96
100
|
if (typeof input === 'string') return input.split('').concat(x);
|
|
97
|
-
const clone = input
|
|
101
|
+
const clone = cloneList(input);
|
|
98
102
|
clone.push(x);
|
|
99
103
|
return clone;
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
function apply(fn, args) {
|
|
107
|
+
if (arguments.length === 1) {
|
|
108
|
+
return _args => apply(fn, _args);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return fn.apply(this, args);
|
|
112
|
+
}
|
|
113
|
+
|
|
102
114
|
const _isArray = Array.isArray;
|
|
103
115
|
|
|
104
116
|
function __findHighestArity(spec, max = 0) {
|
|
@@ -216,7 +228,7 @@ function assocPathFn(path, newValue, input) {
|
|
|
216
228
|
}
|
|
217
229
|
|
|
218
230
|
if (_isInteger(index) && _isArray(input)) {
|
|
219
|
-
const arr = input
|
|
231
|
+
const arr = cloneList(input);
|
|
220
232
|
arr[index] = newValue;
|
|
221
233
|
return arr;
|
|
222
234
|
}
|
|
@@ -226,87 +238,6 @@ function assocPathFn(path, newValue, input) {
|
|
|
226
238
|
|
|
227
239
|
const assocPath = curry(assocPathFn);
|
|
228
240
|
|
|
229
|
-
function both(f, g) {
|
|
230
|
-
if (arguments.length === 1) return _g => both(f, _g);
|
|
231
|
-
return (...input) => f(...input) && g(...input);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function chain(fn, list) {
|
|
235
|
-
if (arguments.length === 1) {
|
|
236
|
-
return _list => chain(fn, _list);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return [].concat(...list.map(fn));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function clampFn(min, max, input) {
|
|
243
|
-
if (min > max) {
|
|
244
|
-
throw new Error('min must not be greater than max in clamp(min, max, value)');
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (input >= min && input <= max) return input;
|
|
248
|
-
if (input > max) return max;
|
|
249
|
-
if (input < min) return min;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const clamp = curry(clampFn);
|
|
253
|
-
|
|
254
|
-
function clone(input) {
|
|
255
|
-
const out = _isArray(input) ? Array(input.length) : {};
|
|
256
|
-
if (input && input.getTime) return new Date(input.getTime());
|
|
257
|
-
|
|
258
|
-
for (const key in input) {
|
|
259
|
-
const v = input[key];
|
|
260
|
-
out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return out;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function complement(fn) {
|
|
267
|
-
return (...input) => !fn(...input);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function compose(...fns) {
|
|
271
|
-
if (fns.length === 0) {
|
|
272
|
-
throw new Error('compose requires at least one argument');
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return (...args) => {
|
|
276
|
-
const list = fns.slice();
|
|
277
|
-
|
|
278
|
-
if (list.length > 0) {
|
|
279
|
-
const fn = list.pop();
|
|
280
|
-
let result = fn(...args);
|
|
281
|
-
|
|
282
|
-
while (list.length > 0) {
|
|
283
|
-
result = list.pop()(result);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return result;
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function concat(x, y) {
|
|
292
|
-
if (arguments.length === 1) return _y => concat(x, _y);
|
|
293
|
-
return typeof x === 'string' ? `${x}${y}` : [...x, ...y];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function cond(conditions) {
|
|
297
|
-
return input => {
|
|
298
|
-
let done = false;
|
|
299
|
-
let toReturn;
|
|
300
|
-
conditions.forEach(([predicate, resultClosure]) => {
|
|
301
|
-
if (!done && predicate(input)) {
|
|
302
|
-
done = true;
|
|
303
|
-
toReturn = resultClosure(input);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
return toReturn;
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
241
|
function _curryN(n, cache, fn) {
|
|
311
242
|
return function () {
|
|
312
243
|
let ci = 0;
|
|
@@ -399,6 +330,95 @@ function curryN(n, fn) {
|
|
|
399
330
|
return _arity(n, _curryN(n, [], fn));
|
|
400
331
|
}
|
|
401
332
|
|
|
333
|
+
function bind(fn, thisObj) {
|
|
334
|
+
if (arguments.length === 1) {
|
|
335
|
+
return _thisObj => bind(fn, _thisObj);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return curryN(fn.length, (...args) => fn.apply(thisObj, args));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function both(f, g) {
|
|
342
|
+
if (arguments.length === 1) return _g => both(f, _g);
|
|
343
|
+
return (...input) => f(...input) && g(...input);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function chain(fn, list) {
|
|
347
|
+
if (arguments.length === 1) {
|
|
348
|
+
return _list => chain(fn, _list);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return [].concat(...list.map(fn));
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function clampFn(min, max, input) {
|
|
355
|
+
if (min > max) {
|
|
356
|
+
throw new Error('min must not be greater than max in clamp(min, max, value)');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (input >= min && input <= max) return input;
|
|
360
|
+
if (input > max) return max;
|
|
361
|
+
if (input < min) return min;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const clamp = curry(clampFn);
|
|
365
|
+
|
|
366
|
+
function clone(input) {
|
|
367
|
+
const out = _isArray(input) ? Array(input.length) : {};
|
|
368
|
+
if (input && input.getTime) return new Date(input.getTime());
|
|
369
|
+
|
|
370
|
+
for (const key in input) {
|
|
371
|
+
const v = input[key];
|
|
372
|
+
out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function complement(fn) {
|
|
379
|
+
return (...input) => !fn(...input);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function compose(...fns) {
|
|
383
|
+
if (fns.length === 0) {
|
|
384
|
+
throw new Error('compose requires at least one argument');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return function (...args) {
|
|
388
|
+
const list = fns.slice();
|
|
389
|
+
|
|
390
|
+
if (list.length > 0) {
|
|
391
|
+
const fn = list.pop();
|
|
392
|
+
let result = fn.apply(this, args);
|
|
393
|
+
|
|
394
|
+
while (list.length > 0) {
|
|
395
|
+
result = list.pop()(result);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function concat(x, y) {
|
|
404
|
+
if (arguments.length === 1) return _y => concat(x, _y);
|
|
405
|
+
return typeof x === 'string' ? `${x}${y}` : [...x, ...y];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function cond(conditions) {
|
|
409
|
+
return input => {
|
|
410
|
+
let done = false;
|
|
411
|
+
let toReturn;
|
|
412
|
+
conditions.forEach(([predicate, resultClosure]) => {
|
|
413
|
+
if (!done && predicate(input)) {
|
|
414
|
+
done = true;
|
|
415
|
+
toReturn = resultClosure(input);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
return toReturn;
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
402
422
|
const _keys = Object.keys;
|
|
403
423
|
|
|
404
424
|
function mapArray(fn, list, isIndexed = false) {
|
|
@@ -429,11 +449,15 @@ function mapObject(fn, obj) {
|
|
|
429
449
|
return willReturn;
|
|
430
450
|
}
|
|
431
451
|
const mapObjIndexed = mapObject;
|
|
432
|
-
function map(fn,
|
|
433
|
-
if (arguments.length === 1) return
|
|
434
|
-
|
|
435
|
-
if (
|
|
436
|
-
|
|
452
|
+
function map(fn, iterable) {
|
|
453
|
+
if (arguments.length === 1) return _iterable => map(fn, _iterable);
|
|
454
|
+
|
|
455
|
+
if (!iterable) {
|
|
456
|
+
throw new Error('Incorrect iterable input');
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (_isArray(iterable)) return mapArray(fn, iterable);
|
|
460
|
+
return mapObject(fn, iterable);
|
|
437
461
|
}
|
|
438
462
|
|
|
439
463
|
function max(x, y) {
|
|
@@ -482,34 +506,83 @@ function defaultTo(defaultArgument, input) {
|
|
|
482
506
|
}
|
|
483
507
|
|
|
484
508
|
function type(input) {
|
|
485
|
-
const typeOf = typeof input;
|
|
486
|
-
|
|
487
509
|
if (input === null) {
|
|
488
510
|
return 'Null';
|
|
489
511
|
} else if (input === undefined) {
|
|
490
512
|
return 'Undefined';
|
|
491
|
-
} else if (
|
|
492
|
-
return '
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
+
} else if (Number.isNaN(input)) {
|
|
514
|
+
return 'NaN';
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const typeResult = Object.prototype.toString.call(input).slice(8, -1);
|
|
518
|
+
return typeResult === 'AsyncFunction' ? 'Async' : typeResult;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function _lastIndexOf(valueToFind, list) {
|
|
522
|
+
if (!_isArray(list)) {
|
|
523
|
+
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const typeOfValue = type(valueToFind);
|
|
527
|
+
if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
|
|
528
|
+
const {
|
|
529
|
+
length
|
|
530
|
+
} = list;
|
|
531
|
+
let index = length;
|
|
532
|
+
let foundIndex = -1;
|
|
533
|
+
|
|
534
|
+
while (--index > -1 && foundIndex === -1) {
|
|
535
|
+
if (equals(list[index], valueToFind)) {
|
|
536
|
+
foundIndex = index;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return foundIndex;
|
|
541
|
+
}
|
|
542
|
+
function _indexOf(valueToFind, list) {
|
|
543
|
+
if (!_isArray(list)) {
|
|
544
|
+
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const typeOfValue = type(valueToFind);
|
|
548
|
+
if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
|
|
549
|
+
let index = -1;
|
|
550
|
+
let foundIndex = -1;
|
|
551
|
+
const {
|
|
552
|
+
length
|
|
553
|
+
} = list;
|
|
554
|
+
|
|
555
|
+
while (++index < length && foundIndex === -1) {
|
|
556
|
+
if (equals(list[index], valueToFind)) {
|
|
557
|
+
foundIndex = index;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return foundIndex;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function _arrayFromIterator(iter) {
|
|
565
|
+
const list = [];
|
|
566
|
+
let next;
|
|
567
|
+
|
|
568
|
+
while (!(next = iter.next()).done) {
|
|
569
|
+
list.push(next.value);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
return list;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function _equalsSets(a, b) {
|
|
576
|
+
if (a.size !== b.size) {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
const aList = _arrayFromIterator(a.values());
|
|
581
|
+
|
|
582
|
+
const bList = _arrayFromIterator(b.values());
|
|
583
|
+
|
|
584
|
+
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
|
|
585
|
+
return filtered.length === 0;
|
|
513
586
|
}
|
|
514
587
|
|
|
515
588
|
function parseError(maybeError) {
|
|
@@ -589,6 +662,10 @@ function equals(a, b) {
|
|
|
589
662
|
return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
|
|
590
663
|
}
|
|
591
664
|
|
|
665
|
+
if (aType === 'Set') {
|
|
666
|
+
return _equalsSets(a, b);
|
|
667
|
+
}
|
|
668
|
+
|
|
592
669
|
if (aType === 'Object') {
|
|
593
670
|
const aKeys = Object.keys(a);
|
|
594
671
|
|
|
@@ -613,48 +690,19 @@ function equals(a, b) {
|
|
|
613
690
|
return false;
|
|
614
691
|
}
|
|
615
692
|
|
|
616
|
-
function
|
|
617
|
-
if (
|
|
618
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
619
|
-
}
|
|
693
|
+
function includes(valueToFind, iterable) {
|
|
694
|
+
if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
|
|
620
695
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
let index = -1;
|
|
624
|
-
let foundIndex = -1;
|
|
625
|
-
const {
|
|
626
|
-
length
|
|
627
|
-
} = list;
|
|
628
|
-
|
|
629
|
-
while (++index < length && foundIndex === -1) {
|
|
630
|
-
if (equals(list[index], valueToFind)) {
|
|
631
|
-
foundIndex = index;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
return foundIndex;
|
|
636
|
-
}
|
|
637
|
-
function indexOf(valueToFind, list) {
|
|
638
|
-
if (arguments.length === 1) {
|
|
639
|
-
return _list => _indexOf(valueToFind, _list);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
return _indexOf(valueToFind, list);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
function includes(valueToFind, input) {
|
|
646
|
-
if (arguments.length === 1) return _input => includes(valueToFind, _input);
|
|
647
|
-
|
|
648
|
-
if (typeof input === 'string') {
|
|
649
|
-
return input.includes(valueToFind);
|
|
696
|
+
if (typeof iterable === 'string') {
|
|
697
|
+
return iterable.includes(valueToFind);
|
|
650
698
|
}
|
|
651
699
|
|
|
652
|
-
if (!
|
|
653
|
-
throw new TypeError(`Cannot read property \'indexOf\' of ${
|
|
700
|
+
if (!iterable) {
|
|
701
|
+
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
|
|
654
702
|
}
|
|
655
703
|
|
|
656
|
-
if (!_isArray(
|
|
657
|
-
return _indexOf(valueToFind,
|
|
704
|
+
if (!_isArray(iterable)) return false;
|
|
705
|
+
return _indexOf(valueToFind, iterable) > -1;
|
|
658
706
|
}
|
|
659
707
|
|
|
660
708
|
class _Set {
|
|
@@ -854,17 +902,33 @@ function either(firstPredicate, secondPredicate) {
|
|
|
854
902
|
return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
|
|
855
903
|
}
|
|
856
904
|
|
|
857
|
-
function endsWith(target,
|
|
858
|
-
if (arguments.length === 1) return
|
|
859
|
-
return str.endsWith(target);
|
|
860
|
-
}
|
|
905
|
+
function endsWith(target, iterable) {
|
|
906
|
+
if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
|
|
861
907
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
throw new Error('wrong object inputs are passed to R.eqProps');
|
|
908
|
+
if (typeof iterable === 'string') {
|
|
909
|
+
return iterable.endsWith(target);
|
|
865
910
|
}
|
|
866
911
|
|
|
867
|
-
|
|
912
|
+
if (!_isArray(target)) return false;
|
|
913
|
+
const diff = iterable.length - target.length;
|
|
914
|
+
let correct = true;
|
|
915
|
+
const filtered = target.filter((x, index) => {
|
|
916
|
+
if (!correct) return false;
|
|
917
|
+
const result = equals(x, iterable[index + diff]);
|
|
918
|
+
if (!result) correct = false;
|
|
919
|
+
return result;
|
|
920
|
+
});
|
|
921
|
+
return filtered.length === target.length;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function prop(propToFind, obj) {
|
|
925
|
+
if (arguments.length === 1) return _obj => prop(propToFind, _obj);
|
|
926
|
+
if (!obj) return undefined;
|
|
927
|
+
return obj[propToFind];
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function eqPropsFn(property, objA, objB) {
|
|
931
|
+
return equals(prop(property, objA), prop(property, objB));
|
|
868
932
|
}
|
|
869
933
|
|
|
870
934
|
const eqProps = curry(eqPropsFn);
|
|
@@ -953,11 +1017,12 @@ function filterArray(predicate, list, indexed = false) {
|
|
|
953
1017
|
return willReturn;
|
|
954
1018
|
}
|
|
955
1019
|
function filter(predicate, iterable) {
|
|
956
|
-
if (arguments.length === 1)
|
|
957
|
-
|
|
1020
|
+
if (arguments.length === 1) return _iterable => filter(predicate, _iterable);
|
|
1021
|
+
|
|
1022
|
+
if (!iterable) {
|
|
1023
|
+
throw new Error('Incorrect iterable input');
|
|
958
1024
|
}
|
|
959
1025
|
|
|
960
|
-
if (!iterable) return [];
|
|
961
1026
|
if (_isArray(iterable)) return filterArray(predicate, iterable);
|
|
962
1027
|
return filterObject(predicate, iterable);
|
|
963
1028
|
}
|
|
@@ -1044,7 +1109,7 @@ function flipFn(fn) {
|
|
|
1044
1109
|
return fn(input[1], input[0], input[2], input[3]);
|
|
1045
1110
|
}
|
|
1046
1111
|
|
|
1047
|
-
throw new Error(
|
|
1112
|
+
throw new Error("R.flip doesn't work with arity > 4");
|
|
1048
1113
|
};
|
|
1049
1114
|
}
|
|
1050
1115
|
|
|
@@ -1110,7 +1175,7 @@ function groupBy(groupFn, list) {
|
|
|
1110
1175
|
|
|
1111
1176
|
function groupWith(compareFn, list) {
|
|
1112
1177
|
if (!_isArray(list)) throw new TypeError('list.reduce is not a function');
|
|
1113
|
-
const clone = list
|
|
1178
|
+
const clone = cloneList(list);
|
|
1114
1179
|
if (list.length === 1) return [clone];
|
|
1115
1180
|
const toReturn = [];
|
|
1116
1181
|
let holder = [];
|
|
@@ -1171,12 +1236,12 @@ function path(pathInput, obj) {
|
|
|
1171
1236
|
return willReturn;
|
|
1172
1237
|
}
|
|
1173
1238
|
|
|
1174
|
-
function hasPath(
|
|
1239
|
+
function hasPath(pathInput, obj) {
|
|
1175
1240
|
if (arguments.length === 1) {
|
|
1176
|
-
return objHolder => hasPath(
|
|
1241
|
+
return objHolder => hasPath(pathInput, objHolder);
|
|
1177
1242
|
}
|
|
1178
1243
|
|
|
1179
|
-
return path(
|
|
1244
|
+
return path(pathInput, obj) !== undefined;
|
|
1180
1245
|
}
|
|
1181
1246
|
|
|
1182
1247
|
function head(listOrString) {
|
|
@@ -1198,8 +1263,8 @@ function identical(a, b) {
|
|
|
1198
1263
|
return _objectIs$1(a, b);
|
|
1199
1264
|
}
|
|
1200
1265
|
|
|
1201
|
-
function identity(
|
|
1202
|
-
return
|
|
1266
|
+
function identity(x) {
|
|
1267
|
+
return x;
|
|
1203
1268
|
}
|
|
1204
1269
|
|
|
1205
1270
|
function ifElseFn(condition, onTrue, onFalse) {
|
|
@@ -1248,6 +1313,14 @@ function indexBy(condition, list) {
|
|
|
1248
1313
|
return toReturn;
|
|
1249
1314
|
}
|
|
1250
1315
|
|
|
1316
|
+
function indexOf(valueToFind, list) {
|
|
1317
|
+
if (arguments.length === 1) {
|
|
1318
|
+
return _list => _indexOf(valueToFind, _list);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
return _indexOf(valueToFind, list);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1251
1324
|
function baseSlice(array, start, end) {
|
|
1252
1325
|
let index = -1;
|
|
1253
1326
|
let {
|
|
@@ -1339,25 +1412,18 @@ function last(listOrString) {
|
|
|
1339
1412
|
return listOrString[listOrString.length - 1];
|
|
1340
1413
|
}
|
|
1341
1414
|
|
|
1342
|
-
function lastIndexOf(
|
|
1343
|
-
if (arguments.length === 1)
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
while (--index > 0) {
|
|
1347
|
-
if (equals(list[index], target)) {
|
|
1348
|
-
return index;
|
|
1349
|
-
}
|
|
1415
|
+
function lastIndexOf(valueToFind, list) {
|
|
1416
|
+
if (arguments.length === 1) {
|
|
1417
|
+
return _list => _lastIndexOf(valueToFind, _list);
|
|
1350
1418
|
}
|
|
1351
1419
|
|
|
1352
|
-
return
|
|
1420
|
+
return _lastIndexOf(valueToFind, list);
|
|
1353
1421
|
}
|
|
1354
1422
|
|
|
1355
1423
|
function length(x) {
|
|
1356
|
-
if (
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
return x.length;
|
|
1424
|
+
if (_isArray(x)) return x.length;
|
|
1425
|
+
if (typeof x === 'string') return x.length;
|
|
1426
|
+
return NaN;
|
|
1361
1427
|
}
|
|
1362
1428
|
|
|
1363
1429
|
function lens(getter, setter) {
|
|
@@ -1375,8 +1441,9 @@ function nth(index, list) {
|
|
|
1375
1441
|
}
|
|
1376
1442
|
|
|
1377
1443
|
function updateFn(index, newValue, list) {
|
|
1378
|
-
const
|
|
1379
|
-
return
|
|
1444
|
+
const clone = cloneList(list);
|
|
1445
|
+
if (index === -1) return clone.fill(newValue, index);
|
|
1446
|
+
return clone.fill(newValue, index, index + 1);
|
|
1380
1447
|
}
|
|
1381
1448
|
|
|
1382
1449
|
const update = curry(updateFn);
|
|
@@ -1389,12 +1456,6 @@ function lensPath(key) {
|
|
|
1389
1456
|
return lens(path(key), assocPath(key));
|
|
1390
1457
|
}
|
|
1391
1458
|
|
|
1392
|
-
function prop(propToFind, obj) {
|
|
1393
|
-
if (arguments.length === 1) return _obj => prop(propToFind, _obj);
|
|
1394
|
-
if (!obj) return undefined;
|
|
1395
|
-
return obj[propToFind];
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
1459
|
function lensProp(key) {
|
|
1399
1460
|
return lens(prop(key), assoc(key));
|
|
1400
1461
|
}
|
|
@@ -1494,7 +1555,7 @@ function moveFn(fromIndex, toIndex, list) {
|
|
|
1494
1555
|
}
|
|
1495
1556
|
|
|
1496
1557
|
if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
|
|
1497
|
-
const clone = list
|
|
1558
|
+
const clone = cloneList(list);
|
|
1498
1559
|
clone[fromIndex] = list[toIndex];
|
|
1499
1560
|
clone[toIndex] = list[fromIndex];
|
|
1500
1561
|
return clone;
|
|
@@ -1648,8 +1709,8 @@ function pathEqFn(pathToSearch, target, input) {
|
|
|
1648
1709
|
|
|
1649
1710
|
const pathEq = curry(pathEqFn);
|
|
1650
1711
|
|
|
1651
|
-
function pathOrFn(defaultValue,
|
|
1652
|
-
return defaultTo(defaultValue, path(
|
|
1712
|
+
function pathOrFn(defaultValue, pathInput, obj) {
|
|
1713
|
+
return defaultTo(defaultValue, path(pathInput, obj));
|
|
1653
1714
|
}
|
|
1654
1715
|
|
|
1655
1716
|
const pathOr = curry(pathOrFn);
|
|
@@ -1837,13 +1898,12 @@ const slice = curry(sliceFn);
|
|
|
1837
1898
|
|
|
1838
1899
|
function sort(sortFn, list) {
|
|
1839
1900
|
if (arguments.length === 1) return _list => sort(sortFn, _list);
|
|
1840
|
-
|
|
1841
|
-
return clone.sort(sortFn);
|
|
1901
|
+
return cloneList(list).sort(sortFn);
|
|
1842
1902
|
}
|
|
1843
1903
|
|
|
1844
1904
|
function sortBy(sortFn, list) {
|
|
1845
1905
|
if (arguments.length === 1) return _list => sortBy(sortFn, _list);
|
|
1846
|
-
const clone = list
|
|
1906
|
+
const clone = cloneList(list);
|
|
1847
1907
|
return clone.sort((a, b) => {
|
|
1848
1908
|
const aSortResult = sortFn(a);
|
|
1849
1909
|
const bSortResult = sortFn(b);
|
|
@@ -1925,9 +1985,22 @@ function splitWhen(predicate, input) {
|
|
|
1925
1985
|
return [preFound, postFound];
|
|
1926
1986
|
}
|
|
1927
1987
|
|
|
1928
|
-
function startsWith(target,
|
|
1929
|
-
if (arguments.length === 1) return
|
|
1930
|
-
|
|
1988
|
+
function startsWith(target, iterable) {
|
|
1989
|
+
if (arguments.length === 1) return _iterable => startsWith(target, _iterable);
|
|
1990
|
+
|
|
1991
|
+
if (typeof iterable === 'string') {
|
|
1992
|
+
return iterable.startsWith(target);
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
if (!_isArray(target)) return false;
|
|
1996
|
+
let correct = true;
|
|
1997
|
+
const filtered = target.filter((x, index) => {
|
|
1998
|
+
if (!correct) return false;
|
|
1999
|
+
const result = equals(x, iterable[index]);
|
|
2000
|
+
if (!result) correct = false;
|
|
2001
|
+
return result;
|
|
2002
|
+
});
|
|
2003
|
+
return filtered.length === target.length;
|
|
1931
2004
|
}
|
|
1932
2005
|
|
|
1933
2006
|
function subtract(a, b) {
|
|
@@ -2077,15 +2150,36 @@ function tryCatch(fn, fallback) {
|
|
|
2077
2150
|
};
|
|
2078
2151
|
}
|
|
2079
2152
|
|
|
2153
|
+
function unapply(fn) {
|
|
2154
|
+
return function (...args) {
|
|
2155
|
+
return fn.call(this, args);
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2080
2159
|
function union(x, y) {
|
|
2081
2160
|
if (arguments.length === 1) return _y => union(x, _y);
|
|
2082
|
-
const toReturn = x
|
|
2161
|
+
const toReturn = cloneList(x);
|
|
2083
2162
|
y.forEach(yInstance => {
|
|
2084
2163
|
if (!includes(yInstance, x)) toReturn.push(yInstance);
|
|
2085
2164
|
});
|
|
2086
2165
|
return toReturn;
|
|
2087
2166
|
}
|
|
2088
2167
|
|
|
2168
|
+
function includesWith(predicate, target, list) {
|
|
2169
|
+
let willReturn = false;
|
|
2170
|
+
let index = -1;
|
|
2171
|
+
|
|
2172
|
+
while (++index < list.length && !willReturn) {
|
|
2173
|
+
const value = list[index];
|
|
2174
|
+
|
|
2175
|
+
if (predicate(target, value)) {
|
|
2176
|
+
willReturn = true;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
return willReturn;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2089
2183
|
function uniqWith(predicate, list) {
|
|
2090
2184
|
if (arguments.length === 1) return _list => uniqWith(predicate, _list);
|
|
2091
2185
|
let index = -1;
|
|
@@ -2093,9 +2187,8 @@ function uniqWith(predicate, list) {
|
|
|
2093
2187
|
|
|
2094
2188
|
while (++index < list.length) {
|
|
2095
2189
|
const value = list[index];
|
|
2096
|
-
const flag = any(x => predicate(value, x), willReturn);
|
|
2097
2190
|
|
|
2098
|
-
if (!
|
|
2191
|
+
if (!includesWith(predicate, value, willReturn)) {
|
|
2099
2192
|
willReturn.push(value);
|
|
2100
2193
|
}
|
|
2101
2194
|
}
|
|
@@ -2199,4 +2292,4 @@ function zipWithFn(fn, x, y) {
|
|
|
2199
2292
|
|
|
2200
2293
|
const zipWith = curry(zipWithFn);
|
|
2201
2294
|
|
|
2202
|
-
export { F, T, _indexOf, add, adjust, all, allPass, always, and, any, anyPass, append, applySpec, assoc, assocPath, both, chain, clamp, clone, complement, compose, concat, cond, converge, 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, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, merge, mergeAll, mergeDeepRight, mergeLeft, min, minBy, minByFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, once, or, over, partial, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, props, range, reduce, 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, union, uniq, uniqWith, unless, update, values, view, when, where, whereEq, without, xor, zip, zipObj, zipWith };
|
|
2295
|
+
export { F, T, _indexOf, _lastIndexOf, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, 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, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, merge, mergeAll, mergeDeepRight, mergeLeft, min, minBy, minByFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, once, or, over, partial, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, props, range, reduce, 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, uniqWith, unless, update, values, view, when, where, whereEq, without, xor, zip, zipObj, zipWith };
|