rambda 6.8.2 → 7.0.1

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.
Files changed (189) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +4108 -5600
  3. package/dist/rambda.esm.js +340 -212
  4. package/dist/rambda.js +345 -212
  5. package/dist/rambda.mjs +340 -212
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +202 -275
  8. package/immutable.js +1 -0
  9. package/index.d.ts +202 -275
  10. package/package.json +111 -95
  11. package/src/F.js +1 -1
  12. package/src/T.js +1 -1
  13. package/src/_internals/_isInteger.js +1 -1
  14. package/src/_internals/_objectIs.js +2 -2
  15. package/src/_internals/baseSlice.js +6 -8
  16. package/src/_internals/cloneList.js +3 -0
  17. package/src/_internals/isFalsy.js +5 -5
  18. package/src/_internals/isObject.js +5 -0
  19. package/src/_internals/isTruthy.js +5 -5
  20. package/src/_internals/set.js +35 -0
  21. package/src/add.js +1 -1
  22. package/src/adjust.js +5 -6
  23. package/src/all.js +3 -3
  24. package/src/allPass.js +4 -4
  25. package/src/always.js +1 -1
  26. package/src/and.js +1 -1
  27. package/src/any.js +3 -3
  28. package/src/anyPass.js +4 -4
  29. package/src/append.js +4 -2
  30. package/src/apply.js +7 -0
  31. package/src/applySpec.js +33 -59
  32. package/src/assoc.js +3 -7
  33. package/src/assocPath.js +22 -25
  34. package/src/bind.js +9 -0
  35. package/src/both.js +1 -1
  36. package/src/chain.js +2 -2
  37. package/src/clamp.js +6 -6
  38. package/src/clone.js +10 -10
  39. package/src/complement.js +1 -1
  40. package/src/compose.js +6 -6
  41. package/src/concat.js +2 -2
  42. package/src/cond.js +3 -3
  43. package/src/converge.js +11 -11
  44. package/src/curry.js +2 -2
  45. package/src/curryN.js +61 -81
  46. package/src/defaultTo.js +5 -8
  47. package/src/difference.js +3 -3
  48. package/src/dissoc.js +4 -4
  49. package/src/divide.js +1 -1
  50. package/src/drop.js +1 -1
  51. package/src/dropLast.js +5 -5
  52. package/src/dropLastWhile.js +12 -12
  53. package/src/dropRepeats.js +6 -6
  54. package/src/dropRepeatsWith.js +7 -7
  55. package/src/dropWhile.js +9 -9
  56. package/src/either.js +2 -2
  57. package/src/endsWith.js +20 -3
  58. package/src/eqProps.js +5 -10
  59. package/src/equals.js +119 -38
  60. package/src/evolve.js +23 -21
  61. package/src/filter.js +17 -19
  62. package/src/find.js +4 -4
  63. package/src/findIndex.js +3 -3
  64. package/src/findLast.js +4 -4
  65. package/src/findLastIndex.js +3 -3
  66. package/src/flatten.js +6 -6
  67. package/src/flip.js +11 -15
  68. package/src/forEach.js +10 -12
  69. package/src/fromPairs.js +2 -2
  70. package/src/groupBy.js +6 -6
  71. package/src/groupWith.js +11 -12
  72. package/src/hasPath.js +5 -5
  73. package/src/head.js +3 -3
  74. package/src/identical.js +1 -1
  75. package/src/identity.js +2 -2
  76. package/src/ifElse.js +3 -5
  77. package/src/includes.js +11 -22
  78. package/src/indexBy.js +11 -11
  79. package/src/indexOf.js +5 -12
  80. package/src/init.js +2 -4
  81. package/src/intersection.js +3 -3
  82. package/src/intersperse.js +5 -5
  83. package/src/is.js +2 -2
  84. package/src/isEmpty.js +5 -5
  85. package/src/isFunction.js +3 -3
  86. package/src/isNil.js +1 -1
  87. package/src/isPromise.js +3 -3
  88. package/src/join.js +1 -1
  89. package/src/keys.js +1 -1
  90. package/src/last.js +4 -4
  91. package/src/lastIndexOf.js +5 -11
  92. package/src/length.js +6 -5
  93. package/src/lens.js +3 -3
  94. package/src/lensIndex.js +4 -4
  95. package/src/lensProp.js +4 -4
  96. package/src/map.js +19 -18
  97. package/src/match.js +1 -1
  98. package/src/mathMod.js +2 -2
  99. package/src/max.js +1 -1
  100. package/src/maxBy.js +2 -4
  101. package/src/maybe.js +2 -4
  102. package/src/mean.js +2 -2
  103. package/src/median.js +12 -10
  104. package/src/merge.js +2 -4
  105. package/src/mergeAll.js +3 -3
  106. package/src/mergeDeepRight.js +8 -8
  107. package/src/mergeLeft.js +2 -2
  108. package/src/min.js +1 -1
  109. package/src/minBy.js +2 -4
  110. package/src/modulo.js +1 -1
  111. package/src/move.js +7 -8
  112. package/src/multiply.js +1 -1
  113. package/src/negate.js +1 -1
  114. package/src/none.js +3 -3
  115. package/src/not.js +1 -1
  116. package/src/nth.js +4 -4
  117. package/src/objOf.js +3 -3
  118. package/src/of.js +2 -2
  119. package/src/omit.js +5 -5
  120. package/src/once.js +6 -6
  121. package/src/or.js +1 -1
  122. package/src/over.js +3 -5
  123. package/src/partial.js +3 -3
  124. package/src/partition.js +17 -15
  125. package/src/path.js +6 -6
  126. package/src/pathEq.js +4 -6
  127. package/src/pathOr.js +5 -7
  128. package/src/paths.js +3 -3
  129. package/src/pick.js +5 -5
  130. package/src/pickAll.js +6 -6
  131. package/src/pipe.js +3 -3
  132. package/src/pluck.js +4 -4
  133. package/src/prepend.js +3 -3
  134. package/src/product.js +2 -2
  135. package/src/prop.js +2 -2
  136. package/src/propEq.js +3 -5
  137. package/src/propIs.js +4 -6
  138. package/src/propOr.js +4 -6
  139. package/src/props.js +6 -6
  140. package/src/range.js +4 -4
  141. package/src/reduce.js +7 -11
  142. package/src/reject.js +2 -2
  143. package/src/repeat.js +2 -2
  144. package/src/replace.js +2 -4
  145. package/src/reverse.js +3 -4
  146. package/src/set.js +5 -9
  147. package/src/slice.js +2 -4
  148. package/src/sort.js +4 -4
  149. package/src/sortBy.js +4 -2
  150. package/src/split.js +1 -1
  151. package/src/splitAt.js +9 -9
  152. package/src/splitEvery.js +8 -6
  153. package/src/splitWhen.js +10 -10
  154. package/src/startsWith.js +20 -3
  155. package/src/subtract.js +1 -1
  156. package/src/sum.js +1 -1
  157. package/src/symmetricDifference.js +9 -7
  158. package/src/tail.js +2 -2
  159. package/src/take.js +2 -4
  160. package/src/takeLast.js +2 -4
  161. package/src/takeLastWhile.js +7 -7
  162. package/src/takeWhile.js +8 -8
  163. package/src/tap.js +1 -1
  164. package/src/test.js +5 -3
  165. package/src/times.js +4 -4
  166. package/src/toLower.js +1 -1
  167. package/src/toPairs.js +1 -1
  168. package/src/toString.js +1 -1
  169. package/src/toUpper.js +1 -1
  170. package/src/transpose.js +4 -3
  171. package/src/trim.js +1 -1
  172. package/src/tryCatch.js +5 -5
  173. package/src/type.js +7 -29
  174. package/src/unapply.js +5 -0
  175. package/src/union.js +4 -3
  176. package/src/uniq.js +7 -10
  177. package/src/uniqWith.js +18 -7
  178. package/src/unless.js +3 -3
  179. package/src/update.js +6 -8
  180. package/src/values.js +2 -2
  181. package/src/view.js +2 -2
  182. package/src/when.js +2 -4
  183. package/src/where.js +5 -5
  184. package/src/whereEq.js +9 -7
  185. package/src/without.js +5 -5
  186. package/src/xor.js +2 -2
  187. package/src/zip.js +3 -3
  188. package/src/zipObj.js +4 -6
  189. package/src/zipWith.js +6 -7
package/dist/rambda.js CHANGED
@@ -19,10 +19,14 @@ function curry(fn, args = []) {
19
19
  return (..._args) => (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([...args, ..._args]);
20
20
  }
21
21
 
22
+ const cloneList = list => {
23
+ return Array.prototype.slice.call(list);
24
+ };
25
+
22
26
  function adjustFn(index, replaceFn, list) {
23
27
  const actualIndex = index < 0 ? list.length + index : index;
24
28
  if (index >= list.length || actualIndex < 0) return list;
25
- const clone = list.slice();
29
+ const clone = cloneList(list);
26
30
  clone[actualIndex] = replaceFn(clone[actualIndex]);
27
31
  return clone;
28
32
  }
@@ -40,11 +44,11 @@ function all(predicate, list) {
40
44
  }
41
45
 
42
46
  function allPass(predicates) {
43
- return input => {
47
+ return (...input) => {
44
48
  let counter = 0;
45
49
 
46
50
  while (counter < predicates.length) {
47
- if (!predicates[counter](input)) {
51
+ if (!predicates[counter](...input)) {
48
52
  return false;
49
53
  }
50
54
 
@@ -80,11 +84,11 @@ function any(predicate, list) {
80
84
  }
81
85
 
82
86
  function anyPass(predicates) {
83
- return input => {
87
+ return (...input) => {
84
88
  let counter = 0;
85
89
 
86
90
  while (counter < predicates.length) {
87
- if (predicates[counter](input)) {
91
+ if (predicates[counter](...input)) {
88
92
  return true;
89
93
  }
90
94
 
@@ -98,11 +102,19 @@ function anyPass(predicates) {
98
102
  function append(x, input) {
99
103
  if (arguments.length === 1) return _input => append(x, _input);
100
104
  if (typeof input === 'string') return input.split('').concat(x);
101
- const clone = input.slice();
105
+ const clone = cloneList(input);
102
106
  clone.push(x);
103
107
  return clone;
104
108
  }
105
109
 
110
+ function apply(fn, args) {
111
+ if (arguments.length === 1) {
112
+ return _args => apply(fn, _args);
113
+ }
114
+
115
+ return fn.apply(this, args);
116
+ }
117
+
106
118
  const _isArray = Array.isArray;
107
119
 
108
120
  function __findHighestArity(spec, max = 0) {
@@ -220,7 +232,7 @@ function assocPathFn(path, newValue, input) {
220
232
  }
221
233
 
222
234
  if (_isInteger(index) && _isArray(input)) {
223
- const arr = input.slice();
235
+ const arr = cloneList(input);
224
236
  arr[index] = newValue;
225
237
  return arr;
226
238
  }
@@ -230,87 +242,6 @@ function assocPathFn(path, newValue, input) {
230
242
 
231
243
  const assocPath = curry(assocPathFn);
232
244
 
233
- function both(f, g) {
234
- if (arguments.length === 1) return _g => both(f, _g);
235
- return (...input) => f(...input) && g(...input);
236
- }
237
-
238
- function chain(fn, list) {
239
- if (arguments.length === 1) {
240
- return _list => chain(fn, _list);
241
- }
242
-
243
- return [].concat(...list.map(fn));
244
- }
245
-
246
- function clampFn(min, max, input) {
247
- if (min > max) {
248
- throw new Error('min must not be greater than max in clamp(min, max, value)');
249
- }
250
-
251
- if (input >= min && input <= max) return input;
252
- if (input > max) return max;
253
- if (input < min) return min;
254
- }
255
-
256
- const clamp = curry(clampFn);
257
-
258
- function clone(input) {
259
- const out = _isArray(input) ? Array(input.length) : {};
260
- if (input && input.getTime) return new Date(input.getTime());
261
-
262
- for (const key in input) {
263
- const v = input[key];
264
- out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
265
- }
266
-
267
- return out;
268
- }
269
-
270
- function complement(fn) {
271
- return (...input) => !fn(...input);
272
- }
273
-
274
- function compose(...fns) {
275
- if (fns.length === 0) {
276
- throw new Error('compose requires at least one argument');
277
- }
278
-
279
- return (...args) => {
280
- const list = fns.slice();
281
-
282
- if (list.length > 0) {
283
- const fn = list.pop();
284
- let result = fn(...args);
285
-
286
- while (list.length > 0) {
287
- result = list.pop()(result);
288
- }
289
-
290
- return result;
291
- }
292
- };
293
- }
294
-
295
- function concat(x, y) {
296
- if (arguments.length === 1) return _y => concat(x, _y);
297
- return typeof x === 'string' ? `${x}${y}` : [...x, ...y];
298
- }
299
-
300
- function cond(conditions) {
301
- return input => {
302
- let done = false;
303
- let toReturn;
304
- conditions.forEach(([predicate, resultClosure]) => {
305
- if (!done && predicate(input)) {
306
- done = true;
307
- toReturn = resultClosure(input);
308
- }
309
- });
310
- return toReturn;
311
- };
312
- }
313
-
314
245
  function _curryN(n, cache, fn) {
315
246
  return function () {
316
247
  let ci = 0;
@@ -403,6 +334,95 @@ function curryN(n, fn) {
403
334
  return _arity(n, _curryN(n, [], fn));
404
335
  }
405
336
 
337
+ function bind(fn, thisObj) {
338
+ if (arguments.length === 1) {
339
+ return _thisObj => bind(fn, _thisObj);
340
+ }
341
+
342
+ return curryN(fn.length, (...args) => fn.apply(thisObj, args));
343
+ }
344
+
345
+ function both(f, g) {
346
+ if (arguments.length === 1) return _g => both(f, _g);
347
+ return (...input) => f(...input) && g(...input);
348
+ }
349
+
350
+ function chain(fn, list) {
351
+ if (arguments.length === 1) {
352
+ return _list => chain(fn, _list);
353
+ }
354
+
355
+ return [].concat(...list.map(fn));
356
+ }
357
+
358
+ function clampFn(min, max, input) {
359
+ if (min > max) {
360
+ throw new Error('min must not be greater than max in clamp(min, max, value)');
361
+ }
362
+
363
+ if (input >= min && input <= max) return input;
364
+ if (input > max) return max;
365
+ if (input < min) return min;
366
+ }
367
+
368
+ const clamp = curry(clampFn);
369
+
370
+ function clone(input) {
371
+ const out = _isArray(input) ? Array(input.length) : {};
372
+ if (input && input.getTime) return new Date(input.getTime());
373
+
374
+ for (const key in input) {
375
+ const v = input[key];
376
+ out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
377
+ }
378
+
379
+ return out;
380
+ }
381
+
382
+ function complement(fn) {
383
+ return (...input) => !fn(...input);
384
+ }
385
+
386
+ function compose(...fns) {
387
+ if (fns.length === 0) {
388
+ throw new Error('compose requires at least one argument');
389
+ }
390
+
391
+ return function (...args) {
392
+ const list = fns.slice();
393
+
394
+ if (list.length > 0) {
395
+ const fn = list.pop();
396
+ let result = fn.apply(this, args);
397
+
398
+ while (list.length > 0) {
399
+ result = list.pop()(result);
400
+ }
401
+
402
+ return result;
403
+ }
404
+ };
405
+ }
406
+
407
+ function concat(x, y) {
408
+ if (arguments.length === 1) return _y => concat(x, _y);
409
+ return typeof x === 'string' ? `${x}${y}` : [...x, ...y];
410
+ }
411
+
412
+ function cond(conditions) {
413
+ return input => {
414
+ let done = false;
415
+ let toReturn;
416
+ conditions.forEach(([predicate, resultClosure]) => {
417
+ if (!done && predicate(input)) {
418
+ done = true;
419
+ toReturn = resultClosure(input);
420
+ }
421
+ });
422
+ return toReturn;
423
+ };
424
+ }
425
+
406
426
  const _keys = Object.keys;
407
427
 
408
428
  function mapArray(fn, list, isIndexed = false) {
@@ -432,11 +452,16 @@ function mapObject(fn, obj) {
432
452
 
433
453
  return willReturn;
434
454
  }
435
- function map(fn, list) {
436
- if (arguments.length === 1) return _list => map(fn, _list);
437
- if (list === undefined) return [];
438
- if (_isArray(list)) return mapArray(fn, list);
439
- return mapObject(fn, list);
455
+ const mapObjIndexed = mapObject;
456
+ function map(fn, iterable) {
457
+ if (arguments.length === 1) return _iterable => map(fn, _iterable);
458
+
459
+ if (!iterable) {
460
+ throw new Error('Incorrect iterable input');
461
+ }
462
+
463
+ if (_isArray(iterable)) return mapArray(fn, iterable);
464
+ return mapObject(fn, iterable);
440
465
  }
441
466
 
442
467
  function max(x, y) {
@@ -485,34 +510,83 @@ function defaultTo(defaultArgument, input) {
485
510
  }
486
511
 
487
512
  function type(input) {
488
- const typeOf = typeof input;
489
-
490
513
  if (input === null) {
491
514
  return 'Null';
492
515
  } else if (input === undefined) {
493
516
  return 'Undefined';
494
- } else if (typeOf === 'boolean') {
495
- return 'Boolean';
496
- } else if (typeOf === 'number') {
497
- return Number.isNaN(input) ? 'NaN' : 'Number';
498
- } else if (typeOf === 'string') {
499
- return 'String';
500
- } else if (_isArray(input)) {
501
- return 'Array';
502
- } else if (typeOf === 'symbol') {
503
- return 'Symbol';
504
- } else if (input instanceof RegExp) {
505
- return 'RegExp';
506
- }
507
-
508
- const asStr = input && input.toString ? input.toString() : '';
509
- if (['true', 'false'].includes(asStr)) return 'Boolean';
510
- if (!Number.isNaN(Number(asStr))) return 'Number';
511
- if (asStr.startsWith('async')) return 'Async';
512
- if (asStr === '[object Promise]') return 'Promise';
513
- if (typeOf === 'function') return 'Function';
514
- if (input instanceof String) return 'String';
515
- return 'Object';
517
+ } else if (Number.isNaN(input)) {
518
+ return 'NaN';
519
+ }
520
+
521
+ const typeResult = Object.prototype.toString.call(input).slice(8, -1);
522
+ return typeResult === 'AsyncFunction' ? 'Async' : typeResult;
523
+ }
524
+
525
+ function _lastIndexOf(valueToFind, list) {
526
+ if (!_isArray(list)) {
527
+ throw new Error(`Cannot read property 'indexOf' of ${list}`);
528
+ }
529
+
530
+ const typeOfValue = type(valueToFind);
531
+ if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
532
+ const {
533
+ length
534
+ } = list;
535
+ let index = length;
536
+ let foundIndex = -1;
537
+
538
+ while (--index > -1 && foundIndex === -1) {
539
+ if (equals(list[index], valueToFind)) {
540
+ foundIndex = index;
541
+ }
542
+ }
543
+
544
+ return foundIndex;
545
+ }
546
+ function _indexOf(valueToFind, list) {
547
+ if (!_isArray(list)) {
548
+ throw new Error(`Cannot read property 'indexOf' of ${list}`);
549
+ }
550
+
551
+ const typeOfValue = type(valueToFind);
552
+ if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
553
+ let index = -1;
554
+ let foundIndex = -1;
555
+ const {
556
+ length
557
+ } = list;
558
+
559
+ while (++index < length && foundIndex === -1) {
560
+ if (equals(list[index], valueToFind)) {
561
+ foundIndex = index;
562
+ }
563
+ }
564
+
565
+ return foundIndex;
566
+ }
567
+
568
+ function _arrayFromIterator(iter) {
569
+ const list = [];
570
+ let next;
571
+
572
+ while (!(next = iter.next()).done) {
573
+ list.push(next.value);
574
+ }
575
+
576
+ return list;
577
+ }
578
+
579
+ function _equalsSets(a, b) {
580
+ if (a.size !== b.size) {
581
+ return false;
582
+ }
583
+
584
+ const aList = _arrayFromIterator(a.values());
585
+
586
+ const bList = _arrayFromIterator(b.values());
587
+
588
+ const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
589
+ return filtered.length === 0;
516
590
  }
517
591
 
518
592
  function parseError(maybeError) {
@@ -592,6 +666,10 @@ function equals(a, b) {
592
666
  return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
593
667
  }
594
668
 
669
+ if (aType === 'Set') {
670
+ return _equalsSets(a, b);
671
+ }
672
+
595
673
  if (aType === 'Object') {
596
674
  const aKeys = Object.keys(a);
597
675
 
@@ -616,44 +694,68 @@ function equals(a, b) {
616
694
  return false;
617
695
  }
618
696
 
619
- function includesArray(valueToFind, input) {
620
- let index = -1;
697
+ function includes(valueToFind, iterable) {
698
+ if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
621
699
 
622
- while (++index < input.length) {
623
- if (equals(input[index], valueToFind)) {
624
- return true;
625
- }
700
+ if (typeof iterable === 'string') {
701
+ return iterable.includes(valueToFind);
626
702
  }
627
703
 
628
- return false;
704
+ if (!iterable) {
705
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
706
+ }
707
+
708
+ if (!_isArray(iterable)) return false;
709
+ return _indexOf(valueToFind, iterable) > -1;
629
710
  }
630
- function includes(valueToFind, input) {
631
- if (arguments.length === 1) return _input => includes(valueToFind, _input);
632
711
 
633
- if (typeof input === 'string') {
634
- return input.includes(valueToFind);
712
+ class _Set {
713
+ constructor() {
714
+ this.set = new Set();
715
+ this.items = {};
635
716
  }
636
717
 
637
- if (!input) {
638
- throw new TypeError(`Cannot read property \'indexOf\' of ${input}`);
639
- }
718
+ checkUniqueness(item) {
719
+ const type$1 = type(item);
640
720
 
641
- if (!_isArray(input)) return false;
642
- return includesArray(valueToFind, input);
643
- }
721
+ if (['Null', 'Undefined', 'NaN'].includes(type$1)) {
722
+ if (type$1 in this.items) {
723
+ return false;
724
+ }
644
725
 
645
- function uniq(list) {
646
- let index = -1;
647
- const willReturn = [];
726
+ this.items[type$1] = true;
727
+ return true;
728
+ }
648
729
 
649
- while (++index < list.length) {
650
- const value = list[index];
730
+ if (!['Object', 'Array'].includes(type$1)) {
731
+ const prevSize = this.set.size;
732
+ this.set.add(item);
733
+ return this.set.size !== prevSize;
734
+ }
651
735
 
652
- if (!includes(value, willReturn)) {
653
- willReturn.push(value);
736
+ if (!(type$1 in this.items)) {
737
+ this.items[type$1] = [item];
738
+ return true;
739
+ }
740
+
741
+ if (_indexOf(item, this.items[type$1]) === -1) {
742
+ this.items[type$1].push(item);
743
+ return true;
654
744
  }
745
+
746
+ return false;
655
747
  }
656
748
 
749
+ }
750
+
751
+ function uniq(list) {
752
+ const set = new _Set();
753
+ const willReturn = [];
754
+ list.forEach(item => {
755
+ if (set.checkUniqueness(item)) {
756
+ willReturn.push(item);
757
+ }
758
+ });
657
759
  return willReturn;
658
760
  }
659
761
 
@@ -804,17 +906,33 @@ function either(firstPredicate, secondPredicate) {
804
906
  return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
805
907
  }
806
908
 
807
- function endsWith(target, str) {
808
- if (arguments.length === 1) return _str => endsWith(target, _str);
809
- return str.endsWith(target);
810
- }
909
+ function endsWith(target, iterable) {
910
+ if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
811
911
 
812
- function eqPropsFn(prop, obj1, obj2) {
813
- if (!obj1 || !obj2) {
814
- throw new Error('wrong object inputs are passed to R.eqProps');
912
+ if (typeof iterable === 'string') {
913
+ return iterable.endsWith(target);
815
914
  }
816
915
 
817
- return equals(obj1[prop], obj2[prop]);
916
+ if (!_isArray(target)) return false;
917
+ const diff = iterable.length - target.length;
918
+ let correct = true;
919
+ const filtered = target.filter((x, index) => {
920
+ if (!correct) return false;
921
+ const result = equals(x, iterable[index + diff]);
922
+ if (!result) correct = false;
923
+ return result;
924
+ });
925
+ return filtered.length === target.length;
926
+ }
927
+
928
+ function prop(propToFind, obj) {
929
+ if (arguments.length === 1) return _obj => prop(propToFind, _obj);
930
+ if (!obj) return undefined;
931
+ return obj[propToFind];
932
+ }
933
+
934
+ function eqPropsFn(property, objA, objB) {
935
+ return equals(prop(property, objA), prop(property, objB));
818
936
  }
819
937
 
820
938
  const eqProps = curry(eqPropsFn);
@@ -874,11 +992,11 @@ function evolve(rules, iterable) {
874
992
  return evolveArray(rules, iterable);
875
993
  }
876
994
 
877
- function filterObject(fn, obj) {
995
+ function filterObject(predicate, obj) {
878
996
  const willReturn = {};
879
997
 
880
998
  for (const prop in obj) {
881
- if (fn(obj[prop], prop, obj)) {
999
+ if (predicate(obj[prop], prop, obj)) {
882
1000
  willReturn[prop] = obj[prop];
883
1001
  }
884
1002
  }
@@ -903,11 +1021,12 @@ function filterArray(predicate, list, indexed = false) {
903
1021
  return willReturn;
904
1022
  }
905
1023
  function filter(predicate, iterable) {
906
- if (arguments.length === 1) {
907
- return _iterable => filter(predicate, _iterable);
1024
+ if (arguments.length === 1) return _iterable => filter(predicate, _iterable);
1025
+
1026
+ if (!iterable) {
1027
+ throw new Error('Incorrect iterable input');
908
1028
  }
909
1029
 
910
- if (!iterable) return [];
911
1030
  if (_isArray(iterable)) return filterArray(predicate, iterable);
912
1031
  return filterObject(predicate, iterable);
913
1032
  }
@@ -994,7 +1113,7 @@ function flipFn(fn) {
994
1113
  return fn(input[1], input[0], input[2], input[3]);
995
1114
  }
996
1115
 
997
- throw new Error('R.flip doesn\'t work with arity > 4');
1116
+ throw new Error("R.flip doesn't work with arity > 4");
998
1117
  };
999
1118
  }
1000
1119
 
@@ -1060,7 +1179,7 @@ function groupBy(groupFn, list) {
1060
1179
 
1061
1180
  function groupWith(compareFn, list) {
1062
1181
  if (!_isArray(list)) throw new TypeError('list.reduce is not a function');
1063
- const clone = list.slice();
1182
+ const clone = cloneList(list);
1064
1183
  if (list.length === 1) return [clone];
1065
1184
  const toReturn = [];
1066
1185
  let holder = [];
@@ -1121,12 +1240,12 @@ function path(pathInput, obj) {
1121
1240
  return willReturn;
1122
1241
  }
1123
1242
 
1124
- function hasPath(maybePath, obj) {
1243
+ function hasPath(pathInput, obj) {
1125
1244
  if (arguments.length === 1) {
1126
- return objHolder => hasPath(maybePath, objHolder);
1245
+ return objHolder => hasPath(pathInput, objHolder);
1127
1246
  }
1128
1247
 
1129
- return path(maybePath, obj) !== undefined;
1248
+ return path(pathInput, obj) !== undefined;
1130
1249
  }
1131
1250
 
1132
1251
  function head(listOrString) {
@@ -1148,8 +1267,8 @@ function identical(a, b) {
1148
1267
  return _objectIs$1(a, b);
1149
1268
  }
1150
1269
 
1151
- function identity(input) {
1152
- return input;
1270
+ function identity(x) {
1271
+ return x;
1153
1272
  }
1154
1273
 
1155
1274
  function ifElseFn(condition, onTrue, onFalse) {
@@ -1200,21 +1319,10 @@ function indexBy(condition, list) {
1200
1319
 
1201
1320
  function indexOf(valueToFind, list) {
1202
1321
  if (arguments.length === 1) {
1203
- return _list => indexOf(valueToFind, _list);
1322
+ return _list => _indexOf(valueToFind, _list);
1204
1323
  }
1205
1324
 
1206
- let index = -1;
1207
- const {
1208
- length
1209
- } = list;
1210
-
1211
- while (++index < length) {
1212
- if (list[index] === valueToFind) {
1213
- return index;
1214
- }
1215
- }
1216
-
1217
- return -1;
1325
+ return _indexOf(valueToFind, list);
1218
1326
  }
1219
1327
 
1220
1328
  function baseSlice(array, start, end) {
@@ -1308,25 +1416,18 @@ function last(listOrString) {
1308
1416
  return listOrString[listOrString.length - 1];
1309
1417
  }
1310
1418
 
1311
- function lastIndexOf(target, list) {
1312
- if (arguments.length === 1) return _list => lastIndexOf(target, _list);
1313
- let index = list.length;
1314
-
1315
- while (--index > 0) {
1316
- if (equals(list[index], target)) {
1317
- return index;
1318
- }
1419
+ function lastIndexOf(valueToFind, list) {
1420
+ if (arguments.length === 1) {
1421
+ return _list => _lastIndexOf(valueToFind, _list);
1319
1422
  }
1320
1423
 
1321
- return -1;
1424
+ return _lastIndexOf(valueToFind, list);
1322
1425
  }
1323
1426
 
1324
1427
  function length(x) {
1325
- if (!x && x !== '' || x.length === undefined) {
1326
- return NaN;
1327
- }
1328
-
1329
- return x.length;
1428
+ if (_isArray(x)) return x.length;
1429
+ if (typeof x === 'string') return x.length;
1430
+ return NaN;
1330
1431
  }
1331
1432
 
1332
1433
  function lens(getter, setter) {
@@ -1344,8 +1445,9 @@ function nth(index, list) {
1344
1445
  }
1345
1446
 
1346
1447
  function updateFn(index, newValue, list) {
1347
- const arrClone = list.slice();
1348
- return arrClone.fill(newValue, index, index + 1);
1448
+ const clone = cloneList(list);
1449
+ if (index === -1) return clone.fill(newValue, index);
1450
+ return clone.fill(newValue, index, index + 1);
1349
1451
  }
1350
1452
 
1351
1453
  const update = curry(updateFn);
@@ -1358,12 +1460,6 @@ function lensPath(key) {
1358
1460
  return lens(path(key), assocPath(key));
1359
1461
  }
1360
1462
 
1361
- function prop(propToFind, obj) {
1362
- if (arguments.length === 1) return _obj => prop(propToFind, _obj);
1363
- if (!obj) return undefined;
1364
- return obj[propToFind];
1365
- }
1366
-
1367
1463
  function lensProp(key) {
1368
1464
  return lens(prop(key), assoc(key));
1369
1465
  }
@@ -1463,7 +1559,7 @@ function moveFn(fromIndex, toIndex, list) {
1463
1559
  }
1464
1560
 
1465
1561
  if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
1466
- const clone = list.slice();
1562
+ const clone = cloneList(list);
1467
1563
  clone[fromIndex] = list[toIndex];
1468
1564
  clone[toIndex] = list[fromIndex];
1469
1565
  return clone;
@@ -1587,13 +1683,13 @@ function partitionObject(predicate, iterable) {
1587
1683
  });
1588
1684
  return [yes, no];
1589
1685
  }
1590
- function partitionArray(predicate, list) {
1686
+ function partitionArray(predicate, list, indexed = false) {
1591
1687
  const yes = [];
1592
1688
  const no = [];
1593
1689
  let counter = -1;
1594
1690
 
1595
1691
  while (counter++ < list.length - 1) {
1596
- if (predicate(list[counter])) {
1692
+ if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) {
1597
1693
  yes.push(list[counter]);
1598
1694
  } else {
1599
1695
  no.push(list[counter]);
@@ -1617,8 +1713,8 @@ function pathEqFn(pathToSearch, target, input) {
1617
1713
 
1618
1714
  const pathEq = curry(pathEqFn);
1619
1715
 
1620
- function pathOrFn(defaultValue, list, obj) {
1621
- return defaultTo(defaultValue, path(list, obj));
1716
+ function pathOrFn(defaultValue, pathInput, obj) {
1717
+ return defaultTo(defaultValue, path(pathInput, obj));
1622
1718
  }
1623
1719
 
1624
1720
  const pathOr = curry(pathOrFn);
@@ -1806,13 +1902,12 @@ const slice = curry(sliceFn);
1806
1902
 
1807
1903
  function sort(sortFn, list) {
1808
1904
  if (arguments.length === 1) return _list => sort(sortFn, _list);
1809
- const clone = list.slice();
1810
- return clone.sort(sortFn);
1905
+ return cloneList(list).sort(sortFn);
1811
1906
  }
1812
1907
 
1813
1908
  function sortBy(sortFn, list) {
1814
1909
  if (arguments.length === 1) return _list => sortBy(sortFn, _list);
1815
- const clone = list.slice();
1910
+ const clone = cloneList(list);
1816
1911
  return clone.sort((a, b) => {
1817
1912
  const aSortResult = sortFn(a);
1818
1913
  const bSortResult = sortFn(b);
@@ -1894,9 +1989,22 @@ function splitWhen(predicate, input) {
1894
1989
  return [preFound, postFound];
1895
1990
  }
1896
1991
 
1897
- function startsWith(target, str) {
1898
- if (arguments.length === 1) return _str => startsWith(target, _str);
1899
- return str.startsWith(target);
1992
+ function startsWith(target, iterable) {
1993
+ if (arguments.length === 1) return _iterable => startsWith(target, _iterable);
1994
+
1995
+ if (typeof iterable === 'string') {
1996
+ return iterable.startsWith(target);
1997
+ }
1998
+
1999
+ if (!_isArray(target)) return false;
2000
+ let correct = true;
2001
+ const filtered = target.filter((x, index) => {
2002
+ if (!correct) return false;
2003
+ const result = equals(x, iterable[index]);
2004
+ if (!result) correct = false;
2005
+ return result;
2006
+ });
2007
+ return filtered.length === target.length;
1900
2008
  }
1901
2009
 
1902
2010
  function subtract(a, b) {
@@ -2046,15 +2154,36 @@ function tryCatch(fn, fallback) {
2046
2154
  };
2047
2155
  }
2048
2156
 
2157
+ function unapply(fn) {
2158
+ return function (...args) {
2159
+ return fn.call(this, args);
2160
+ };
2161
+ }
2162
+
2049
2163
  function union(x, y) {
2050
2164
  if (arguments.length === 1) return _y => union(x, _y);
2051
- const toReturn = x.slice();
2165
+ const toReturn = cloneList(x);
2052
2166
  y.forEach(yInstance => {
2053
2167
  if (!includes(yInstance, x)) toReturn.push(yInstance);
2054
2168
  });
2055
2169
  return toReturn;
2056
2170
  }
2057
2171
 
2172
+ function includesWith(predicate, target, list) {
2173
+ let willReturn = false;
2174
+ let index = -1;
2175
+
2176
+ while (++index < list.length && !willReturn) {
2177
+ const value = list[index];
2178
+
2179
+ if (predicate(target, value)) {
2180
+ willReturn = true;
2181
+ }
2182
+ }
2183
+
2184
+ return willReturn;
2185
+ }
2186
+
2058
2187
  function uniqWith(predicate, list) {
2059
2188
  if (arguments.length === 1) return _list => uniqWith(predicate, _list);
2060
2189
  let index = -1;
@@ -2062,9 +2191,8 @@ function uniqWith(predicate, list) {
2062
2191
 
2063
2192
  while (++index < list.length) {
2064
2193
  const value = list[index];
2065
- const flag = any(x => predicate(value, x), willReturn);
2066
2194
 
2067
- if (!flag) {
2195
+ if (!includesWith(predicate, value, willReturn)) {
2068
2196
  willReturn.push(value);
2069
2197
  }
2070
2198
  }
@@ -2134,7 +2262,7 @@ function without(matchAgainst, source) {
2134
2262
  return _source => without(matchAgainst, _source);
2135
2263
  }
2136
2264
 
2137
- return reduce((prev, current) => includesArray(current, matchAgainst) ? prev : prev.concat(current), [], source);
2265
+ return reduce((prev, current) => _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current), [], source);
2138
2266
  }
2139
2267
 
2140
2268
  function xor(a, b) {
@@ -2170,6 +2298,8 @@ const zipWith = curry(zipWithFn);
2170
2298
 
2171
2299
  exports.F = F;
2172
2300
  exports.T = T;
2301
+ exports._indexOf = _indexOf;
2302
+ exports._lastIndexOf = _lastIndexOf;
2173
2303
  exports.add = add;
2174
2304
  exports.adjust = adjust;
2175
2305
  exports.all = all;
@@ -2179,9 +2309,11 @@ exports.and = and;
2179
2309
  exports.any = any;
2180
2310
  exports.anyPass = anyPass;
2181
2311
  exports.append = append;
2312
+ exports.apply = apply;
2182
2313
  exports.applySpec = applySpec;
2183
2314
  exports.assoc = assoc;
2184
2315
  exports.assocPath = assocPath;
2316
+ exports.bind = bind;
2185
2317
  exports.both = both;
2186
2318
  exports.chain = chain;
2187
2319
  exports.clamp = clamp;
@@ -2232,7 +2364,6 @@ exports.identity = identity;
2232
2364
  exports.ifElse = ifElse;
2233
2365
  exports.inc = inc;
2234
2366
  exports.includes = includes;
2235
- exports.includesArray = includesArray;
2236
2367
  exports.indexBy = indexBy;
2237
2368
  exports.indexOf = indexOf;
2238
2369
  exports.init = init;
@@ -2252,6 +2383,7 @@ exports.lensPath = lensPath;
2252
2383
  exports.lensProp = lensProp;
2253
2384
  exports.map = map;
2254
2385
  exports.mapArray = mapArray;
2386
+ exports.mapObjIndexed = mapObjIndexed;
2255
2387
  exports.mapObject = mapObject;
2256
2388
  exports.match = match;
2257
2389
  exports.mathMod = mathMod;
@@ -2333,6 +2465,7 @@ exports.transpose = transpose;
2333
2465
  exports.trim = trim;
2334
2466
  exports.tryCatch = tryCatch;
2335
2467
  exports.type = type;
2468
+ exports.unapply = unapply;
2336
2469
  exports.union = union;
2337
2470
  exports.uniq = uniq;
2338
2471
  exports.uniqWith = uniqWith;