rambda 6.8.3 → 7.0.2

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 +95 -0
  2. package/README.md +4157 -4921
  3. package/dist/rambda.esm.js +336 -209
  4. package/dist/rambda.js +340 -209
  5. package/dist/rambda.mjs +336 -209
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +203 -284
  8. package/index.d.ts +194 -275
  9. package/package.json +119 -95
  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 +5 -0
  18. package/src/_internals/isTruthy.js +5 -5
  19. package/src/_internals/set.js +35 -0
  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 -22
  77. package/src/indexBy.js +11 -11
  78. package/src/indexOf.js +5 -12
  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 +3 -3
  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 +7 -10
  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 +5 -5
  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.mjs 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.slice();
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.slice();
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.slice();
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, list) {
433
- if (arguments.length === 1) return _list => map(fn, _list);
434
- if (list === undefined) return [];
435
- if (_isArray(list)) return mapArray(fn, list);
436
- return mapObject(fn, list);
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 (typeOf === 'boolean') {
492
- return 'Boolean';
493
- } else if (typeOf === 'number') {
494
- return Number.isNaN(input) ? 'NaN' : 'Number';
495
- } else if (typeOf === 'string') {
496
- return 'String';
497
- } else if (_isArray(input)) {
498
- return 'Array';
499
- } else if (typeOf === 'symbol') {
500
- return 'Symbol';
501
- } else if (input instanceof RegExp) {
502
- return 'RegExp';
503
- }
504
-
505
- const asStr = input && input.toString ? input.toString() : '';
506
- if (['true', 'false'].includes(asStr)) return 'Boolean';
507
- if (!Number.isNaN(Number(asStr))) return 'Number';
508
- if (asStr.startsWith('async')) return 'Async';
509
- if (asStr === '[object Promise]') return 'Promise';
510
- if (typeOf === 'function') return 'Function';
511
- if (input instanceof String) return 'String';
512
- return 'Object';
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,44 +690,68 @@ function equals(a, b) {
613
690
  return false;
614
691
  }
615
692
 
616
- function includesArray(valueToFind, input) {
617
- let index = -1;
693
+ function includes(valueToFind, iterable) {
694
+ if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
618
695
 
619
- while (++index < input.length) {
620
- if (equals(input[index], valueToFind)) {
621
- return true;
622
- }
696
+ if (typeof iterable === 'string') {
697
+ return iterable.includes(valueToFind);
623
698
  }
624
699
 
625
- return false;
700
+ if (!iterable) {
701
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
702
+ }
703
+
704
+ if (!_isArray(iterable)) return false;
705
+ return _indexOf(valueToFind, iterable) > -1;
626
706
  }
627
- function includes(valueToFind, input) {
628
- if (arguments.length === 1) return _input => includes(valueToFind, _input);
629
707
 
630
- if (typeof input === 'string') {
631
- return input.includes(valueToFind);
708
+ class _Set {
709
+ constructor() {
710
+ this.set = new Set();
711
+ this.items = {};
632
712
  }
633
713
 
634
- if (!input) {
635
- throw new TypeError(`Cannot read property \'indexOf\' of ${input}`);
636
- }
714
+ checkUniqueness(item) {
715
+ const type$1 = type(item);
637
716
 
638
- if (!_isArray(input)) return false;
639
- return includesArray(valueToFind, input);
640
- }
717
+ if (['Null', 'Undefined', 'NaN'].includes(type$1)) {
718
+ if (type$1 in this.items) {
719
+ return false;
720
+ }
641
721
 
642
- function uniq(list) {
643
- let index = -1;
644
- const willReturn = [];
722
+ this.items[type$1] = true;
723
+ return true;
724
+ }
645
725
 
646
- while (++index < list.length) {
647
- const value = list[index];
726
+ if (!['Object', 'Array'].includes(type$1)) {
727
+ const prevSize = this.set.size;
728
+ this.set.add(item);
729
+ return this.set.size !== prevSize;
730
+ }
648
731
 
649
- if (!includes(value, willReturn)) {
650
- willReturn.push(value);
732
+ if (!(type$1 in this.items)) {
733
+ this.items[type$1] = [item];
734
+ return true;
735
+ }
736
+
737
+ if (_indexOf(item, this.items[type$1]) === -1) {
738
+ this.items[type$1].push(item);
739
+ return true;
651
740
  }
741
+
742
+ return false;
652
743
  }
653
744
 
745
+ }
746
+
747
+ function uniq(list) {
748
+ const set = new _Set();
749
+ const willReturn = [];
750
+ list.forEach(item => {
751
+ if (set.checkUniqueness(item)) {
752
+ willReturn.push(item);
753
+ }
754
+ });
654
755
  return willReturn;
655
756
  }
656
757
 
@@ -801,17 +902,33 @@ function either(firstPredicate, secondPredicate) {
801
902
  return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
802
903
  }
803
904
 
804
- function endsWith(target, str) {
805
- if (arguments.length === 1) return _str => endsWith(target, _str);
806
- return str.endsWith(target);
807
- }
905
+ function endsWith(target, iterable) {
906
+ if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
808
907
 
809
- function eqPropsFn(prop, obj1, obj2) {
810
- if (!obj1 || !obj2) {
811
- throw new Error('wrong object inputs are passed to R.eqProps');
908
+ if (typeof iterable === 'string') {
909
+ return iterable.endsWith(target);
812
910
  }
813
911
 
814
- return equals(obj1[prop], obj2[prop]);
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));
815
932
  }
816
933
 
817
934
  const eqProps = curry(eqPropsFn);
@@ -900,12 +1017,13 @@ function filterArray(predicate, list, indexed = false) {
900
1017
  return willReturn;
901
1018
  }
902
1019
  function filter(predicate, iterable) {
903
- if (arguments.length === 1) {
904
- return _iterable => filter(predicate, _iterable);
1020
+ if (arguments.length === 1) return _iterable => filter(predicate, _iterable);
1021
+
1022
+ if (!iterable) {
1023
+ throw new Error('Incorrect iterable input');
905
1024
  }
906
1025
 
907
- if (!iterable) return [];
908
- if (_isArray(iterable)) return filterArray(predicate, iterable);
1026
+ if (_isArray(iterable)) return filterArray(predicate, iterable, false);
909
1027
  return filterObject(predicate, iterable);
910
1028
  }
911
1029
 
@@ -991,7 +1109,7 @@ function flipFn(fn) {
991
1109
  return fn(input[1], input[0], input[2], input[3]);
992
1110
  }
993
1111
 
994
- throw new Error('R.flip doesn\'t work with arity > 4');
1112
+ throw new Error("R.flip doesn't work with arity > 4");
995
1113
  };
996
1114
  }
997
1115
 
@@ -1057,7 +1175,7 @@ function groupBy(groupFn, list) {
1057
1175
 
1058
1176
  function groupWith(compareFn, list) {
1059
1177
  if (!_isArray(list)) throw new TypeError('list.reduce is not a function');
1060
- const clone = list.slice();
1178
+ const clone = cloneList(list);
1061
1179
  if (list.length === 1) return [clone];
1062
1180
  const toReturn = [];
1063
1181
  let holder = [];
@@ -1118,12 +1236,12 @@ function path(pathInput, obj) {
1118
1236
  return willReturn;
1119
1237
  }
1120
1238
 
1121
- function hasPath(maybePath, obj) {
1239
+ function hasPath(pathInput, obj) {
1122
1240
  if (arguments.length === 1) {
1123
- return objHolder => hasPath(maybePath, objHolder);
1241
+ return objHolder => hasPath(pathInput, objHolder);
1124
1242
  }
1125
1243
 
1126
- return path(maybePath, obj) !== undefined;
1244
+ return path(pathInput, obj) !== undefined;
1127
1245
  }
1128
1246
 
1129
1247
  function head(listOrString) {
@@ -1145,8 +1263,8 @@ function identical(a, b) {
1145
1263
  return _objectIs$1(a, b);
1146
1264
  }
1147
1265
 
1148
- function identity(input) {
1149
- return input;
1266
+ function identity(x) {
1267
+ return x;
1150
1268
  }
1151
1269
 
1152
1270
  function ifElseFn(condition, onTrue, onFalse) {
@@ -1197,21 +1315,10 @@ function indexBy(condition, list) {
1197
1315
 
1198
1316
  function indexOf(valueToFind, list) {
1199
1317
  if (arguments.length === 1) {
1200
- return _list => indexOf(valueToFind, _list);
1318
+ return _list => _indexOf(valueToFind, _list);
1201
1319
  }
1202
1320
 
1203
- let index = -1;
1204
- const {
1205
- length
1206
- } = list;
1207
-
1208
- while (++index < length) {
1209
- if (list[index] === valueToFind) {
1210
- return index;
1211
- }
1212
- }
1213
-
1214
- return -1;
1321
+ return _indexOf(valueToFind, list);
1215
1322
  }
1216
1323
 
1217
1324
  function baseSlice(array, start, end) {
@@ -1305,25 +1412,18 @@ function last(listOrString) {
1305
1412
  return listOrString[listOrString.length - 1];
1306
1413
  }
1307
1414
 
1308
- function lastIndexOf(target, list) {
1309
- if (arguments.length === 1) return _list => lastIndexOf(target, _list);
1310
- let index = list.length;
1311
-
1312
- while (--index > 0) {
1313
- if (equals(list[index], target)) {
1314
- return index;
1315
- }
1415
+ function lastIndexOf(valueToFind, list) {
1416
+ if (arguments.length === 1) {
1417
+ return _list => _lastIndexOf(valueToFind, _list);
1316
1418
  }
1317
1419
 
1318
- return -1;
1420
+ return _lastIndexOf(valueToFind, list);
1319
1421
  }
1320
1422
 
1321
1423
  function length(x) {
1322
- if (!x && x !== '' || x.length === undefined) {
1323
- return NaN;
1324
- }
1325
-
1326
- return x.length;
1424
+ if (_isArray(x)) return x.length;
1425
+ if (typeof x === 'string') return x.length;
1426
+ return NaN;
1327
1427
  }
1328
1428
 
1329
1429
  function lens(getter, setter) {
@@ -1341,8 +1441,9 @@ function nth(index, list) {
1341
1441
  }
1342
1442
 
1343
1443
  function updateFn(index, newValue, list) {
1344
- const arrClone = list.slice();
1345
- return arrClone.fill(newValue, index, index + 1);
1444
+ const clone = cloneList(list);
1445
+ if (index === -1) return clone.fill(newValue, index);
1446
+ return clone.fill(newValue, index, index + 1);
1346
1447
  }
1347
1448
 
1348
1449
  const update = curry(updateFn);
@@ -1355,12 +1456,6 @@ function lensPath(key) {
1355
1456
  return lens(path(key), assocPath(key));
1356
1457
  }
1357
1458
 
1358
- function prop(propToFind, obj) {
1359
- if (arguments.length === 1) return _obj => prop(propToFind, _obj);
1360
- if (!obj) return undefined;
1361
- return obj[propToFind];
1362
- }
1363
-
1364
1459
  function lensProp(key) {
1365
1460
  return lens(prop(key), assoc(key));
1366
1461
  }
@@ -1460,7 +1555,7 @@ function moveFn(fromIndex, toIndex, list) {
1460
1555
  }
1461
1556
 
1462
1557
  if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
1463
- const clone = list.slice();
1558
+ const clone = cloneList(list);
1464
1559
  clone[fromIndex] = list[toIndex];
1465
1560
  clone[toIndex] = list[fromIndex];
1466
1561
  return clone;
@@ -1614,8 +1709,8 @@ function pathEqFn(pathToSearch, target, input) {
1614
1709
 
1615
1710
  const pathEq = curry(pathEqFn);
1616
1711
 
1617
- function pathOrFn(defaultValue, list, obj) {
1618
- return defaultTo(defaultValue, path(list, obj));
1712
+ function pathOrFn(defaultValue, pathInput, obj) {
1713
+ return defaultTo(defaultValue, path(pathInput, obj));
1619
1714
  }
1620
1715
 
1621
1716
  const pathOr = curry(pathOrFn);
@@ -1803,13 +1898,12 @@ const slice = curry(sliceFn);
1803
1898
 
1804
1899
  function sort(sortFn, list) {
1805
1900
  if (arguments.length === 1) return _list => sort(sortFn, _list);
1806
- const clone = list.slice();
1807
- return clone.sort(sortFn);
1901
+ return cloneList(list).sort(sortFn);
1808
1902
  }
1809
1903
 
1810
1904
  function sortBy(sortFn, list) {
1811
1905
  if (arguments.length === 1) return _list => sortBy(sortFn, _list);
1812
- const clone = list.slice();
1906
+ const clone = cloneList(list);
1813
1907
  return clone.sort((a, b) => {
1814
1908
  const aSortResult = sortFn(a);
1815
1909
  const bSortResult = sortFn(b);
@@ -1891,9 +1985,22 @@ function splitWhen(predicate, input) {
1891
1985
  return [preFound, postFound];
1892
1986
  }
1893
1987
 
1894
- function startsWith(target, str) {
1895
- if (arguments.length === 1) return _str => startsWith(target, _str);
1896
- return str.startsWith(target);
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;
1897
2004
  }
1898
2005
 
1899
2006
  function subtract(a, b) {
@@ -2043,15 +2150,36 @@ function tryCatch(fn, fallback) {
2043
2150
  };
2044
2151
  }
2045
2152
 
2153
+ function unapply(fn) {
2154
+ return function (...args) {
2155
+ return fn.call(this, args);
2156
+ };
2157
+ }
2158
+
2046
2159
  function union(x, y) {
2047
2160
  if (arguments.length === 1) return _y => union(x, _y);
2048
- const toReturn = x.slice();
2161
+ const toReturn = cloneList(x);
2049
2162
  y.forEach(yInstance => {
2050
2163
  if (!includes(yInstance, x)) toReturn.push(yInstance);
2051
2164
  });
2052
2165
  return toReturn;
2053
2166
  }
2054
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
+
2055
2183
  function uniqWith(predicate, list) {
2056
2184
  if (arguments.length === 1) return _list => uniqWith(predicate, _list);
2057
2185
  let index = -1;
@@ -2059,9 +2187,8 @@ function uniqWith(predicate, list) {
2059
2187
 
2060
2188
  while (++index < list.length) {
2061
2189
  const value = list[index];
2062
- const flag = any(x => predicate(value, x), willReturn);
2063
2190
 
2064
- if (!flag) {
2191
+ if (!includesWith(predicate, value, willReturn)) {
2065
2192
  willReturn.push(value);
2066
2193
  }
2067
2194
  }
@@ -2131,7 +2258,7 @@ function without(matchAgainst, source) {
2131
2258
  return _source => without(matchAgainst, _source);
2132
2259
  }
2133
2260
 
2134
- return reduce((prev, current) => includesArray(current, matchAgainst) ? prev : prev.concat(current), [], source);
2261
+ return reduce((prev, current) => _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current), [], source);
2135
2262
  }
2136
2263
 
2137
2264
  function xor(a, b) {
@@ -2165,4 +2292,4 @@ function zipWithFn(fn, x, y) {
2165
2292
 
2166
2293
  const zipWith = curry(zipWithFn);
2167
2294
 
2168
- export { F, T, 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, includesArray, 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 };