rambda 10.3.4 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +654 -260
- package/dist/rambda.cjs +163 -148
- package/dist/rambda.js +159 -148
- package/dist/rambda.umd.js +163 -148
- package/index.d.cts +44 -22
- package/index.d.ts +44 -22
- package/package.json +1 -1
- package/rambda.js +5 -1
- package/src/difference.js +9 -0
- package/src/exists.js +7 -0
- package/src/{innerJoin.js → intersectionWith.js} +1 -1
- package/src/range.js +7 -32
- package/src/rangeDescending.js +8 -0
- package/src/unionWith.js +11 -0
package/dist/rambda.js
CHANGED
|
@@ -256,60 +256,6 @@ function descend(getFunction) {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
function drop(howManyToDrop, ) {
|
|
260
|
-
return list => list.slice(howManyToDrop > 0 ? howManyToDrop : 0)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function dropLast(numberItems) {
|
|
264
|
-
return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function dropLastWhile(predicate) {
|
|
268
|
-
return list => {
|
|
269
|
-
if (list.length === 0) {
|
|
270
|
-
return list
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const toReturn = [];
|
|
274
|
-
let counter = list.length;
|
|
275
|
-
|
|
276
|
-
while (counter) {
|
|
277
|
-
const item = list[--counter];
|
|
278
|
-
if (!predicate(item, counter)) {
|
|
279
|
-
toReturn.push(item);
|
|
280
|
-
break
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
while (counter) {
|
|
285
|
-
toReturn.push(list[--counter]);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return toReturn.reverse()
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function dropWhile(predicate) {
|
|
293
|
-
return iterable => {
|
|
294
|
-
const toReturn = [];
|
|
295
|
-
let counter = 0;
|
|
296
|
-
|
|
297
|
-
while (counter < iterable.length) {
|
|
298
|
-
const item = iterable[counter++];
|
|
299
|
-
if (!predicate(item, counter)) {
|
|
300
|
-
toReturn.push(item);
|
|
301
|
-
break
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
while (counter < iterable.length) {
|
|
306
|
-
toReturn.push(iterable[counter++]);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return toReturn
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
259
|
function type(input) {
|
|
314
260
|
if (input === null) {
|
|
315
261
|
return 'Null'
|
|
@@ -533,6 +479,83 @@ function equals(a) {
|
|
|
533
479
|
return b => equalsFn(a, b)
|
|
534
480
|
}
|
|
535
481
|
|
|
482
|
+
function includes(valueToFind) {
|
|
483
|
+
return iterable => {
|
|
484
|
+
if (typeof iterable === 'string') {
|
|
485
|
+
return iterable.includes(valueToFind)
|
|
486
|
+
}
|
|
487
|
+
if (!iterable) {
|
|
488
|
+
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
|
|
489
|
+
}
|
|
490
|
+
if (!isArray(iterable)) {
|
|
491
|
+
return false
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return _indexOf(valueToFind, iterable) > -1
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function difference(x) {
|
|
499
|
+
return y => ([
|
|
500
|
+
...filter(value => !includes(value)(y))(x),
|
|
501
|
+
...filter(value => !includes(value)(x))(y),
|
|
502
|
+
])
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function drop(howManyToDrop, ) {
|
|
506
|
+
return list => list.slice(howManyToDrop > 0 ? howManyToDrop : 0)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function dropLast(numberItems) {
|
|
510
|
+
return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function dropLastWhile(predicate) {
|
|
514
|
+
return list => {
|
|
515
|
+
if (list.length === 0) {
|
|
516
|
+
return list
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const toReturn = [];
|
|
520
|
+
let counter = list.length;
|
|
521
|
+
|
|
522
|
+
while (counter) {
|
|
523
|
+
const item = list[--counter];
|
|
524
|
+
if (!predicate(item, counter)) {
|
|
525
|
+
toReturn.push(item);
|
|
526
|
+
break
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
while (counter) {
|
|
531
|
+
toReturn.push(list[--counter]);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return toReturn.reverse()
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function dropWhile(predicate) {
|
|
539
|
+
return iterable => {
|
|
540
|
+
const toReturn = [];
|
|
541
|
+
let counter = 0;
|
|
542
|
+
|
|
543
|
+
while (counter < iterable.length) {
|
|
544
|
+
const item = iterable[counter++];
|
|
545
|
+
if (!predicate(item, counter)) {
|
|
546
|
+
toReturn.push(item);
|
|
547
|
+
break
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
while (counter < iterable.length) {
|
|
552
|
+
toReturn.push(iterable[counter++]);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return toReturn
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
536
559
|
class _Set {
|
|
537
560
|
constructor() {
|
|
538
561
|
this.set = new Set();
|
|
@@ -611,24 +634,30 @@ function evolve(rules) {
|
|
|
611
634
|
return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
|
|
612
635
|
}
|
|
613
636
|
|
|
614
|
-
function
|
|
615
|
-
return iterable =>
|
|
616
|
-
|
|
617
|
-
return iterable.includes(valueToFind)
|
|
618
|
-
}
|
|
619
|
-
if (!iterable) {
|
|
620
|
-
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
|
|
621
|
-
}
|
|
622
|
-
if (!isArray(iterable)) {
|
|
623
|
-
return false
|
|
624
|
-
}
|
|
637
|
+
function excludes(valueToFind) {
|
|
638
|
+
return iterable => !includes(valueToFind)(iterable)
|
|
639
|
+
}
|
|
625
640
|
|
|
626
|
-
|
|
641
|
+
function find(predicate) {
|
|
642
|
+
return list => {
|
|
643
|
+
let index = 0;
|
|
644
|
+
const len = list.length;
|
|
645
|
+
|
|
646
|
+
while (index < len) {
|
|
647
|
+
const x = list[index];
|
|
648
|
+
if (predicate(x)) {
|
|
649
|
+
return x
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
index++;
|
|
653
|
+
}
|
|
627
654
|
}
|
|
628
655
|
}
|
|
629
656
|
|
|
630
|
-
function
|
|
631
|
-
return
|
|
657
|
+
function exists(predicate) {
|
|
658
|
+
return list => {
|
|
659
|
+
return find(predicate)(list) !== undefined
|
|
660
|
+
}
|
|
632
661
|
}
|
|
633
662
|
|
|
634
663
|
function filterAsync(predicate) {
|
|
@@ -660,22 +689,6 @@ function filterObject(predicate) {
|
|
|
660
689
|
}
|
|
661
690
|
}
|
|
662
691
|
|
|
663
|
-
function find(predicate) {
|
|
664
|
-
return list => {
|
|
665
|
-
let index = 0;
|
|
666
|
-
const len = list.length;
|
|
667
|
-
|
|
668
|
-
while (index < len) {
|
|
669
|
-
const x = list[index];
|
|
670
|
-
if (predicate(x)) {
|
|
671
|
-
return x
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
index++;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
692
|
function findIndex(predicate) {
|
|
680
693
|
return list => {
|
|
681
694
|
const len = list.length;
|
|
@@ -905,40 +918,6 @@ function init(input) {
|
|
|
905
918
|
return input.length ? baseSlice(input, 0, -1) : []
|
|
906
919
|
}
|
|
907
920
|
|
|
908
|
-
function _includesWith(pred, x, list) {
|
|
909
|
-
let idx = 0;
|
|
910
|
-
const len = list.length;
|
|
911
|
-
|
|
912
|
-
while (idx < len) {
|
|
913
|
-
if (pred(x, list[idx])) {
|
|
914
|
-
return true
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
idx += 1;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
return false
|
|
921
|
-
}
|
|
922
|
-
function _filter(fn, list) {
|
|
923
|
-
let idx = 0;
|
|
924
|
-
const len = list.length;
|
|
925
|
-
const result = [];
|
|
926
|
-
|
|
927
|
-
while (idx < len) {
|
|
928
|
-
if (fn(list[idx])) {
|
|
929
|
-
result[result.length] = list[idx];
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
idx += 1;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
return result
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
function innerJoin(pred, xs) {
|
|
939
|
-
return ys => _filter(x => _includesWith(pred, x, ys), xs)
|
|
940
|
-
}
|
|
941
|
-
|
|
942
921
|
const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g);
|
|
943
922
|
const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '');
|
|
944
923
|
|
|
@@ -973,6 +952,40 @@ function intersection(listA) {
|
|
|
973
952
|
return listB => filter(x => includes(x)(listA))(listB)
|
|
974
953
|
}
|
|
975
954
|
|
|
955
|
+
function _includesWith(pred, x, list) {
|
|
956
|
+
let idx = 0;
|
|
957
|
+
const len = list.length;
|
|
958
|
+
|
|
959
|
+
while (idx < len) {
|
|
960
|
+
if (pred(x, list[idx])) {
|
|
961
|
+
return true
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
idx += 1;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
return false
|
|
968
|
+
}
|
|
969
|
+
function _filter(fn, list) {
|
|
970
|
+
let idx = 0;
|
|
971
|
+
const len = list.length;
|
|
972
|
+
const result = [];
|
|
973
|
+
|
|
974
|
+
while (idx < len) {
|
|
975
|
+
if (fn(list[idx])) {
|
|
976
|
+
result[result.length] = list[idx];
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
idx += 1;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
return result
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function intersectionWith(pred, xs) {
|
|
986
|
+
return ys => _filter(x => _includesWith(pred, x, ys), xs)
|
|
987
|
+
}
|
|
988
|
+
|
|
976
989
|
function intersperse(separator) {
|
|
977
990
|
return list => {
|
|
978
991
|
let index = -1;
|
|
@@ -1505,37 +1518,23 @@ function propSatisfies(predicate, property) {
|
|
|
1505
1518
|
return obj => predicate(obj[property])
|
|
1506
1519
|
}
|
|
1507
1520
|
|
|
1508
|
-
function
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return willReturn
|
|
1521
|
+
function range(a, b) {
|
|
1522
|
+
const start = b === undefined ? 0 : a;
|
|
1523
|
+
const end = b === undefined ? a : b;
|
|
1524
|
+
if (end<= start) {
|
|
1525
|
+
return []
|
|
1526
|
+
}
|
|
1527
|
+
const len = end - start;
|
|
1528
|
+
return Array.from({ length: len + 1 }, (_, i) => start + i)
|
|
1517
1529
|
}
|
|
1518
1530
|
|
|
1519
|
-
function
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
return []
|
|
1527
|
-
}
|
|
1528
|
-
if (end < start) return rangeDescending(start,end)
|
|
1529
|
-
|
|
1530
|
-
const len = end - start;
|
|
1531
|
-
const willReturn = Array(len);
|
|
1532
|
-
|
|
1533
|
-
for (let i = 0; i < len; i++) {
|
|
1534
|
-
willReturn[i] = start + i;
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
return willReturn
|
|
1538
|
-
}
|
|
1531
|
+
function rangeDescending(start, b) {
|
|
1532
|
+
const end = b === undefined ? 0 : b;
|
|
1533
|
+
if (start <= end) {
|
|
1534
|
+
return []
|
|
1535
|
+
}
|
|
1536
|
+
const len = start - end;
|
|
1537
|
+
return Array.from({ length: len + 1 }, (_, i) => start - i)
|
|
1539
1538
|
}
|
|
1540
1539
|
|
|
1541
1540
|
function replace(pattern, replacer) {
|
|
@@ -1783,6 +1782,18 @@ function union(x) {
|
|
|
1783
1782
|
}
|
|
1784
1783
|
}
|
|
1785
1784
|
|
|
1785
|
+
function unionWith(predicate, x) {
|
|
1786
|
+
return y => {
|
|
1787
|
+
const filtered = y.filter(yInstance => {
|
|
1788
|
+
return x.every(xInstance => {
|
|
1789
|
+
return !predicate(xInstance, yInstance)
|
|
1790
|
+
})
|
|
1791
|
+
});
|
|
1792
|
+
|
|
1793
|
+
return [...x, ...filtered]
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1786
1797
|
function uniq(list) {
|
|
1787
1798
|
const set = new _Set();
|
|
1788
1799
|
const willReturn = [];
|
|
@@ -1884,4 +1895,4 @@ function zipWith(fn, x) {
|
|
|
1884
1895
|
)
|
|
1885
1896
|
}
|
|
1886
1897
|
|
|
1887
|
-
export { _arity, _includes, _indexOf, _lastIndexOf, addProp, addPropToObjects, all, allPass, any, anyPass, append, ascend, assertType, checkObjectWithSpec, compact, complement, concat, convertToType, count, countBy, createCompareFunction, createObjectFromKeys, defaultTo, descend, drop, dropLast, dropLastWhile, dropWhile, duplicateBy, eqBy, eqProps, equals, equalsFn, evolve, excludes, filter, filterAsync, filterObject, find, findIndex, findLast, findLastIndex, findNth, flatMap, flatten, flattenObject, flattenObjectHelper, groupBy, groupByFallback, head, includes, indexBy, indexOf, init,
|
|
1898
|
+
export { _arity, _includes, _indexOf, _lastIndexOf, addProp, addPropToObjects, all, allPass, any, anyPass, append, ascend, assertType, checkObjectWithSpec, compact, complement, concat, convertToType, count, countBy, createCompareFunction, createObjectFromKeys, defaultTo, descend, difference, drop, dropLast, dropLastWhile, dropWhile, duplicateBy, eqBy, eqProps, equals, equalsFn, evolve, excludes, exists, filter, filterAsync, filterObject, find, findIndex, findLast, findLastIndex, findNth, flatMap, flatten, flattenObject, flattenObjectHelper, groupBy, groupByFallback, head, includes, indexBy, indexOf, init, interpolate, intersection, intersectionWith, intersperse, join, last, lastIndexOf, map, mapAsync, mapFn, mapKeys, mapObject, mapObjectAsync, mapParallelAsync, mapPropObject, match, maxBy, merge, mergeTypes, minBy, modifyItemAtIndex, modifyPath, modifyProp, none, objOf, objectIncludes, omit, partition, partitionObject, path, pathSatisfies, permutations, pick, pipe, pipeAsync, pluck, prepend, prop, propEq, propOr, propSatisfies, range, rangeDescending, reduce, reject, rejectObject, replace, replaceAll, shuffle, sort, sortBy, sortByDescending, sortByFn, sortByPath, sortByPathDescending, sortObject, sortWith, split, splitEvery, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, transformFlatObject, tryCatch, type, union, unionWith, uniq, uniqBy, uniqWith, unless, unwind, update, when, zip, zipWith };
|