rambda 10.0.0-alpha.0 → 10.0.0-beta.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 (64) hide show
  1. package/CHANGELOG.md +124 -16
  2. package/README.md +5526 -1730
  3. package/dist/{rambda.esm.js → rambda.cjs} +663 -355
  4. package/dist/rambda.js +545 -456
  5. package/dist/rambda.umd.js +563 -357
  6. package/immutable.d.ts +321 -343
  7. package/index.d.ts +321 -343
  8. package/package.json +20 -13
  9. package/rambda.js +16 -1
  10. package/src/addProp.js +3 -0
  11. package/src/append.js +5 -5
  12. package/src/ascend.js +16 -0
  13. package/src/compact.js +12 -0
  14. package/src/concat.js +1 -1
  15. package/src/count.js +7 -7
  16. package/src/countBy.js +12 -12
  17. package/src/createObjectFromKeys.js +10 -0
  18. package/src/descend.js +10 -0
  19. package/src/dropLast.js +1 -3
  20. package/src/eqProps.js +1 -2
  21. package/src/equals.js +2 -2
  22. package/src/evolve.js +2 -23
  23. package/src/filter.js +14 -14
  24. package/src/find.js +10 -10
  25. package/src/findIndex.js +9 -9
  26. package/src/findLast.js +8 -8
  27. package/src/findLastIndex.js +8 -8
  28. package/src/findNth.js +16 -0
  29. package/src/groupBy.js +14 -13
  30. package/src/includes.js +12 -13
  31. package/src/interpolate.js +29 -0
  32. package/src/intersection.js +1 -1
  33. package/src/intersperse.js +12 -12
  34. package/src/join.js +1 -1
  35. package/src/mapAsync.js +3 -3
  36. package/src/mapKeys.js +11 -0
  37. package/src/mapObjectAsync.js +9 -9
  38. package/src/mapParallelAsync.js +3 -0
  39. package/src/match.js +5 -5
  40. package/src/modifyProp.js +20 -0
  41. package/src/objectIncludes.js +12 -0
  42. package/src/partition.js +13 -37
  43. package/src/partitionObject.js +15 -0
  44. package/src/permutations.js +40 -0
  45. package/src/pipeAsync.js +7 -6
  46. package/src/pluck.js +9 -9
  47. package/src/prepend.js +1 -1
  48. package/src/propSatisfies.js +1 -3
  49. package/src/range.js +35 -12
  50. package/src/reject.js +1 -1
  51. package/src/rejectObject.js +13 -0
  52. package/src/shuffle.js +13 -0
  53. package/src/sort.js +1 -1
  54. package/src/sortBy.js +12 -10
  55. package/src/sortObject.js +15 -0
  56. package/src/sortWith.js +8 -8
  57. package/src/split.js +2 -2
  58. package/src/splitEvery.js +11 -11
  59. package/src/takeLastWhile.js +18 -18
  60. package/src/tap.js +4 -4
  61. package/src/test.js +1 -1
  62. package/src/uniqBy.js +4 -4
  63. package/src/uniqWith.js +10 -10
  64. package/src/modifyPath.js +0 -30
@@ -4,6 +4,10 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.R = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
+ function addProp(key, value) {
8
+ return obj => ({ ...obj, [key]: value })
9
+ }
10
+
7
11
  function all(predicate) {
8
12
  return list => {
9
13
  for (let i = 0; i < list.length; i++) {
@@ -58,15 +62,32 @@
58
62
  }
59
63
  }
60
64
 
61
- const cloneList = list => Array.prototype.slice.call(list);
65
+ const cloneList$1 = list => Array.prototype.slice.call(list);
62
66
 
63
67
  function append(x) {
64
- return list=> {
65
- const clone = cloneList(list);
66
- clone.push(x);
68
+ return list => {
69
+ const clone = cloneList$1(list);
70
+ clone.push(x);
67
71
 
68
- return clone
69
- }
72
+ return clone
73
+ }
74
+ }
75
+
76
+ function createCompareFunction(a, b, winner, loser) {
77
+ if (a === b) {
78
+ return 0
79
+ }
80
+
81
+ return a < b ? winner : loser
82
+ }
83
+
84
+ function ascend(getFunction) {
85
+ return (a, b) => {
86
+ const aValue = getFunction(a);
87
+ const bValue = getFunction(b);
88
+
89
+ return createCompareFunction(aValue, bValue, -1, 1)
90
+ }
70
91
  }
71
92
 
72
93
  function checkObjectWithSpec(conditions) {
@@ -86,41 +107,100 @@
86
107
  }
87
108
  }
88
109
 
110
+ const { isArray } = Array;
111
+
112
+ function filter(predicate) {
113
+ return list => {
114
+ if (!list) {
115
+ throw new Error('Incorrect iterable input')
116
+ }
117
+ let index = 0;
118
+ const len = list.length;
119
+ const willReturn = [];
120
+
121
+ while (index < len) {
122
+ if (predicate(list[index], index)) {
123
+ willReturn.push(list[index]);
124
+ }
125
+
126
+ index++;
127
+ }
128
+
129
+ return willReturn
130
+ }
131
+ }
132
+
133
+ function reject(predicate) {
134
+ return list => filter(x => !predicate(x))(list)
135
+ }
136
+
137
+ function rejectObject(predicate) {
138
+ return obj => {
139
+ const willReturn = {};
140
+
141
+ for (const prop in obj) {
142
+ if (!predicate(obj[prop], prop, obj)) {
143
+ willReturn[prop] = obj[prop];
144
+ }
145
+ }
146
+
147
+ return willReturn
148
+ }
149
+ }
150
+
151
+ const isNullOrUndefined = x => x === null || x === undefined;
152
+
153
+ function compact(input){
154
+ if(isArray(input)){
155
+ return reject(isNullOrUndefined)(input)
156
+ }
157
+ return rejectObject(isNullOrUndefined)(input)
158
+ }
159
+
89
160
  function complement(fn) {
90
161
  return (...input) => !fn(...input)
91
162
  }
92
163
 
93
164
  function concat(x) {
94
- return y => typeof x === 'string' ? `${x}${y}` : [...x, ...y]
165
+ return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
95
166
  }
96
167
 
97
- const { isArray } = Array;
168
+ function count(predicate) {
169
+ return list => {
170
+ if (!isArray(list)) {
171
+ return 0
172
+ }
98
173
 
99
- function count(predicate, ) {
100
- return list => {
101
- if (!isArray(list)) {
102
- return 0
174
+ return list.filter(x => predicate(x)).length
103
175
  }
104
-
105
- return list.filter(x => predicate(x)).length
106
- }
107
176
  }
108
177
 
109
178
  function countBy(fn) {
110
- return list => {
111
- const willReturn = {};
179
+ return list => {
180
+ const willReturn = {};
112
181
 
113
- list.forEach(item => {
114
- const key = fn(item);
115
- if (!willReturn[key]) {
116
- willReturn[key] = 1;
117
- } else {
118
- willReturn[key]++;
119
- }
120
- });
182
+ list.forEach(item => {
183
+ const key = fn(item);
184
+ if (!willReturn[key]) {
185
+ willReturn[key] = 1;
186
+ } else {
187
+ willReturn[key]++;
188
+ }
189
+ });
121
190
 
122
- return willReturn
191
+ return willReturn
192
+ }
123
193
  }
194
+
195
+ function createObjectFromKeys(keys) {
196
+ return fn => {
197
+ const result = {};
198
+ keys.forEach((key, index) => {
199
+ result[key] = fn(key, index);
200
+ });
201
+
202
+ return result
203
+ }
124
204
  }
125
205
 
126
206
  function isFalsy(input) {
@@ -135,6 +215,15 @@
135
215
  return isFalsy(input) ? defaultArgument : input
136
216
  }
137
217
 
218
+ function descend(getFunction) {
219
+ return (a, b) => {
220
+ const aValue = getFunction(a);
221
+ const bValue = getFunction(b);
222
+
223
+ return createCompareFunction(aValue, bValue, 1, -1)
224
+ }
225
+ }
226
+
138
227
  function drop(howManyToDrop, listOrString) {
139
228
  if (arguments.length === 1) {
140
229
  return _list => drop(howManyToDrop, _list)
@@ -144,9 +233,7 @@
144
233
  }
145
234
 
146
235
  function dropLast(numberItems) {
147
- return list => numberItems > 0
148
- ? list.slice(0, -numberItems)
149
- : list.slice()
236
+ return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
150
237
  }
151
238
 
152
239
  function dropLastWhile(predicate) {
@@ -306,7 +393,7 @@
306
393
  }
307
394
 
308
395
  function equalsFn(a, b) {
309
- if (Object.is(a, b)) {
396
+ if (Object.is(a, b)) {
310
397
  return true
311
398
  }
312
399
 
@@ -415,19 +502,15 @@
415
502
  return false
416
503
  }
417
504
  function equals(a) {
418
- return b => equalsFn(a, b)
505
+ return b => equalsFn(a, b)
419
506
  }
420
507
 
421
508
  function eqBy(fn, a) {
422
509
  return b => equalsFn(fn(a), fn(b))
423
510
  }
424
511
 
425
- function prop(searchProperty) {
426
- return obj => (obj ? obj[searchProperty] : undefined)
427
- }
428
-
429
512
  function eqProps(property, objA) {
430
- return objB => equalsFn(prop(property)(objA), prop(property)(objB))
513
+ return objB => equalsFn( objA[property], objB[property] )
431
514
  }
432
515
 
433
516
  const { keys } = Object;
@@ -449,73 +532,30 @@
449
532
  }
450
533
  }
451
534
 
452
- function evolveFn(rules, obj) {
453
- return mapObject((x, prop) => {
454
- if (type(x) === 'Object') {
455
- const typeRule = type(rules[prop]);
456
- if (typeRule === 'Function') {
457
- return rules[prop](x)
458
- }
459
- if (typeRule === 'Object') {
460
- return evolveFn(rules[prop], x)
461
- }
462
-
463
- return x
464
- }
465
- if (type(rules[prop]) === 'Function') {
466
- return rules[prop](x)
467
- }
468
-
469
- return x
470
- })(obj)
471
- }
472
-
473
535
  function evolve(rules) {
474
- return obj => evolveFn(rules, obj)
475
- }
536
+ return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
537
+ }
476
538
 
477
539
  function includes(valueToFind) {
478
- return iterable =>
479
- {
480
- if (typeof iterable === 'string') {
481
- return iterable.includes(valueToFind)
482
- }
483
- if (!iterable) {
484
- throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
485
- }
486
- if (!isArray(iterable)) {
487
- return false
488
- }
540
+ return iterable => {
541
+ if (typeof iterable === 'string') {
542
+ return iterable.includes(valueToFind)
543
+ }
544
+ if (!iterable) {
545
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
546
+ }
547
+ if (!isArray(iterable)) {
548
+ return false
549
+ }
489
550
 
490
- return _indexOf(valueToFind, iterable) > -1
491
- }
551
+ return _indexOf(valueToFind, iterable) > -1
552
+ }
492
553
  }
493
554
 
494
555
  function excludes(valueToFind) {
495
556
  return iterable => !includes(valueToFind)(iterable)
496
557
  }
497
558
 
498
- function filter(predicate) {
499
- return list => {
500
- if (!list) {
501
- throw new Error('Incorrect iterable input')
502
- }
503
- let index = 0;
504
- const len = list.length;
505
- const willReturn = [];
506
-
507
- while (index < len) {
508
- if (predicate(list[index], index)) {
509
- willReturn.push(list[index]);
510
- }
511
-
512
- index++;
513
- }
514
-
515
- return willReturn
516
- }
517
- }
518
-
519
559
  function filterObject(predicate) {
520
560
  return obj => {
521
561
  const willReturn = {};
@@ -531,62 +571,79 @@
531
571
  }
532
572
 
533
573
  function find(predicate) {
534
- return list => {
535
- let index = 0;
536
- const len = list.length;
574
+ return list => {
575
+ let index = 0;
576
+ const len = list.length;
537
577
 
538
- while (index < len) {
539
- const x = list[index];
540
- if (predicate(x)) {
541
- return x
542
- }
578
+ while (index < len) {
579
+ const x = list[index];
580
+ if (predicate(x)) {
581
+ return x
582
+ }
543
583
 
544
- index++;
584
+ index++;
585
+ }
545
586
  }
546
587
  }
547
- }
548
588
 
549
589
  function findIndex(predicate) {
550
- return list => {
551
- const len = list.length;
552
- let index = -1;
590
+ return list => {
591
+ const len = list.length;
592
+ let index = -1;
553
593
 
554
- while (++index < len) {
555
- if (predicate(list[index])) {
556
- return index
594
+ while (++index < len) {
595
+ if (predicate(list[index])) {
596
+ return index
597
+ }
557
598
  }
558
- }
559
599
 
560
- return -1
561
- }
600
+ return -1
601
+ }
562
602
  }
563
603
 
564
604
  function findLast(predicate) {
565
- return list => {
566
- let index = list.length;
605
+ return list => {
606
+ let index = list.length;
567
607
 
568
- while (--index >= 0) {
569
- if (predicate(list[index])) {
570
- return list[index]
608
+ while (--index >= 0) {
609
+ if (predicate(list[index])) {
610
+ return list[index]
611
+ }
571
612
  }
572
- }
573
613
 
574
- return undefined
575
- }
614
+ return undefined
615
+ }
576
616
  }
577
617
 
578
618
  function findLastIndex(fn) {
579
- return list => {
580
- let index = list.length;
619
+ return list => {
620
+ let index = list.length;
581
621
 
582
- while (--index >= 0) {
583
- if (fn(list[index])) {
584
- return index
622
+ while (--index >= 0) {
623
+ if (fn(list[index])) {
624
+ return index
625
+ }
585
626
  }
586
- }
587
627
 
588
- return -1
628
+ return -1
629
+ }
589
630
  }
631
+
632
+ function findNth(predicate, nth) {
633
+ return list => {
634
+ let index = 0;
635
+ const len = list.length;
636
+
637
+ while (index < len) {
638
+ const x = list[index];
639
+ if (predicate(x)) {
640
+ if (nth === 0) return x
641
+ nth--;
642
+ }
643
+
644
+ index++;
645
+ }
646
+ }
590
647
  }
591
648
 
592
649
  function flatMap(fn) {
@@ -607,24 +664,25 @@
607
664
  return willReturn
608
665
  }
609
666
 
610
- function groupBy(groupFn, list) {
611
- if (arguments.length === 1) {
612
- return _list => groupBy(groupFn, _list)
613
- }
667
+ function groupByFallback(groupFn, list) {
668
+ const result = {};
669
+ for (let i = 0; i < list.length; i++) {
670
+ const item = list[i];
671
+ const key = groupFn(item);
614
672
 
615
- const result = {};
616
- for (let i = 0; i < list.length; i++) {
617
- const item = list[i];
618
- const key = groupFn(item);
673
+ if (!result[key]) {
674
+ result[key] = [];
675
+ }
619
676
 
620
- if (!result[key]) {
621
- result[key] = [];
677
+ result[key].push(item);
622
678
  }
623
679
 
624
- result[key].push(item);
625
- }
680
+ return result
681
+ }
626
682
 
627
- return result
683
+
684
+ function groupBy(groupFn) {
685
+ return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
628
686
  }
629
687
 
630
688
  function head(listOrString) {
@@ -701,30 +759,60 @@
701
759
  return ys => _filter(x => _includesWith(pred, x, ys), xs)
702
760
  }
703
761
 
762
+ const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g);
763
+ const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '');
764
+
765
+ const replace$1 = ({ inputHolder, prop, replacer }) => {
766
+ const regexBase = `{{${prop}}}`;
767
+ const regex = new RegExp(regexBase, 'g');
768
+ return inputHolder.replace(regex, replacer)
769
+ };
770
+
771
+ function interpolate(input) {
772
+ return templateInput => {
773
+ const occurrences = getOccurrences(input);
774
+ if (occurrences === null) {
775
+ return input
776
+ }
777
+ let inputHolder = input;
778
+
779
+ for (const occurrence of occurrences) {
780
+ const prop = getOccurrenceProp(occurrence);
781
+ inputHolder = replace$1({
782
+ inputHolder,
783
+ prop,
784
+ replacer: templateInput[prop],
785
+ });
786
+ }
787
+
788
+ return inputHolder
789
+ }
790
+ }
791
+
704
792
  function intersection(listA) {
705
- return listB =>filter(x => includes(x)(listA))(listB)
793
+ return listB => filter(x => includes(x)(listA))(listB)
706
794
  }
707
795
 
708
796
  function intersperse(separator) {
709
- return list => {
710
- let index = -1;
711
- const len = list.length;
712
- const willReturn = [];
797
+ return list => {
798
+ let index = -1;
799
+ const len = list.length;
800
+ const willReturn = [];
713
801
 
714
- while (++index < len) {
715
- if (index === len - 1) {
716
- willReturn.push(list[index]);
717
- } else {
718
- willReturn.push(list[index], separator);
802
+ while (++index < len) {
803
+ if (index === len - 1) {
804
+ willReturn.push(list[index]);
805
+ } else {
806
+ willReturn.push(list[index], separator);
807
+ }
719
808
  }
720
- }
721
809
 
722
- return willReturn
723
- }
810
+ return willReturn
811
+ }
724
812
  }
725
813
 
726
814
  function join(glue) {
727
- return list=> list.join(glue)
815
+ return list => list.join(glue)
728
816
  }
729
817
 
730
818
  function last(listOrString) {
@@ -752,34 +840,50 @@
752
840
  }
753
841
 
754
842
  function mapAsync(fn) {
755
- return async list => {
756
- const willReturn = [];
843
+ return async list => {
844
+ const willReturn = [];
757
845
  let i = 0;
758
846
  for (const a of list) {
759
847
  willReturn.push(await fn(a, i++));
760
848
  }
761
849
 
762
850
  return willReturn
763
- }
851
+ }
764
852
  }
765
853
 
766
- function mapObjectAsync(fn) {
767
- return async obj => {
854
+ function mapKeys(fn) {
855
+ return obj => {
768
856
  const willReturn = {};
769
- for (const prop in obj){
770
- willReturn[ prop ] = await fn(obj[ prop ], prop);
771
- }
772
-
857
+
858
+ Object.keys(obj).forEach(key => {
859
+ willReturn[fn(key, obj[key])] = obj[key];
860
+ });
861
+
773
862
  return willReturn
774
863
  }
775
864
  }
776
865
 
866
+ function mapObjectAsync(fn) {
867
+ return async obj => {
868
+ const willReturn = {};
869
+ for (const prop in obj) {
870
+ willReturn[prop] = await fn(obj[prop], prop);
871
+ }
872
+
873
+ return willReturn
874
+ }
875
+ }
876
+
877
+ function mapParallelAsync(fn) {
878
+ return async list => Promise.all(list.map((x, i) => fn(x, i)))
879
+ }
880
+
777
881
  function match(pattern) {
778
- return input => {
779
- const willReturn = input.match(pattern);
780
-
781
- return willReturn === null ? [] : willReturn
782
- }
882
+ return input => {
883
+ const willReturn = input.match(pattern);
884
+
885
+ return willReturn === null ? [] : willReturn
886
+ }
783
887
  }
784
888
 
785
889
  function maxBy(compareFn, x) {
@@ -799,66 +903,33 @@
799
903
  return y => (compareFn(y) < compareFn(x) ? y : x)
800
904
  }
801
905
 
802
- function createPath(path, delimiter = '.') {
803
- return typeof path === 'string'
804
- ? path.split(delimiter).map(x => (Number.isInteger(Number(x)) ? Number(x) : x))
805
- : path
806
- }
807
-
808
- function path(pathInput, obj) {
809
- if (arguments.length === 1) {
810
- return _obj => path(pathInput, _obj)
811
- }
812
-
813
- if (!obj) {
814
- return undefined
815
- }
816
- let willReturn = obj;
817
- let counter = 0;
818
-
819
- const pathArrValue = createPath(pathInput);
820
-
821
- while (counter < pathArrValue.length) {
822
- if (willReturn === null || willReturn === undefined) {
823
- return undefined
824
- }
825
- if (willReturn[pathArrValue[counter]] === null) {
826
- return undefined
906
+ function update(index, newValue) {
907
+ return list => {
908
+ const clone = cloneList$1(list);
909
+ if (index === -1) {
910
+ return clone.fill(newValue, index)
827
911
  }
828
912
 
829
- willReturn = willReturn[pathArrValue[counter]];
830
- counter++;
913
+ return clone.fill(newValue, index, index + 1)
831
914
  }
832
-
833
- return willReturn
834
915
  }
835
916
 
836
- function assoc(prop, newValue) {
837
- return obj => Object.assign({}, obj, { [prop]: newValue })
838
- }
839
-
840
- function modifyPathFn(pathInput, fn, obj) {
841
- const path$1 = createPath(pathInput);
842
- if (path$1.length === 1) {
843
- return {
844
- ...obj,
845
- [path$1[0]]: fn(obj[path$1[0]]),
846
- }
847
- }
848
- if (path(path$1)(obj) === undefined) {
849
- return obj
850
- }
851
-
852
- const val = modifyPathFn(Array.prototype.slice.call(path$1, 1), fn, obj[path$1[0]]);
853
- if (val === obj[path$1[0]]) {
854
- return obj
855
- }
917
+ function modifyFn(property, fn, list) {
918
+ if (list[property] === undefined) {
919
+ return list
920
+ }
921
+ if (isArray(list)) {
922
+ return update(property, fn(list[property]))(list)
923
+ }
856
924
 
857
- return assoc(path$1[0], val)(obj)
925
+ return {
926
+ ...list,
927
+ [property]: fn(list[property]),
928
+ }
858
929
  }
859
930
 
860
- function modifyPath(pathInput, fn) {
861
- return obj => modifyPathFn(pathInput, fn, obj)
931
+ function modifyProp(property, fn) {
932
+ return obj => modifyFn(property, fn, obj)
862
933
  }
863
934
 
864
935
  function none(predicate) {
@@ -877,6 +948,22 @@
877
948
  return value => ({ [key]: value })
878
949
  }
879
950
 
951
+ function objectIncludes(condition) {
952
+ return obj => {
953
+ const result = filterObject((conditionValue, conditionProp) =>
954
+ equals(conditionValue)(obj[conditionProp]),
955
+ )(condition);
956
+
957
+ return Object.keys(result).length === Object.keys(condition).length
958
+ }
959
+ }
960
+
961
+ function createPath(path, delimiter = '.') {
962
+ return typeof path === 'string'
963
+ ? path.split(delimiter).map(x => (Number.isInteger(Number(x)) ? Number(x) : x))
964
+ : path
965
+ }
966
+
880
967
  function _includes(x, list) {
881
968
  let index = -1;
882
969
  const { length } = list;
@@ -909,10 +996,29 @@
909
996
  }
910
997
  }
911
998
 
912
- function partitionObject(predicate, iterable) {
999
+ function partition(predicate) {
1000
+ return list => {
1001
+ const yes = [];
1002
+ const no = [];
1003
+ let counter = -1;
1004
+
1005
+ while (counter++ < list.length - 1) {
1006
+ if (predicate(list[counter], counter)) {
1007
+ yes.push(list[counter]);
1008
+ } else {
1009
+ no.push(list[counter]);
1010
+ }
1011
+ }
1012
+
1013
+ return [yes, no]
1014
+ }
1015
+ }
1016
+
1017
+ function partitionObject(predicate) {
1018
+ return obj => {
913
1019
  const yes = {};
914
1020
  const no = {};
915
- Object.entries(iterable).forEach(([prop, value]) => {
1021
+ Object.entries(obj).forEach(([prop, value]) => {
916
1022
  if (predicate(value, prop)) {
917
1023
  yes[prop] = value;
918
1024
  } else {
@@ -922,31 +1028,73 @@
922
1028
 
923
1029
  return [yes, no]
924
1030
  }
1031
+ }
925
1032
 
926
- function partitionArray(predicate, list, indexed = false) {
927
- const yes = [];
928
- const no = [];
929
- let counter = -1;
1033
+ function path(pathInput, obj) {
1034
+ if (arguments.length === 1) {
1035
+ return _obj => path(pathInput, _obj)
1036
+ }
930
1037
 
931
- while (counter++ < list.length - 1) {
932
- if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) {
933
- yes.push(list[counter]);
934
- } else {
935
- no.push(list[counter]);
1038
+ if (!obj) {
1039
+ return undefined
1040
+ }
1041
+ let willReturn = obj;
1042
+ let counter = 0;
1043
+
1044
+ const pathArrValue = createPath(pathInput);
1045
+
1046
+ while (counter < pathArrValue.length) {
1047
+ if (willReturn === null || willReturn === undefined) {
1048
+ return undefined
1049
+ }
1050
+ if (willReturn[pathArrValue[counter]] === null) {
1051
+ return undefined
936
1052
  }
1053
+
1054
+ willReturn = willReturn[pathArrValue[counter]];
1055
+ counter++;
937
1056
  }
938
1057
 
939
- return [yes, no]
1058
+ return willReturn
940
1059
  }
941
1060
 
942
- function partition(predicate) {
943
- return iterable => {
944
- if (!isArray(iterable)) {
945
- return partitionObject(predicate, iterable)
946
- }
947
-
948
- return partitionArray(predicate, iterable)
949
- }
1061
+ /**
1062
+ * Source:
1063
+ * https://github.com/denoland/std/blob/main/collections/permutations.ts
1064
+ */
1065
+ function permutations(inputArray) {
1066
+ const result = [];
1067
+ const array = cloneList$1(inputArray);
1068
+ const k = array.length;
1069
+ if (k === 0) {
1070
+ return result;
1071
+ }
1072
+
1073
+ const c = new Array(k).fill(0);
1074
+
1075
+ result.push([...array]);
1076
+
1077
+ let i = 1;
1078
+
1079
+ while (i < k) {
1080
+ if (c[i] < i) {
1081
+ if (i % 2 === 0) {
1082
+ [array[0], array[i]] = [array[i], array[0]];
1083
+ } else {
1084
+ [array[c[i]], array[i]] = [array[i], array[c[i]]];
1085
+ }
1086
+
1087
+ result.push([...array]);
1088
+
1089
+ c[i] += 1;
1090
+ i = 1;
1091
+ } else {
1092
+ c[i] = 0;
1093
+ i += 1;
1094
+ }
1095
+ }
1096
+
1097
+ return result;
950
1098
  }
951
1099
 
952
1100
  function pick(propsToPick) {
@@ -1069,30 +1217,35 @@
1069
1217
  }
1070
1218
 
1071
1219
  async function pipeAsync(input, ...fnList) {
1072
- let willReturn = input;
1073
- for (const fn of fnList) {
1074
- const initialResult = fn(willReturn);
1075
- willReturn = type(initialResult) === 'Promise' ? await initialResult : initialResult;
1076
- }
1077
- return willReturn
1220
+ let willReturn = input;
1221
+ for (const fn of fnList) {
1222
+ const initialResult = fn(willReturn);
1223
+ willReturn =
1224
+ type(initialResult) === 'Promise' ? await initialResult : initialResult;
1225
+ }
1226
+ return willReturn
1078
1227
  }
1079
1228
 
1080
1229
  function pluck(property) {
1081
- return list => {
1082
- const willReturn = [];
1230
+ return list => {
1231
+ const willReturn = [];
1083
1232
 
1084
- list.forEach(x => {
1085
- if (x[property] !== undefined) {
1086
- willReturn.push(x[property]);
1087
- }
1088
- });
1233
+ list.forEach(x => {
1234
+ if (x[property] !== undefined) {
1235
+ willReturn.push(x[property]);
1236
+ }
1237
+ });
1089
1238
 
1090
- return willReturn
1091
- }
1239
+ return willReturn
1240
+ }
1092
1241
  }
1093
1242
 
1094
1243
  function prepend(x) {
1095
- return list=> [x].concat(list)
1244
+ return list => [x].concat(list)
1245
+ }
1246
+
1247
+ function prop(searchProperty) {
1248
+ return obj => (obj ? obj[searchProperty] : undefined)
1096
1249
  }
1097
1250
 
1098
1251
  function propEq(valueToMatch, propToFind) {
@@ -1116,30 +1269,49 @@
1116
1269
  }
1117
1270
 
1118
1271
  function propSatisfies(predicate, property) {
1119
- return obj => predicate(prop(property))
1272
+ return obj => predicate(obj[property])
1120
1273
  }
1121
1274
 
1122
- function range(start){
1123
- return end => {
1124
- if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))){
1125
- throw new TypeError('Both arguments to range must be numbers')
1126
- }
1275
+ function range(start) {
1276
+ return end => {
1277
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
1278
+ throw new TypeError('Both arguments to range must be numbers')
1279
+ }
1127
1280
 
1128
- if (end < start) return []
1281
+ if (end <= start) {
1282
+ return []
1283
+ }
1129
1284
 
1130
- const len = end - start;
1131
- const willReturn = Array(len);
1285
+ const len = end - start;
1286
+ const willReturn = Array(len);
1132
1287
 
1133
- for (let i = 0; i < len; i++){
1134
- willReturn[ i ] = start + i;
1135
- }
1288
+ for (let i = 0; i < len + 1; i++) {
1289
+ willReturn[i] = start + i;
1290
+ }
1136
1291
 
1137
- return willReturn
1138
- }
1292
+ return willReturn
1293
+ }
1139
1294
  }
1140
1295
 
1141
- function reject(predicate) {
1142
- return list => filter(x => !predicate(x))
1296
+ function rangeDescending(start) {
1297
+ return end => {
1298
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
1299
+ throw new TypeError('Both arguments to range must be numbers')
1300
+ }
1301
+
1302
+ if (end >= start) {
1303
+ return []
1304
+ }
1305
+
1306
+ const len = start - end;
1307
+ const willReturn = Array(len);
1308
+
1309
+ for (let i = 0; i < len + 1; i++) {
1310
+ willReturn[i] = start - i;
1311
+ }
1312
+
1313
+ return willReturn
1314
+ }
1143
1315
  }
1144
1316
 
1145
1317
  function replace(pattern, replacer) {
@@ -1153,30 +1325,60 @@
1153
1325
  return list
1154
1326
  }
1155
1327
 
1156
- const clone = cloneList(list);
1328
+ const clone = cloneList$1(list);
1157
1329
  clone[actualIndex] = replaceFn(clone[actualIndex]);
1158
1330
 
1159
1331
  return clone
1160
1332
  }
1161
1333
  }
1162
1334
 
1163
- function sort(sortFn){
1164
- return list => cloneList(list).sort(sortFn)
1335
+ function shuffle(listInput) {
1336
+ const list = cloneList(listInput);
1337
+ let counter = list.length;
1338
+ while (counter > 0) {
1339
+ const index = Math.floor(Math.random() * counter);
1340
+ counter--;
1341
+ const temp = list[counter];
1342
+ list[counter] = list[index];
1343
+ list[index] = temp;
1344
+ }
1345
+
1346
+ return list
1165
1347
  }
1166
1348
 
1167
- function sortBy(sortFn){
1168
- return list => {
1169
- const clone = cloneList(list);
1349
+ function sort(sortFn) {
1350
+ return list => cloneList$1(list).sort(sortFn)
1351
+ }
1170
1352
 
1171
- return clone.sort((a, b) => {
1172
- const aSortResult = sortFn(a);
1173
- const bSortResult = sortFn(b);
1353
+ function sortBy(sortFn) {
1354
+ return list => {
1355
+ const clone = cloneList$1(list);
1174
1356
 
1175
- if (aSortResult === bSortResult) return 0
1357
+ return clone.sort((a, b) => {
1358
+ const aSortResult = sortFn(a);
1359
+ const bSortResult = sortFn(b);
1176
1360
 
1177
- return aSortResult < bSortResult ? -1 : 1
1178
- })
1361
+ if (aSortResult === bSortResult) {
1362
+ return 0
1363
+ }
1364
+
1365
+ return aSortResult < bSortResult ? -1 : 1
1366
+ })
1367
+ }
1179
1368
  }
1369
+
1370
+ function sortObject(predicate) {
1371
+ return obj => {
1372
+ const keys = Object.keys(obj);
1373
+ const sortedKeys = sort((a, b) => predicate(a, b, obj[a], obj[b]))(keys);
1374
+
1375
+ const toReturn = {};
1376
+ sortedKeys.forEach(singleKey => {
1377
+ toReturn[singleKey] = obj[singleKey];
1378
+ });
1379
+
1380
+ return toReturn
1381
+ }
1180
1382
  }
1181
1383
 
1182
1384
  function sortHelper(a, b, listOfSortingFns) {
@@ -1191,37 +1393,37 @@
1191
1393
  }
1192
1394
 
1193
1395
  function sortWith(listOfSortingFns) {
1194
- return list => {
1195
- if (Array.isArray(list) === false) {
1196
- return []
1197
- }
1396
+ return list => {
1397
+ if (Array.isArray(list) === false) {
1398
+ return []
1399
+ }
1198
1400
 
1199
- const clone = list.slice();
1200
- clone.sort((a, b) => sortHelper(a, b, listOfSortingFns));
1401
+ const clone = list.slice();
1402
+ clone.sort((a, b) => sortHelper(a, b, listOfSortingFns));
1201
1403
 
1202
- return clone
1203
- }
1404
+ return clone
1405
+ }
1204
1406
  }
1205
1407
 
1206
- function split(separator){
1207
- return str => str.split(separator)
1408
+ function split(separator) {
1409
+ return str => str.split(separator)
1208
1410
  }
1209
1411
 
1210
1412
  function splitEvery(sliceLength) {
1211
- return list => {
1212
- if (sliceLength < 1) {
1213
- throw new Error('First argument to splitEvery must be a positive integer')
1214
- }
1413
+ return list => {
1414
+ if (sliceLength < 1) {
1415
+ throw new Error('First argument to splitEvery must be a positive integer')
1416
+ }
1215
1417
 
1216
- const willReturn = [];
1217
- let counter = 0;
1418
+ const willReturn = [];
1419
+ let counter = 0;
1218
1420
 
1219
- while (counter < list.length) {
1220
- willReturn.push(list.slice(counter, (counter += sliceLength)));
1221
- }
1421
+ while (counter < list.length) {
1422
+ willReturn.push(list.slice(counter, (counter += sliceLength)));
1423
+ }
1222
1424
 
1223
- return willReturn
1224
- }
1425
+ return willReturn
1426
+ }
1225
1427
  }
1226
1428
 
1227
1429
  function symmetricDifference(x) {
@@ -1267,24 +1469,24 @@
1267
1469
  }
1268
1470
 
1269
1471
  function takeLastWhile(predicate) {
1270
- return input => {
1271
- if (input.length === 0) {
1272
- return input
1273
- }
1274
-
1275
- const toReturn = [];
1276
- let counter = input.length;
1277
-
1278
- while (counter) {
1279
- const item = input[--counter];
1280
- if (!predicate(item)) {
1281
- break
1282
- }
1283
- toReturn.push(item);
1284
- }
1285
-
1286
- return toReturn.reverse()
1287
- }
1472
+ return input => {
1473
+ if (input.length === 0) {
1474
+ return input
1475
+ }
1476
+
1477
+ const toReturn = [];
1478
+ let counter = input.length;
1479
+
1480
+ while (counter) {
1481
+ const item = input[--counter];
1482
+ if (!predicate(item)) {
1483
+ break
1484
+ }
1485
+ toReturn.push(item);
1486
+ }
1487
+
1488
+ return toReturn.reverse()
1489
+ }
1288
1490
  }
1289
1491
 
1290
1492
  function takeWhile(predicate) {
@@ -1304,15 +1506,15 @@
1304
1506
  }
1305
1507
 
1306
1508
  function tap(fn) {
1307
- return x => {
1308
- fn(x);
1509
+ return x => {
1510
+ fn(x);
1309
1511
 
1310
- return x
1311
- }
1512
+ return x
1513
+ }
1312
1514
  }
1313
1515
 
1314
1516
  function test(pattern) {
1315
- return str => str.search(pattern) !== -1
1517
+ return str => str.search(pattern) !== -1
1316
1518
  }
1317
1519
 
1318
1520
  function tryCatch(fn, fallback) {
@@ -1327,7 +1529,7 @@
1327
1529
 
1328
1530
  function union(x) {
1329
1531
  return y => {
1330
- const toReturn = cloneList(x);
1532
+ const toReturn = cloneList$1(x);
1331
1533
 
1332
1534
  y.forEach(yInstance => {
1333
1535
  if (!includes(yInstance)(x)) {
@@ -1391,11 +1593,11 @@
1391
1593
  }
1392
1594
 
1393
1595
  function uniqBy(fn) {
1394
- return list => {
1395
- const set = new _Set();
1596
+ return list => {
1597
+ const set = new _Set();
1396
1598
 
1397
- return list.filter(item => set.checkUniqueness(fn(item)))
1398
- }
1599
+ return list.filter(item => set.checkUniqueness(fn(item)))
1600
+ }
1399
1601
  }
1400
1602
 
1401
1603
  function includesWith(predicate, target, list) {
@@ -1414,20 +1616,20 @@
1414
1616
  }
1415
1617
 
1416
1618
  function uniqWith(predicate) {
1417
- return list => {
1418
- let index = -1;
1419
- const willReturn = [];
1619
+ return list => {
1620
+ let index = -1;
1621
+ const willReturn = [];
1420
1622
 
1421
- while (++index < list.length) {
1422
- const value = list[index];
1623
+ while (++index < list.length) {
1624
+ const value = list[index];
1423
1625
 
1424
- if (!includesWith(predicate, value, willReturn)) {
1425
- willReturn.push(value);
1626
+ if (!includesWith(predicate, value, willReturn)) {
1627
+ willReturn.push(value);
1628
+ }
1426
1629
  }
1427
- }
1428
1630
 
1429
- return willReturn
1430
- }
1631
+ return willReturn
1632
+ }
1431
1633
  }
1432
1634
 
1433
1635
  function unless(predicate, whenFalseFn) {
@@ -1449,17 +1651,6 @@
1449
1651
  }
1450
1652
  }
1451
1653
 
1452
- function update(index, newValue) {
1453
- return list => {
1454
- const clone = cloneList(list);
1455
- if (index === -1) {
1456
- return clone.fill(newValue, index)
1457
- }
1458
-
1459
- return clone.fill(newValue, index, index + 1)
1460
- }
1461
- }
1462
-
1463
1654
  function when(predicate, whenTrueFn) {
1464
1655
  return input => {
1465
1656
  if (!predicate(input)) {
@@ -1494,17 +1685,23 @@
1494
1685
  exports._includes = _includes;
1495
1686
  exports._indexOf = _indexOf;
1496
1687
  exports._lastIndexOf = _lastIndexOf;
1688
+ exports.addProp = addProp;
1497
1689
  exports.all = all;
1498
1690
  exports.allPass = allPass;
1499
1691
  exports.any = any;
1500
1692
  exports.anyPass = anyPass;
1501
1693
  exports.append = append;
1694
+ exports.ascend = ascend;
1502
1695
  exports.checkObjectWithSpec = checkObjectWithSpec;
1696
+ exports.compact = compact;
1503
1697
  exports.complement = complement;
1504
1698
  exports.concat = concat;
1505
1699
  exports.count = count;
1506
1700
  exports.countBy = countBy;
1701
+ exports.createCompareFunction = createCompareFunction;
1702
+ exports.createObjectFromKeys = createObjectFromKeys;
1507
1703
  exports.defaultTo = defaultTo;
1704
+ exports.descend = descend;
1508
1705
  exports.drop = drop;
1509
1706
  exports.dropLast = dropLast;
1510
1707
  exports.dropLastWhile = dropLastWhile;
@@ -1514,7 +1711,6 @@
1514
1711
  exports.equals = equals;
1515
1712
  exports.equalsFn = equalsFn;
1516
1713
  exports.evolve = evolve;
1517
- exports.evolveFn = evolveFn;
1518
1714
  exports.excludes = excludes;
1519
1715
  exports.filter = filter;
1520
1716
  exports.filterObject = filterObject;
@@ -1522,14 +1718,17 @@
1522
1718
  exports.findIndex = findIndex;
1523
1719
  exports.findLast = findLast;
1524
1720
  exports.findLastIndex = findLastIndex;
1721
+ exports.findNth = findNth;
1525
1722
  exports.flatMap = flatMap;
1526
1723
  exports.flatten = flatten;
1527
1724
  exports.groupBy = groupBy;
1725
+ exports.groupByFallback = groupByFallback;
1528
1726
  exports.head = head;
1529
1727
  exports.includes = includes;
1530
1728
  exports.indexOf = indexOf;
1531
1729
  exports.init = init;
1532
1730
  exports.innerJoin = innerJoin;
1731
+ exports.interpolate = interpolate;
1533
1732
  exports.intersection = intersection;
1534
1733
  exports.intersperse = intersperse;
1535
1734
  exports.join = join;
@@ -1537,21 +1736,24 @@
1537
1736
  exports.lastIndexOf = lastIndexOf;
1538
1737
  exports.map = map;
1539
1738
  exports.mapAsync = mapAsync;
1739
+ exports.mapKeys = mapKeys;
1540
1740
  exports.mapObject = mapObject;
1541
1741
  exports.mapObjectAsync = mapObjectAsync;
1742
+ exports.mapParallelAsync = mapParallelAsync;
1542
1743
  exports.match = match;
1543
1744
  exports.maxBy = maxBy;
1544
1745
  exports.merge = merge;
1545
1746
  exports.mergeTypes = mergeTypes;
1546
1747
  exports.minBy = minBy;
1547
- exports.modifyPath = modifyPath;
1748
+ exports.modifyProp = modifyProp;
1548
1749
  exports.none = none;
1549
1750
  exports.objOf = objOf;
1751
+ exports.objectIncludes = objectIncludes;
1550
1752
  exports.omit = omit;
1551
1753
  exports.partition = partition;
1552
- exports.partitionArray = partitionArray;
1553
1754
  exports.partitionObject = partitionObject;
1554
1755
  exports.path = path;
1756
+ exports.permutations = permutations;
1555
1757
  exports.pick = pick;
1556
1758
  exports.pipe = pipe;
1557
1759
  exports.pipeAsync = pipeAsync;
@@ -1562,12 +1764,16 @@
1562
1764
  exports.propOr = propOr;
1563
1765
  exports.propSatisfies = propSatisfies;
1564
1766
  exports.range = range;
1767
+ exports.rangeDescending = rangeDescending;
1565
1768
  exports.reduce = reduce;
1566
1769
  exports.reject = reject;
1770
+ exports.rejectObject = rejectObject;
1567
1771
  exports.replace = replace;
1568
1772
  exports.replaceItemAtIndex = replaceItemAtIndex;
1773
+ exports.shuffle = shuffle;
1569
1774
  exports.sort = sort;
1570
1775
  exports.sortBy = sortBy;
1776
+ exports.sortObject = sortObject;
1571
1777
  exports.sortWith = sortWith;
1572
1778
  exports.split = split;
1573
1779
  exports.splitEvery = splitEvery;