rambda 6.9.0 → 7.0.3

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 (188) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/README.md +3827 -4905
  3. package/dist/rambda.esm.js +301 -208
  4. package/dist/rambda.js +306 -209
  5. package/dist/rambda.mjs +303 -210
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +207 -285
  8. package/index.d.ts +198 -276
  9. package/package.json +119 -98
  10. package/src/F.js +1 -1
  11. package/src/T.js +1 -1
  12. package/src/_internals/_isInteger.js +1 -1
  13. package/src/_internals/_objectIs.js +2 -2
  14. package/src/_internals/baseSlice.js +6 -8
  15. package/src/_internals/cloneList.js +3 -0
  16. package/src/_internals/isFalsy.js +5 -5
  17. package/src/_internals/isObject.js +3 -3
  18. package/src/_internals/isTruthy.js +5 -5
  19. package/src/_internals/set.js +4 -4
  20. package/src/add.js +1 -1
  21. package/src/adjust.js +5 -6
  22. package/src/all.js +3 -3
  23. package/src/allPass.js +4 -4
  24. package/src/always.js +1 -1
  25. package/src/and.js +1 -1
  26. package/src/any.js +3 -3
  27. package/src/anyPass.js +4 -4
  28. package/src/append.js +4 -2
  29. package/src/apply.js +7 -0
  30. package/src/applySpec.js +33 -59
  31. package/src/assoc.js +3 -7
  32. package/src/assocPath.js +22 -25
  33. package/src/bind.js +9 -0
  34. package/src/both.js +1 -1
  35. package/src/chain.js +2 -2
  36. package/src/clamp.js +6 -6
  37. package/src/clone.js +10 -10
  38. package/src/complement.js +1 -1
  39. package/src/compose.js +6 -6
  40. package/src/concat.js +2 -2
  41. package/src/cond.js +3 -3
  42. package/src/converge.js +11 -11
  43. package/src/curry.js +2 -2
  44. package/src/curryN.js +61 -81
  45. package/src/defaultTo.js +5 -8
  46. package/src/difference.js +3 -3
  47. package/src/dissoc.js +4 -4
  48. package/src/divide.js +1 -1
  49. package/src/drop.js +1 -1
  50. package/src/dropLast.js +5 -5
  51. package/src/dropLastWhile.js +12 -12
  52. package/src/dropRepeats.js +6 -6
  53. package/src/dropRepeatsWith.js +7 -7
  54. package/src/dropWhile.js +9 -9
  55. package/src/either.js +2 -2
  56. package/src/endsWith.js +20 -3
  57. package/src/eqProps.js +5 -10
  58. package/src/equals.js +119 -38
  59. package/src/evolve.js +23 -21
  60. package/src/filter.js +18 -18
  61. package/src/find.js +4 -4
  62. package/src/findIndex.js +3 -3
  63. package/src/findLast.js +4 -4
  64. package/src/findLastIndex.js +3 -3
  65. package/src/flatten.js +6 -6
  66. package/src/flip.js +11 -15
  67. package/src/forEach.js +10 -12
  68. package/src/fromPairs.js +2 -2
  69. package/src/groupBy.js +6 -6
  70. package/src/groupWith.js +11 -12
  71. package/src/hasPath.js +5 -5
  72. package/src/head.js +3 -3
  73. package/src/identical.js +1 -1
  74. package/src/identity.js +2 -2
  75. package/src/ifElse.js +3 -5
  76. package/src/includes.js +11 -10
  77. package/src/indexBy.js +11 -11
  78. package/src/indexOf.js +3 -25
  79. package/src/init.js +2 -4
  80. package/src/intersection.js +3 -3
  81. package/src/intersperse.js +5 -5
  82. package/src/is.js +2 -2
  83. package/src/isEmpty.js +5 -5
  84. package/src/isFunction.js +3 -3
  85. package/src/isNil.js +1 -1
  86. package/src/isPromise.js +3 -3
  87. package/src/join.js +1 -1
  88. package/src/keys.js +1 -1
  89. package/src/last.js +4 -4
  90. package/src/lastIndexOf.js +5 -11
  91. package/src/length.js +6 -5
  92. package/src/lens.js +3 -3
  93. package/src/lensIndex.js +4 -4
  94. package/src/lensProp.js +4 -4
  95. package/src/map.js +17 -18
  96. package/src/match.js +1 -1
  97. package/src/mathMod.js +2 -2
  98. package/src/max.js +1 -1
  99. package/src/maxBy.js +2 -4
  100. package/src/maybe.js +2 -4
  101. package/src/mean.js +2 -2
  102. package/src/median.js +12 -10
  103. package/src/merge.js +2 -4
  104. package/src/mergeAll.js +3 -3
  105. package/src/mergeDeepRight.js +8 -8
  106. package/src/mergeLeft.js +2 -2
  107. package/src/min.js +1 -1
  108. package/src/minBy.js +2 -4
  109. package/src/modulo.js +1 -1
  110. package/src/move.js +7 -8
  111. package/src/multiply.js +1 -1
  112. package/src/negate.js +1 -1
  113. package/src/none.js +4 -4
  114. package/src/not.js +1 -1
  115. package/src/nth.js +4 -4
  116. package/src/objOf.js +3 -3
  117. package/src/of.js +2 -2
  118. package/src/omit.js +5 -5
  119. package/src/once.js +6 -6
  120. package/src/or.js +1 -1
  121. package/src/over.js +3 -5
  122. package/src/partial.js +3 -3
  123. package/src/partition.js +17 -15
  124. package/src/path.js +6 -6
  125. package/src/pathEq.js +4 -6
  126. package/src/pathOr.js +5 -7
  127. package/src/paths.js +3 -3
  128. package/src/pick.js +5 -5
  129. package/src/pickAll.js +6 -6
  130. package/src/pipe.js +3 -3
  131. package/src/pluck.js +4 -4
  132. package/src/prepend.js +3 -3
  133. package/src/product.js +2 -2
  134. package/src/prop.js +2 -2
  135. package/src/propEq.js +3 -5
  136. package/src/propIs.js +4 -6
  137. package/src/propOr.js +4 -6
  138. package/src/props.js +6 -6
  139. package/src/range.js +4 -4
  140. package/src/reduce.js +7 -11
  141. package/src/reject.js +2 -2
  142. package/src/repeat.js +2 -2
  143. package/src/replace.js +2 -4
  144. package/src/reverse.js +3 -4
  145. package/src/set.js +5 -9
  146. package/src/slice.js +2 -4
  147. package/src/sort.js +4 -4
  148. package/src/sortBy.js +4 -2
  149. package/src/split.js +1 -1
  150. package/src/splitAt.js +9 -9
  151. package/src/splitEvery.js +8 -6
  152. package/src/splitWhen.js +10 -10
  153. package/src/startsWith.js +20 -3
  154. package/src/subtract.js +1 -1
  155. package/src/sum.js +1 -1
  156. package/src/symmetricDifference.js +9 -7
  157. package/src/tail.js +2 -2
  158. package/src/take.js +2 -4
  159. package/src/takeLast.js +2 -4
  160. package/src/takeLastWhile.js +7 -7
  161. package/src/takeWhile.js +8 -8
  162. package/src/tap.js +1 -1
  163. package/src/test.js +5 -3
  164. package/src/times.js +4 -4
  165. package/src/toLower.js +1 -1
  166. package/src/toPairs.js +1 -1
  167. package/src/toString.js +1 -1
  168. package/src/toUpper.js +1 -1
  169. package/src/transpose.js +4 -3
  170. package/src/trim.js +1 -1
  171. package/src/tryCatch.js +5 -5
  172. package/src/type.js +7 -29
  173. package/src/unapply.js +5 -0
  174. package/src/union.js +4 -3
  175. package/src/uniq.js +2 -2
  176. package/src/uniqWith.js +18 -7
  177. package/src/unless.js +3 -3
  178. package/src/update.js +6 -8
  179. package/src/values.js +2 -2
  180. package/src/view.js +2 -2
  181. package/src/when.js +2 -4
  182. package/src/where.js +5 -5
  183. package/src/whereEq.js +9 -7
  184. package/src/without.js +1 -1
  185. package/src/xor.js +2 -2
  186. package/src/zip.js +3 -3
  187. package/src/zipObj.js +4 -6
  188. 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) {
@@ -433,11 +453,15 @@ function mapObject(fn, obj) {
433
453
  return willReturn;
434
454
  }
435
455
  const mapObjIndexed = mapObject;
436
- function map(fn, list) {
437
- if (arguments.length === 1) return _list => map(fn, _list);
438
- if (list === undefined) return [];
439
- if (_isArray(list)) return mapArray(fn, list);
440
- return mapObject(fn, list);
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);
441
465
  }
442
466
 
443
467
  function max(x, y) {
@@ -486,34 +510,83 @@ function defaultTo(defaultArgument, input) {
486
510
  }
487
511
 
488
512
  function type(input) {
489
- const typeOf = typeof input;
490
-
491
513
  if (input === null) {
492
514
  return 'Null';
493
515
  } else if (input === undefined) {
494
516
  return 'Undefined';
495
- } else if (typeOf === 'boolean') {
496
- return 'Boolean';
497
- } else if (typeOf === 'number') {
498
- return Number.isNaN(input) ? 'NaN' : 'Number';
499
- } else if (typeOf === 'string') {
500
- return 'String';
501
- } else if (_isArray(input)) {
502
- return 'Array';
503
- } else if (typeOf === 'symbol') {
504
- return 'Symbol';
505
- } else if (input instanceof RegExp) {
506
- return 'RegExp';
507
- }
508
-
509
- const asStr = input && input.toString ? input.toString() : '';
510
- if (['true', 'false'].includes(asStr)) return 'Boolean';
511
- if (!Number.isNaN(Number(asStr))) return 'Number';
512
- if (asStr.startsWith('async')) return 'Async';
513
- if (asStr === '[object Promise]') return 'Promise';
514
- if (typeOf === 'function') return 'Function';
515
- if (input instanceof String) return 'String';
516
- 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;
517
590
  }
518
591
 
519
592
  function parseError(maybeError) {
@@ -593,6 +666,10 @@ function equals(a, b) {
593
666
  return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
594
667
  }
595
668
 
669
+ if (aType === 'Set') {
670
+ return _equalsSets(a, b);
671
+ }
672
+
596
673
  if (aType === 'Object') {
597
674
  const aKeys = Object.keys(a);
598
675
 
@@ -617,48 +694,19 @@ function equals(a, b) {
617
694
  return false;
618
695
  }
619
696
 
620
- function _indexOf(valueToFind, list) {
621
- if (!_isArray(list)) {
622
- throw new Error(`Cannot read property 'indexOf' of ${list}`);
623
- }
624
-
625
- const typeOfValue = type(valueToFind);
626
- if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
627
- let index = -1;
628
- let foundIndex = -1;
629
- const {
630
- length
631
- } = list;
632
-
633
- while (++index < length && foundIndex === -1) {
634
- if (equals(list[index], valueToFind)) {
635
- foundIndex = index;
636
- }
637
- }
638
-
639
- return foundIndex;
640
- }
641
- function indexOf(valueToFind, list) {
642
- if (arguments.length === 1) {
643
- return _list => _indexOf(valueToFind, _list);
644
- }
645
-
646
- return _indexOf(valueToFind, list);
647
- }
648
-
649
- function includes(valueToFind, input) {
650
- if (arguments.length === 1) return _input => includes(valueToFind, _input);
697
+ function includes(valueToFind, iterable) {
698
+ if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
651
699
 
652
- if (typeof input === 'string') {
653
- return input.includes(valueToFind);
700
+ if (typeof iterable === 'string') {
701
+ return iterable.includes(valueToFind);
654
702
  }
655
703
 
656
- if (!input) {
657
- throw new TypeError(`Cannot read property \'indexOf\' of ${input}`);
704
+ if (!iterable) {
705
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
658
706
  }
659
707
 
660
- if (!_isArray(input)) return false;
661
- return _indexOf(valueToFind, input) > -1;
708
+ if (!_isArray(iterable)) return false;
709
+ return _indexOf(valueToFind, iterable) > -1;
662
710
  }
663
711
 
664
712
  class _Set {
@@ -858,17 +906,33 @@ function either(firstPredicate, secondPredicate) {
858
906
  return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
859
907
  }
860
908
 
861
- function endsWith(target, str) {
862
- if (arguments.length === 1) return _str => endsWith(target, _str);
863
- return str.endsWith(target);
864
- }
909
+ function endsWith(target, iterable) {
910
+ if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
865
911
 
866
- function eqPropsFn(prop, obj1, obj2) {
867
- if (!obj1 || !obj2) {
868
- throw new Error('wrong object inputs are passed to R.eqProps');
912
+ if (typeof iterable === 'string') {
913
+ return iterable.endsWith(target);
869
914
  }
870
915
 
871
- 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));
872
936
  }
873
937
 
874
938
  const eqProps = curry(eqPropsFn);
@@ -957,12 +1021,13 @@ function filterArray(predicate, list, indexed = false) {
957
1021
  return willReturn;
958
1022
  }
959
1023
  function filter(predicate, iterable) {
960
- if (arguments.length === 1) {
961
- 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');
962
1028
  }
963
1029
 
964
- if (!iterable) return [];
965
- if (_isArray(iterable)) return filterArray(predicate, iterable);
1030
+ if (_isArray(iterable)) return filterArray(predicate, iterable, false);
966
1031
  return filterObject(predicate, iterable);
967
1032
  }
968
1033
 
@@ -1048,7 +1113,7 @@ function flipFn(fn) {
1048
1113
  return fn(input[1], input[0], input[2], input[3]);
1049
1114
  }
1050
1115
 
1051
- throw new Error('R.flip doesn\'t work with arity > 4');
1116
+ throw new Error("R.flip doesn't work with arity > 4");
1052
1117
  };
1053
1118
  }
1054
1119
 
@@ -1114,7 +1179,7 @@ function groupBy(groupFn, list) {
1114
1179
 
1115
1180
  function groupWith(compareFn, list) {
1116
1181
  if (!_isArray(list)) throw new TypeError('list.reduce is not a function');
1117
- const clone = list.slice();
1182
+ const clone = cloneList(list);
1118
1183
  if (list.length === 1) return [clone];
1119
1184
  const toReturn = [];
1120
1185
  let holder = [];
@@ -1175,12 +1240,12 @@ function path(pathInput, obj) {
1175
1240
  return willReturn;
1176
1241
  }
1177
1242
 
1178
- function hasPath(maybePath, obj) {
1243
+ function hasPath(pathInput, obj) {
1179
1244
  if (arguments.length === 1) {
1180
- return objHolder => hasPath(maybePath, objHolder);
1245
+ return objHolder => hasPath(pathInput, objHolder);
1181
1246
  }
1182
1247
 
1183
- return path(maybePath, obj) !== undefined;
1248
+ return path(pathInput, obj) !== undefined;
1184
1249
  }
1185
1250
 
1186
1251
  function head(listOrString) {
@@ -1202,8 +1267,8 @@ function identical(a, b) {
1202
1267
  return _objectIs$1(a, b);
1203
1268
  }
1204
1269
 
1205
- function identity(input) {
1206
- return input;
1270
+ function identity(x) {
1271
+ return x;
1207
1272
  }
1208
1273
 
1209
1274
  function ifElseFn(condition, onTrue, onFalse) {
@@ -1252,6 +1317,14 @@ function indexBy(condition, list) {
1252
1317
  return toReturn;
1253
1318
  }
1254
1319
 
1320
+ function indexOf(valueToFind, list) {
1321
+ if (arguments.length === 1) {
1322
+ return _list => _indexOf(valueToFind, _list);
1323
+ }
1324
+
1325
+ return _indexOf(valueToFind, list);
1326
+ }
1327
+
1255
1328
  function baseSlice(array, start, end) {
1256
1329
  let index = -1;
1257
1330
  let {
@@ -1343,25 +1416,18 @@ function last(listOrString) {
1343
1416
  return listOrString[listOrString.length - 1];
1344
1417
  }
1345
1418
 
1346
- function lastIndexOf(target, list) {
1347
- if (arguments.length === 1) return _list => lastIndexOf(target, _list);
1348
- let index = list.length;
1349
-
1350
- while (--index > 0) {
1351
- if (equals(list[index], target)) {
1352
- return index;
1353
- }
1419
+ function lastIndexOf(valueToFind, list) {
1420
+ if (arguments.length === 1) {
1421
+ return _list => _lastIndexOf(valueToFind, _list);
1354
1422
  }
1355
1423
 
1356
- return -1;
1424
+ return _lastIndexOf(valueToFind, list);
1357
1425
  }
1358
1426
 
1359
1427
  function length(x) {
1360
- if (!x && x !== '' || x.length === undefined) {
1361
- return NaN;
1362
- }
1363
-
1364
- return x.length;
1428
+ if (_isArray(x)) return x.length;
1429
+ if (typeof x === 'string') return x.length;
1430
+ return NaN;
1365
1431
  }
1366
1432
 
1367
1433
  function lens(getter, setter) {
@@ -1379,8 +1445,9 @@ function nth(index, list) {
1379
1445
  }
1380
1446
 
1381
1447
  function updateFn(index, newValue, list) {
1382
- const arrClone = list.slice();
1383
- 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);
1384
1451
  }
1385
1452
 
1386
1453
  const update = curry(updateFn);
@@ -1393,12 +1460,6 @@ function lensPath(key) {
1393
1460
  return lens(path(key), assocPath(key));
1394
1461
  }
1395
1462
 
1396
- function prop(propToFind, obj) {
1397
- if (arguments.length === 1) return _obj => prop(propToFind, _obj);
1398
- if (!obj) return undefined;
1399
- return obj[propToFind];
1400
- }
1401
-
1402
1463
  function lensProp(key) {
1403
1464
  return lens(prop(key), assoc(key));
1404
1465
  }
@@ -1498,7 +1559,7 @@ function moveFn(fromIndex, toIndex, list) {
1498
1559
  }
1499
1560
 
1500
1561
  if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
1501
- const clone = list.slice();
1562
+ const clone = cloneList(list);
1502
1563
  clone[fromIndex] = list[toIndex];
1503
1564
  clone[toIndex] = list[fromIndex];
1504
1565
  return clone;
@@ -1519,10 +1580,10 @@ function none(predicate, list) {
1519
1580
  if (arguments.length === 1) return _list => none(predicate, _list);
1520
1581
 
1521
1582
  for (let i = 0; i < list.length; i++) {
1522
- if (!predicate(list[i])) return true;
1583
+ if (predicate(list[i])) return false;
1523
1584
  }
1524
1585
 
1525
- return false;
1586
+ return true;
1526
1587
  }
1527
1588
 
1528
1589
  function not(input) {
@@ -1652,8 +1713,8 @@ function pathEqFn(pathToSearch, target, input) {
1652
1713
 
1653
1714
  const pathEq = curry(pathEqFn);
1654
1715
 
1655
- function pathOrFn(defaultValue, list, obj) {
1656
- return defaultTo(defaultValue, path(list, obj));
1716
+ function pathOrFn(defaultValue, pathInput, obj) {
1717
+ return defaultTo(defaultValue, path(pathInput, obj));
1657
1718
  }
1658
1719
 
1659
1720
  const pathOr = curry(pathOrFn);
@@ -1841,13 +1902,12 @@ const slice = curry(sliceFn);
1841
1902
 
1842
1903
  function sort(sortFn, list) {
1843
1904
  if (arguments.length === 1) return _list => sort(sortFn, _list);
1844
- const clone = list.slice();
1845
- return clone.sort(sortFn);
1905
+ return cloneList(list).sort(sortFn);
1846
1906
  }
1847
1907
 
1848
1908
  function sortBy(sortFn, list) {
1849
1909
  if (arguments.length === 1) return _list => sortBy(sortFn, _list);
1850
- const clone = list.slice();
1910
+ const clone = cloneList(list);
1851
1911
  return clone.sort((a, b) => {
1852
1912
  const aSortResult = sortFn(a);
1853
1913
  const bSortResult = sortFn(b);
@@ -1929,9 +1989,22 @@ function splitWhen(predicate, input) {
1929
1989
  return [preFound, postFound];
1930
1990
  }
1931
1991
 
1932
- function startsWith(target, str) {
1933
- if (arguments.length === 1) return _str => startsWith(target, _str);
1934
- 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;
1935
2008
  }
1936
2009
 
1937
2010
  function subtract(a, b) {
@@ -2081,15 +2154,36 @@ function tryCatch(fn, fallback) {
2081
2154
  };
2082
2155
  }
2083
2156
 
2157
+ function unapply(fn) {
2158
+ return function (...args) {
2159
+ return fn.call(this, args);
2160
+ };
2161
+ }
2162
+
2084
2163
  function union(x, y) {
2085
2164
  if (arguments.length === 1) return _y => union(x, _y);
2086
- const toReturn = x.slice();
2165
+ const toReturn = cloneList(x);
2087
2166
  y.forEach(yInstance => {
2088
2167
  if (!includes(yInstance, x)) toReturn.push(yInstance);
2089
2168
  });
2090
2169
  return toReturn;
2091
2170
  }
2092
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
+
2093
2187
  function uniqWith(predicate, list) {
2094
2188
  if (arguments.length === 1) return _list => uniqWith(predicate, _list);
2095
2189
  let index = -1;
@@ -2097,9 +2191,8 @@ function uniqWith(predicate, list) {
2097
2191
 
2098
2192
  while (++index < list.length) {
2099
2193
  const value = list[index];
2100
- const flag = any(x => predicate(value, x), willReturn);
2101
2194
 
2102
- if (!flag) {
2195
+ if (!includesWith(predicate, value, willReturn)) {
2103
2196
  willReturn.push(value);
2104
2197
  }
2105
2198
  }
@@ -2206,6 +2299,7 @@ const zipWith = curry(zipWithFn);
2206
2299
  exports.F = F;
2207
2300
  exports.T = T;
2208
2301
  exports._indexOf = _indexOf;
2302
+ exports._lastIndexOf = _lastIndexOf;
2209
2303
  exports.add = add;
2210
2304
  exports.adjust = adjust;
2211
2305
  exports.all = all;
@@ -2215,9 +2309,11 @@ exports.and = and;
2215
2309
  exports.any = any;
2216
2310
  exports.anyPass = anyPass;
2217
2311
  exports.append = append;
2312
+ exports.apply = apply;
2218
2313
  exports.applySpec = applySpec;
2219
2314
  exports.assoc = assoc;
2220
2315
  exports.assocPath = assocPath;
2316
+ exports.bind = bind;
2221
2317
  exports.both = both;
2222
2318
  exports.chain = chain;
2223
2319
  exports.clamp = clamp;
@@ -2369,6 +2465,7 @@ exports.transpose = transpose;
2369
2465
  exports.trim = trim;
2370
2466
  exports.tryCatch = tryCatch;
2371
2467
  exports.type = type;
2468
+ exports.unapply = unapply;
2372
2469
  exports.union = union;
2373
2470
  exports.uniq = uniq;
2374
2471
  exports.uniqWith = uniqWith;