rambda 10.3.2 → 10.3.4
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 +19 -1
- package/README.md +263 -174
- package/dist/rambda.cjs +12 -2
- package/dist/rambda.js +12 -2
- package/dist/rambda.umd.js +12 -2
- package/index.d.cts +20 -27
- package/index.d.ts +20 -27
- package/package.json +11 -10
- package/src/mapParallelAsync.js +12 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ const result = pipe(
|
|
|
21
21
|
//=> [6, 8]
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
You can test this example in <a href="https://rambda.
|
|
24
|
+
You can test this example in <a href="https://rambda.netlify.app/?const%20result%20%3D%20R.pipe(%0A%20%20%5B1%2C%202%2C%203%2C%204%5D%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%202)%2C%0A%20%20R.map(x%20%3D%3E%20x%20*%202)%2C%0A)%0A%2F%2F%20%3D%3E%20%5B6%2C%208%5D">Rambda's REPL</a>
|
|
25
25
|
|
|
26
26
|
* [API](#api)
|
|
27
27
|
* [Changelog](#-changelog)
|
|
@@ -183,7 +183,7 @@ const result = R.pipe(
|
|
|
183
183
|
// => { a: 1, b: 'foo', c: 3 }
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
186
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%7B%20a%3A%201%2C%20b%3A%20'foo'%20%7D%2C%0A%09R.addProp('c'%2C%203)%0A)%0A%2F%2F%20%3D%3E%20%7B%20a%3A%201%2C%20b%3A%20'foo'%2C%20c%3A%203%20%7D">Try this <strong>R.addProp</strong> example in Rambda REPL</a>
|
|
187
187
|
|
|
188
188
|
<details>
|
|
189
189
|
|
|
@@ -278,7 +278,7 @@ const result = R.pipe(
|
|
|
278
278
|
// => [{a: 1, b: 2, c: '3'}, {a: 3, b: 4, c: '7'}]
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
281
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%5B%0A%09%09%7Ba%3A%201%2C%20b%3A%202%7D%2C%0A%09%09%7Ba%3A%203%2C%20b%3A%204%7D%2C%0A%09%5D%2C%0A%09R.addPropToObjects(%0A%09%09'c'%2C%0A%09%09(x)%20%3D%3E%20String(x.a%20%2B%20x.b)%2C%0A%09)%0A)%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A%201%2C%20b%3A%202%2C%20c%3A%20'3'%7D%2C%20%7Ba%3A%203%2C%20b%3A%204%2C%20c%3A%20'7'%7D%5D">Try this <strong>R.addPropToObjects</strong> example in Rambda REPL</a>
|
|
282
282
|
|
|
283
283
|
<details>
|
|
284
284
|
|
|
@@ -393,7 +393,7 @@ const result = R.pipe(
|
|
|
393
393
|
) // => true
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
396
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%200%2C%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%20-1%0A%0Aconst%20result%20%3D%20R.pipe(%0A%09list%2C%0A%09R.all(predicate)%0A)%20%2F%2F%20%3D%3E%20true">Try this <strong>R.all</strong> example in Rambda REPL</a>
|
|
397
397
|
|
|
398
398
|
<details>
|
|
399
399
|
|
|
@@ -491,7 +491,7 @@ const result = R.pipe(
|
|
|
491
491
|
) // => [[1, 2, 3, 4]]
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
494
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%5B1%2C%202%2C%203%2C%204%5D%2C%20%5B3%2C%204%2C%205%5D%5D%0Aconst%20result%20%3D%20R.pipe(%0A%09list%2C%0A%09R.filter(R.allPass(%5BR.includes(2)%2C%20R.includes(3)%5D))%0A)%20%2F%2F%20%3D%3E%20%5B%5B1%2C%202%2C%203%2C%204%5D%5D">Try this <strong>R.allPass</strong> example in Rambda REPL</a>
|
|
495
495
|
|
|
496
496
|
<details>
|
|
497
497
|
|
|
@@ -591,7 +591,7 @@ R.any(predicate)(list)
|
|
|
591
591
|
// => true
|
|
592
592
|
```
|
|
593
593
|
|
|
594
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
594
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20*%20x%20%3E%208%0Aconst%20result%20%3D%20R.any(predicate)(list)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.any</strong> example in Rambda REPL</a>
|
|
595
595
|
|
|
596
596
|
<details>
|
|
597
597
|
|
|
@@ -688,7 +688,7 @@ const result = fn(input)
|
|
|
688
688
|
// => true
|
|
689
689
|
```
|
|
690
690
|
|
|
691
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
691
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20isBig%20%3D%20x%20%3D%3E%20x%20%3E%2020%0Aconst%20isOdd%20%3D%20x%20%3D%3E%20x%20%25%202%20%3D%3D%3D%201%0Aconst%20input%20%3D%2011%0A%0Aconst%20fn%20%3D%20R.anyPass(%0A%20%20%5BisBig%2C%20isOdd%5D%0A)%0A%0Aconst%20result%20%3D%20fn(input)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.anyPass</strong> example in Rambda REPL</a>
|
|
692
692
|
|
|
693
693
|
<details>
|
|
694
694
|
|
|
@@ -838,7 +838,7 @@ const result = R.append('foo')(['bar', 'baz'])
|
|
|
838
838
|
// => ['bar', 'baz', 'foo']
|
|
839
839
|
```
|
|
840
840
|
|
|
841
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
841
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.append('foo')(%5B'bar'%2C%20'baz'%5D)%0A%2F%2F%20%3D%3E%20%5B'bar'%2C%20'baz'%2C%20'foo'%5D">Try this <strong>R.append</strong> example in Rambda REPL</a>
|
|
842
842
|
|
|
843
843
|
<details>
|
|
844
844
|
|
|
@@ -930,7 +930,7 @@ const result = R.pipe(
|
|
|
930
930
|
// => [{a: 0}, {a: 1}, {a: 2}]
|
|
931
931
|
```
|
|
932
932
|
|
|
933
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
933
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%5B%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%2C%20%7Ba%3A%200%7D%5D%2C%0A%09R.sort(R.ascend(R.prop('a')))%0A)%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A%200%7D%2C%20%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%5D">Try this <strong>R.ascend</strong> example in Rambda REPL</a>
|
|
934
934
|
|
|
935
935
|
<details>
|
|
936
936
|
|
|
@@ -1136,7 +1136,7 @@ const result = condition(input)
|
|
|
1136
1136
|
// => true
|
|
1137
1137
|
```
|
|
1138
1138
|
|
|
1139
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1139
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20condition%20%3D%20R.checkObjectWithSpec(%7B%0A%20%20a%20%3A%20x%20%3D%3E%20typeof%20x%20%3D%3D%3D%20%22string%22%2C%0A%20%20b%20%3A%20x%20%3D%3E%20x%20%3D%3D%3D%204%0A%7D)%0Aconst%20input%20%3D%20%7B%0A%20%20a%20%3A%20%22foo%22%2C%0A%20%20b%20%3A%204%2C%0A%20%20c%20%3A%2011%2C%0A%7D%0A%0Aconst%20result%20%3D%20condition(input)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.checkObjectWithSpec</strong> example in Rambda REPL</a>
|
|
1140
1140
|
|
|
1141
1141
|
<details>
|
|
1142
1142
|
|
|
@@ -1272,7 +1272,7 @@ const result = R.pipe(
|
|
|
1272
1272
|
// => { a: ['a', 'b', 'c'], b: [1, 2, 3], c: { a: 1, b: 2, c: 0, f: false } }
|
|
1273
1273
|
```
|
|
1274
1274
|
|
|
1275
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1275
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%7B%0A%09%09a%3A%20%5B%20undefined%2C%20''%2C%20'a'%2C%20'b'%2C%20'c'%5D%2C%0A%09%09b%3A%20%5B1%2C2%2C%20null%2C%200%2C%20undefined%2C%203%5D%2C%0A%09%09c%3A%20%7B%20a%3A%201%2C%20b%3A%202%2C%20c%3A%200%2C%20d%3A%20undefined%2C%20e%3A%20null%2C%20f%3A%20false%20%7D%2C%0A%09%7D%2C%0A%09x%20%3D%3E%20(%7B%0A%09%09a%3A%20R.compact(x.a)%2C%0A%09%09b%3A%20R.compact(x.b)%2C%0A%09%09c%3A%20R.compact(x.c)%0A%09%7D)%0A)%0A%2F%2F%20%3D%3E%20%7B%20a%3A%20%5B'a'%2C%20'b'%2C%20'c'%5D%2C%20b%3A%20%5B1%2C%202%2C%203%5D%2C%20c%3A%20%7B%20a%3A%201%2C%20b%3A%202%2C%20c%3A%200%2C%20f%3A%20false%20%7D%20%7D">Try this <strong>R.compact</strong> example in Rambda REPL</a>
|
|
1276
1276
|
|
|
1277
1277
|
<details>
|
|
1278
1278
|
|
|
@@ -1392,7 +1392,7 @@ const result = [
|
|
|
1392
1392
|
] => [ true, false ]
|
|
1393
1393
|
```
|
|
1394
1394
|
|
|
1395
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1395
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20x%20%3D%3E%20x%20%3E%205%0Aconst%20inverted%20%3D%20complement(fn)%0A%0Aconst%20result%20%3D%20%5B%0A%20%20fn(7)%2C%0A%20%20inverted(7)%0A%5D%20%3D%3E%20%5B%20true%2C%20false%20%5D">Try this <strong>R.complement</strong> example in Rambda REPL</a>
|
|
1396
1396
|
|
|
1397
1397
|
<details>
|
|
1398
1398
|
|
|
@@ -1473,7 +1473,7 @@ R.concat([1, 2])([3, 4]) // => [1, 2, 3, 4]
|
|
|
1473
1473
|
R.concat('foo')('bar') // => 'foobar'
|
|
1474
1474
|
```
|
|
1475
1475
|
|
|
1476
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1476
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?R.concat(%5B1%2C%202%5D)(%5B3%2C%204%5D)%20%2F%2F%20%3D%3E%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20result%20%3D%20R.concat('foo')('bar')%20%2F%2F%20%3D%3E%20'foobar'">Try this <strong>R.concat</strong> example in Rambda REPL</a>
|
|
1477
1477
|
|
|
1478
1478
|
<details>
|
|
1479
1479
|
|
|
@@ -1592,7 +1592,7 @@ const result = R.count(x => x.a !== undefined)(list)
|
|
|
1592
1592
|
// => 2
|
|
1593
1593
|
```
|
|
1594
1594
|
|
|
1595
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1595
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%7Ba%3A%201%7D%2C%201%2C%20%7Ba%3A2%7D%5D%0Aconst%20result%20%3D%20R.count(x%20%3D%3E%20x.a%20!%3D%3D%20undefined)(list)%0A%2F%2F%20%3D%3E%202">Try this <strong>R.count</strong> example in Rambda REPL</a>
|
|
1596
1596
|
|
|
1597
1597
|
<details>
|
|
1598
1598
|
|
|
@@ -1683,7 +1683,7 @@ const expected = { a: 2, b: 2, c: 2 }
|
|
|
1683
1683
|
// => `result` is equal to `expected`
|
|
1684
1684
|
```
|
|
1685
1685
|
|
|
1686
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1686
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%20'a'%2C%20'A'%2C%20'b'%2C%20'B'%2C%20'c'%2C%20'C'%20%5D%0A%0Aconst%20result%20%3D%20countBy(x%20%3D%3E%20x.toLowerCase())(%20list)%0Aconst%20expected%20%3D%20%7B%20a%3A%202%2C%20b%3A%202%2C%20c%3A%202%20%7D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.countBy</strong> example in Rambda REPL</a>
|
|
1687
1687
|
|
|
1688
1688
|
<details>
|
|
1689
1689
|
|
|
@@ -1781,7 +1781,7 @@ const result = R.createObjectFromKeys(
|
|
|
1781
1781
|
// => {a: 'a-0', b: 'b-1', c: 'c-2'}
|
|
1782
1782
|
```
|
|
1783
1783
|
|
|
1784
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1784
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.createObjectFromKeys(%0A%09(x%2C%20index)%20%3D%3E%20%60%24%7Bx%7D-%24%7Bindex%7D%60%0A)(%5B'a'%2C%20'b'%2C%20'c'%5D)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-0'%2C%20b%3A%20'b-1'%2C%20c%3A%20'c-2'%7D">Try this <strong>R.createObjectFromKeys</strong> example in Rambda REPL</a>
|
|
1785
1785
|
|
|
1786
1786
|
<details>
|
|
1787
1787
|
|
|
@@ -1857,7 +1857,7 @@ R.defaultTo('foo'))(undefined) // => 'foo'
|
|
|
1857
1857
|
R.defaultTo('foo')('') // => 'foo'
|
|
1858
1858
|
```
|
|
1859
1859
|
|
|
1860
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1860
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?R.defaultTo('foo')('bar')%20%2F%2F%20%3D%3E%20'bar'%0AR.defaultTo('foo'))(undefined)%20%2F%2F%20%3D%3E%20'foo'%0A%0A%2F%2F%20Important%20-%20emtpy%20string%20is%20not%20falsy%20value%0Aconst%20result%20%3D%20R.defaultTo('foo')('')%20%2F%2F%20%3D%3E%20'foo'">Try this <strong>R.defaultTo</strong> example in Rambda REPL</a>
|
|
1861
1861
|
|
|
1862
1862
|
<details>
|
|
1863
1863
|
|
|
@@ -1956,7 +1956,7 @@ const result = R.pipe(
|
|
|
1956
1956
|
// => [{a: 2}, {a: 1}, {a: 0}]
|
|
1957
1957
|
```
|
|
1958
1958
|
|
|
1959
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
1959
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%5B%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%2C%20%7Ba%3A%200%7D%5D%2C%0A%09R.sort(R.descend(R.prop('a')))%0A)%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A%202%7D%2C%20%7Ba%3A%201%7D%2C%20%7Ba%3A%200%7D%5D">Try this <strong>R.descend</strong> example in Rambda REPL</a>
|
|
1960
1960
|
|
|
1961
1961
|
<details>
|
|
1962
1962
|
|
|
@@ -2002,7 +2002,7 @@ It returns `howMany` items dropped from beginning of list.
|
|
|
2002
2002
|
R.drop(2)(['foo', 'bar', 'baz']) // => ['baz']
|
|
2003
2003
|
```
|
|
2004
2004
|
|
|
2005
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2005
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.drop(2)(%5B'foo'%2C%20'bar'%2C%20'baz'%5D)%20%2F%2F%20%3D%3E%20%5B'baz'%5D">Try this <strong>R.drop</strong> example in Rambda REPL</a>
|
|
2006
2006
|
|
|
2007
2007
|
<details>
|
|
2008
2008
|
|
|
@@ -2135,7 +2135,7 @@ const result = dropLastWhile(predicate)(list);
|
|
|
2135
2135
|
// => [1, 2]
|
|
2136
2136
|
```
|
|
2137
2137
|
|
|
2138
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2138
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%5D%3B%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%3D%203%0A%0Aconst%20result%20%3D%20dropLastWhile(predicate)(list)%3B%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.dropLastWhile</strong> example in Rambda REPL</a>
|
|
2139
2139
|
|
|
2140
2140
|
<details>
|
|
2141
2141
|
|
|
@@ -2219,7 +2219,7 @@ const result = R.dropRepeatsBy(
|
|
|
2219
2219
|
// => [1, 2, 3]
|
|
2220
2220
|
```
|
|
2221
2221
|
|
|
2222
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2222
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.dropRepeatsBy(%0A%20%20Math.abs%2C%0A%20%20%5B1%2C%20-1%2C%202%2C%203%2C%20-3%5D%0A)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%2C%203%5D">Try this <strong>R.dropRepeatsBy</strong> example in Rambda REPL</a>
|
|
2223
2223
|
|
|
2224
2224
|
<details>
|
|
2225
2225
|
|
|
@@ -2247,7 +2247,7 @@ const result = R.dropRepeatsWith(R.prop('a'))(list)
|
|
|
2247
2247
|
// => [{a:1,b:2}, {a:2, b:4}]
|
|
2248
2248
|
```
|
|
2249
2249
|
|
|
2250
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2250
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%7Ba%3A1%2Cb%3A2%7D%2C%20%7Ba%3A1%2Cb%3A3%7D%2C%20%7Ba%3A2%2C%20b%3A4%7D%5D%0Aconst%20result%20%3D%20R.dropRepeatsWith(R.prop('a'))(list)%0A%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A1%2Cb%3A2%7D%2C%20%7Ba%3A2%2C%20b%3A4%7D%5D">Try this <strong>R.dropRepeatsWith</strong> example in Rambda REPL</a>
|
|
2251
2251
|
|
|
2252
2252
|
<details>
|
|
2253
2253
|
|
|
@@ -2275,7 +2275,7 @@ const result = R.dropWhile(predicate)(list)
|
|
|
2275
2275
|
// => [3, 4]
|
|
2276
2276
|
```
|
|
2277
2277
|
|
|
2278
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2278
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3C%203%0Aconst%20result%20%3D%20R.dropWhile(predicate)(list)%0A%2F%2F%20%3D%3E%20%5B3%2C%204%5D">Try this <strong>R.dropWhile</strong> example in Rambda REPL</a>
|
|
2279
2279
|
|
|
2280
2280
|
<details>
|
|
2281
2281
|
|
|
@@ -2394,7 +2394,7 @@ const result = R.duplicateBy(x => x, list)
|
|
|
2394
2394
|
// => [{a:1}]
|
|
2395
2395
|
```
|
|
2396
2396
|
|
|
2397
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2397
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%2C%20%7Ba%3A1%7D%5D%0Aconst%20result%20%3D%20R.duplicateBy(x%20%3D%3E%20x%2C%20list)%0A%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A1%7D%5D">Try this <strong>R.duplicateBy</strong> example in Rambda REPL</a>
|
|
2398
2398
|
|
|
2399
2399
|
<details>
|
|
2400
2400
|
|
|
@@ -2462,7 +2462,7 @@ const result = R.eqBy(Math.abs, 5)(-5)
|
|
|
2462
2462
|
// => true
|
|
2463
2463
|
```
|
|
2464
2464
|
|
|
2465
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2465
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.eqBy(Math.abs%2C%205)(-5)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.eqBy</strong> example in Rambda REPL</a>
|
|
2466
2466
|
|
|
2467
2467
|
<details>
|
|
2468
2468
|
|
|
@@ -2531,7 +2531,7 @@ const result = R.eqProps('a', obj1)(obj2)
|
|
|
2531
2531
|
// => true
|
|
2532
2532
|
```
|
|
2533
2533
|
|
|
2534
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2534
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj1%20%3D%20%7Ba%3A%201%2C%20b%3A2%7D%0Aconst%20obj2%20%3D%20%7Ba%3A%201%2C%20b%3A3%7D%0Aconst%20result%20%3D%20R.eqProps('a'%2C%20obj1)(obj2)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.eqProps</strong> example in Rambda REPL</a>
|
|
2535
2535
|
|
|
2536
2536
|
<details>
|
|
2537
2537
|
|
|
@@ -2630,7 +2630,7 @@ R.equals(
|
|
|
2630
2630
|
) // => true
|
|
2631
2631
|
```
|
|
2632
2632
|
|
|
2633
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
2633
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?R.equals(%0A%20%20%5B1%2C%20%7Ba%3A2%7D%2C%20%5B%7Bb%3A%203%7D%5D%5D%2C%0A%20%20%5B1%2C%20%7Ba%3A2%7D%2C%20%5B%7Bb%3A%203%7D%5D%5D%0Aconst%20result%20%3D%20)%20%2F%2F%20%3D%3E%20true">Try this <strong>R.equals</strong> example in Rambda REPL</a>
|
|
2634
2634
|
|
|
2635
2635
|
<details>
|
|
2636
2636
|
|
|
@@ -3122,7 +3122,7 @@ const result = R.pipe(
|
|
|
3122
3122
|
// => result is { foo: 3, baz: 'baz' }
|
|
3123
3123
|
```
|
|
3124
3124
|
|
|
3125
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3125
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20input%20%3D%20%7B%0A%09foo%3A%202%2C%0A%09baz%3A%20'baz'%2C%0A%7D%0Aconst%20result%20%3D%20R.pipe(%0A%09input%2C%0A%09R.evolve(%7B%0A%09%09foo%3A%20x%20%3D%3E%20x%20%2B%201%2C%0A%09%7D)%0A)%0A%2F%2F%20%3D%3E%20result%20is%20%7B%20foo%3A%203%2C%20baz%3A%20'baz'%20%7D">Try this <strong>R.evolve</strong> example in Rambda REPL</a>
|
|
3126
3126
|
|
|
3127
3127
|
<details>
|
|
3128
3128
|
|
|
@@ -3228,7 +3228,7 @@ const result = [
|
|
|
3228
3228
|
// => [true, true ]
|
|
3229
3229
|
```
|
|
3230
3230
|
|
|
3231
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3231
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.excludes('ar')('foo')%2C%0A%20%20R.excludes(%7Ba%3A%202%7D)(%5B%7Ba%3A%201%7D%5D)%0A%5D%0A%2F%2F%20%3D%3E%20%5Btrue%2C%20true%20%5D">Try this <strong>R.excludes</strong> example in Rambda REPL</a>
|
|
3232
3232
|
|
|
3233
3233
|
<details>
|
|
3234
3234
|
|
|
@@ -3321,7 +3321,7 @@ const result = R.filter(predicate)(list)
|
|
|
3321
3321
|
// => [2, 3]
|
|
3322
3322
|
```
|
|
3323
3323
|
|
|
3324
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3324
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%201%0Aconst%20list%20%3D%20%5B1%2C%202%2C%203%5D%0Aconst%20result%20%3D%20R.filter(predicate)(list)%0A%2F%2F%20%3D%3E%20%5B2%2C%203%5D">Try this <strong>R.filter</strong> example in Rambda REPL</a>
|
|
3325
3325
|
|
|
3326
3326
|
<details>
|
|
3327
3327
|
|
|
@@ -3583,7 +3583,7 @@ const result = R.filterObject(
|
|
|
3583
3583
|
// => {a: 1, c: 3}
|
|
3584
3584
|
```
|
|
3585
3585
|
|
|
3586
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3586
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.filterObject(%0A%09(val%2C%20prop)%20%3D%3E%20prop%20%3D%3D%3D%20'a'%20%7C%7C%20val%20%3E%201%0A)(%7Ba%3A%201%2C%20b%3A%202%2C%20c%3A3%7D)%0A%2F%2F%20%3D%3E%20%7Ba%3A%201%2C%20c%3A%203%7D">Try this <strong>R.filterObject</strong> example in Rambda REPL</a>
|
|
3587
3587
|
|
|
3588
3588
|
<details>
|
|
3589
3589
|
|
|
@@ -3691,7 +3691,7 @@ const result = R.find(predicate)(list)
|
|
|
3691
3691
|
// => {foo: 1}
|
|
3692
3692
|
```
|
|
3693
3693
|
|
|
3694
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3694
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20R.type(x.foo)%20%3D%3D%3D%20'Number'%0Aconst%20list%20%3D%20%5B%7Bfoo%3A%20'bar'%7D%2C%20%7Bfoo%3A%201%7D%5D%0A%0Aconst%20result%20%3D%20R.find(predicate)(list)%0A%2F%2F%20%3D%3E%20%7Bfoo%3A%201%7D">Try this <strong>R.find</strong> example in Rambda REPL</a>
|
|
3695
3695
|
|
|
3696
3696
|
<details>
|
|
3697
3697
|
|
|
@@ -3795,7 +3795,7 @@ const result = R.findIndex(predicate)(list)
|
|
|
3795
3795
|
// => 1
|
|
3796
3796
|
```
|
|
3797
3797
|
|
|
3798
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3798
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20R.type(x.foo)%20%3D%3D%3D%20'Number'%0Aconst%20list%20%3D%20%5B%7Bfoo%3A%20'bar'%7D%2C%20%7Bfoo%3A%201%7D%5D%0A%0Aconst%20result%20%3D%20R.findIndex(predicate)(list)%0A%2F%2F%20%3D%3E%201">Try this <strong>R.findIndex</strong> example in Rambda REPL</a>
|
|
3799
3799
|
|
|
3800
3800
|
<details>
|
|
3801
3801
|
|
|
@@ -3890,7 +3890,7 @@ const result = R.findLast(predicate)(list)
|
|
|
3890
3890
|
// => {foo: 1}
|
|
3891
3891
|
```
|
|
3892
3892
|
|
|
3893
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3893
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20R.type(x.foo)%20%3D%3D%3D%20'Number'%0Aconst%20list%20%3D%20%5B%7Bfoo%3A%200%7D%2C%20%7Bfoo%3A%201%7D%5D%0A%0Aconst%20result%20%3D%20R.findLast(predicate)(list)%0A%2F%2F%20%3D%3E%20%7Bfoo%3A%201%7D">Try this <strong>R.findLast</strong> example in Rambda REPL</a>
|
|
3894
3894
|
|
|
3895
3895
|
<details>
|
|
3896
3896
|
|
|
@@ -3945,7 +3945,7 @@ const result = R.findLastIndex(predicate)(list)
|
|
|
3945
3945
|
// => 1
|
|
3946
3946
|
```
|
|
3947
3947
|
|
|
3948
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
3948
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20R.type(x.foo)%20%3D%3D%3D%20'Number'%0Aconst%20list%20%3D%20%5B%7Bfoo%3A%200%7D%2C%20%7Bfoo%3A%201%7D%5D%0A%0Aconst%20result%20%3D%20R.findLastIndex(predicate)(list)%0A%2F%2F%20%3D%3E%201">Try this <strong>R.findLastIndex</strong> example in Rambda REPL</a>
|
|
3949
3949
|
|
|
3950
3950
|
<details>
|
|
3951
3951
|
|
|
@@ -4034,7 +4034,7 @@ const result = R.findNth(predicate, 2)(list)
|
|
|
4034
4034
|
// => {foo: 2}
|
|
4035
4035
|
```
|
|
4036
4036
|
|
|
4037
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4037
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20R.type(x.foo)%20%3D%3D%3D%20'Number'%0Aconst%20list%20%3D%20%5B%7Bfoo%3A%200%7D%2C%20%7Bfoo%3A%201%7D%2C%20%7Bfoo%3A%202%7D%2C%20%7Bfoo%3A%203%7D%5D%0A%0Aconst%20result%20%3D%20R.findNth(predicate%2C%202)(list)%0A%2F%2F%20%3D%3E%20%7Bfoo%3A%202%7D">Try this <strong>R.findNth</strong> example in Rambda REPL</a>
|
|
4038
4038
|
|
|
4039
4039
|
<details>
|
|
4040
4040
|
|
|
@@ -4112,7 +4112,7 @@ const result = R.flatMap(duplicate)(list)
|
|
|
4112
4112
|
// => [ 1, 1, 2, 2, 3, 3 ]
|
|
4113
4113
|
```
|
|
4114
4114
|
|
|
4115
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4115
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20duplicate%20%3D%20n%20%3D%3E%20%5B%20n%2C%20n%20%5D%0Aconst%20list%20%3D%20%5B%201%2C%202%2C%203%20%5D%0A%0Aconst%20result%20%3D%20R.flatMap(duplicate)(list)%0A%2F%2F%20%3D%3E%20%5B%201%2C%201%2C%202%2C%202%2C%203%2C%203%20%5D">Try this <strong>R.flatMap</strong> example in Rambda REPL</a>
|
|
4116
4116
|
|
|
4117
4117
|
<details>
|
|
4118
4118
|
|
|
@@ -4233,7 +4233,7 @@ const result = R.flatten<number>([
|
|
|
4233
4233
|
// => [ 1, 2, 3, 30, 300, 4 ]
|
|
4234
4234
|
```
|
|
4235
4235
|
|
|
4236
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4236
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.flatten%3Cnumber%3E(%5B%0A%20%201%2C%0A%20%202%2C%0A%20%20%5B3%2C%2030%2C%20%5B300%5D%5D%2C%0A%20%20%5B4%5D%0A%5D)%0A%2F%2F%20%3D%3E%20%5B%201%2C%202%2C%203%2C%2030%2C%20300%2C%204%20%5D">Try this <strong>R.flatten</strong> example in Rambda REPL</a>
|
|
4237
4237
|
|
|
4238
4238
|
<details>
|
|
4239
4239
|
|
|
@@ -4331,7 +4331,7 @@ const result = R.flattenObject(
|
|
|
4331
4331
|
// => [3, 1, 2] or [2, 3, 1] or ...
|
|
4332
4332
|
```
|
|
4333
4333
|
|
|
4334
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4334
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.flattenObject(%0A%09%5B1%2C%202%2C%203%5D%0A)%0A%2F%2F%20%3D%3E%20%5B3%2C%201%2C%202%5D%20or%20%5B2%2C%203%2C%201%5D%20or%20...">Try this <strong>R.flattenObject</strong> example in Rambda REPL</a>
|
|
4335
4335
|
|
|
4336
4336
|
<details>
|
|
4337
4337
|
|
|
@@ -4555,7 +4555,7 @@ const result = R.groupBy(groupFn, list)
|
|
|
4555
4555
|
// => { '1': ['a', 'b'], '2': ['aa', 'bb'] }
|
|
4556
4556
|
```
|
|
4557
4557
|
|
|
4558
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4558
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%20'a'%2C%20'b'%2C%20'aa'%2C%20'bb'%20%5D%0Aconst%20groupFn%20%3D%20x%20%3D%3E%20x.length%0A%0Aconst%20result%20%3D%20R.groupBy(groupFn%2C%20list)%0A%2F%2F%20%3D%3E%20%7B%20'1'%3A%20%5B'a'%2C%20'b'%5D%2C%20'2'%3A%20%5B'aa'%2C%20'bb'%5D%20%7D">Try this <strong>R.groupBy</strong> example in Rambda REPL</a>
|
|
4559
4559
|
|
|
4560
4560
|
<details>
|
|
4561
4561
|
|
|
@@ -4672,7 +4672,7 @@ const result = [
|
|
|
4672
4672
|
// => [1, 'f']
|
|
4673
4673
|
```
|
|
4674
4674
|
|
|
4675
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4675
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.head(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.head('foo')%0A%5D%0A%2F%2F%20%3D%3E%20%5B1%2C%20'f'%5D">Try this <strong>R.head</strong> example in Rambda REPL</a>
|
|
4676
4676
|
|
|
4677
4677
|
<details>
|
|
4678
4678
|
|
|
@@ -4795,7 +4795,7 @@ const result = [
|
|
|
4795
4795
|
// => [true, true ]
|
|
4796
4796
|
```
|
|
4797
4797
|
|
|
4798
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4798
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.includes('oo')('foo')%2C%0A%20%20R.includes(%7Ba%3A%201%7D)(%5B%7Ba%3A%201%7D%5D)%0A%5D%0A%2F%2F%20%3D%3E%20%5Btrue%2C%20true%20%5D">Try this <strong>R.includes</strong> example in Rambda REPL</a>
|
|
4799
4799
|
|
|
4800
4800
|
<details>
|
|
4801
4801
|
|
|
@@ -4927,7 +4927,7 @@ const result = R.indexBy(
|
|
|
4927
4927
|
// => {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
|
|
4928
4928
|
```
|
|
4929
4929
|
|
|
4930
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
4930
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.indexBy(%0A%09'id'%0A)(%5B%7Bid%3A%20'xyz'%2C%20title%3A%20'A'%7D%2C%20%7Bid%3A%20'abc'%2C%20title%3A%20'B'%7D%5D)%0A%2F%2F%20%3D%3E%20%7Babc%3A%20%7Bid%3A%20'abc'%2C%20title%3A%20'B'%7D%2C%20xyz%3A%20%7Bid%3A%20'xyz'%2C%20title%3A%20'A'%7D%7D">Try this <strong>R.indexBy</strong> example in Rambda REPL</a>
|
|
4931
4931
|
|
|
4932
4932
|
<details>
|
|
4933
4933
|
|
|
@@ -5029,7 +5029,7 @@ const result = [
|
|
|
5029
5029
|
// => [0, 1]
|
|
5030
5030
|
```
|
|
5031
5031
|
|
|
5032
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5032
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.indexOf(%7Ba%3A1%7D)(%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%5D)%2C%0A%20%20R.indexOf(2)(%5B1%2C%202%2C%203%5D)%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B0%2C%201%5D">Try this <strong>R.indexOf</strong> example in Rambda REPL</a>
|
|
5033
5033
|
|
|
5034
5034
|
<details>
|
|
5035
5035
|
|
|
@@ -5129,7 +5129,7 @@ const result = [
|
|
|
5129
5129
|
// => [[1, 2], 'fo']
|
|
5130
5130
|
```
|
|
5131
5131
|
|
|
5132
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5132
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.init(%5B1%2C%202%2C%203%5D)%20%2C%0A%20%20R.init('foo')%20%20%2F%2F%20%3D%3E%20'fo'%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%202%5D%2C%20'fo'%5D">Try this <strong>R.init</strong> example in Rambda REPL</a>
|
|
5133
5133
|
|
|
5134
5134
|
<details>
|
|
5135
5135
|
|
|
@@ -5235,7 +5235,7 @@ const result = R.innerJoin(predicate, list1)(list2)
|
|
|
5235
5235
|
// => [4, 5]
|
|
5236
5236
|
```
|
|
5237
5237
|
|
|
5238
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5238
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list1%20%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%5D%0Aconst%20list2%20%3D%20%5B4%2C%205%2C%206%5D%0Aconst%20predicate%20%3D%20(x%2C%20y)%20%3D%3E%20x%20%3E%3D%20y%0Aconst%20result%20%3D%20R.innerJoin(predicate%2C%20list1)(list2)%0A%2F%2F%20%3D%3E%20%5B4%2C%205%5D">Try this <strong>R.innerJoin</strong> example in Rambda REPL</a>
|
|
5239
5239
|
|
|
5240
5240
|
<details>
|
|
5241
5241
|
|
|
@@ -5357,7 +5357,7 @@ const expected = 'foo is BAR even 1 more'
|
|
|
5357
5357
|
// => `result` is equal to `expected`
|
|
5358
5358
|
```
|
|
5359
5359
|
|
|
5360
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5360
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20inputWithTags%20%3D%20'foo%20is%20%7B%7Bbar%7D%7D%20even%20%7B%7Ba%7D%7D%20more'%0Aconst%20templateArguments%20%3D%20%7B%22bar%22%3A%22BAR%22%2C%20a%3A%201%7D%0A%0Aconst%20result%20%3D%20R.interpolate(inputWithTags%2C%20templateArguments)%0Aconst%20expected%20%3D%20'foo%20is%20BAR%20even%201%20more'%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.interpolate</strong> example in Rambda REPL</a>
|
|
5361
5361
|
|
|
5362
5362
|
<details>
|
|
5363
5363
|
|
|
@@ -5466,7 +5466,7 @@ const result = R.intersection(listA)(listB)
|
|
|
5466
5466
|
// => [{ id : 3 }, { id : 4 }]
|
|
5467
5467
|
```
|
|
5468
5468
|
|
|
5469
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5469
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20listA%20%3D%20%5B%20%7B%20id%20%3A%201%20%7D%2C%20%7B%20id%20%3A%202%20%7D%2C%20%7B%20id%20%3A%203%20%7D%2C%20%7B%20id%20%3A%204%20%7D%20%5D%0Aconst%20listB%20%3D%20%5B%20%7B%20id%20%3A%203%20%7D%2C%20%7B%20id%20%3A%204%20%7D%2C%20%7B%20id%20%3A%205%20%7D%2C%20%7B%20id%20%3A%206%20%7D%20%5D%0A%0Aconst%20result%20%3D%20R.intersection(listA)(listB)%0A%2F%2F%20%3D%3E%20%5B%7B%20id%20%3A%203%20%7D%2C%20%7B%20id%20%3A%204%20%7D%5D">Try this <strong>R.intersection</strong> example in Rambda REPL</a>
|
|
5470
5470
|
|
|
5471
5471
|
<details>
|
|
5472
5472
|
|
|
@@ -5561,7 +5561,7 @@ const result = R.intersperse(separator)(list)
|
|
|
5561
5561
|
// => [0, 10, 1, 10, 2, 10, 3]
|
|
5562
5562
|
```
|
|
5563
5563
|
|
|
5564
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5564
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%200%2C%201%2C%202%2C%203%20%5D%0Aconst%20separator%20%3D%2010%0Aconst%20result%20%3D%20R.intersperse(separator)(list)%0A%2F%2F%20%3D%3E%20%5B0%2C%2010%2C%201%2C%2010%2C%202%2C%2010%2C%203%5D">Try this <strong>R.intersperse</strong> example in Rambda REPL</a>
|
|
5565
5565
|
|
|
5566
5566
|
<details>
|
|
5567
5567
|
|
|
@@ -5656,7 +5656,7 @@ It returns a string of all `list` instances joined with a `glue`.
|
|
|
5656
5656
|
R.join('-', [1, 2, 3]) // => '1-2-3'
|
|
5657
5657
|
```
|
|
5658
5658
|
|
|
5659
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5659
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.join('-'%2C%20%5B1%2C%202%2C%203%5D)%20%20%2F%2F%20%3D%3E%20'1-2-3'">Try this <strong>R.join</strong> example in Rambda REPL</a>
|
|
5660
5660
|
|
|
5661
5661
|
<details>
|
|
5662
5662
|
|
|
@@ -5721,7 +5721,7 @@ const result = [
|
|
|
5721
5721
|
// => [3, 'o']
|
|
5722
5722
|
```
|
|
5723
5723
|
|
|
5724
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5724
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.last(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.last('foo')%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B3%2C%20'o'%5D">Try this <strong>R.last</strong> example in Rambda REPL</a>
|
|
5725
5725
|
|
|
5726
5726
|
<details>
|
|
5727
5727
|
|
|
@@ -5800,7 +5800,7 @@ const result = [
|
|
|
5800
5800
|
// => [4, -1]
|
|
5801
5801
|
```
|
|
5802
5802
|
|
|
5803
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5803
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%2C%201%2C%202%2C%203%5D%0Aconst%20result%20%3D%20%5B%0A%20%20R.lastIndexOf(2)(list)%2C%0A%20%20R.lastIndexOf(4)(list)%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B4%2C%20-1%5D">Try this <strong>R.lastIndexOf</strong> example in Rambda REPL</a>
|
|
5804
5804
|
|
|
5805
5805
|
<details>
|
|
5806
5806
|
|
|
@@ -5885,13 +5885,13 @@ describe('R.lastIndexOf', () => {
|
|
|
5885
5885
|
```typescript
|
|
5886
5886
|
|
|
5887
5887
|
map<T extends IterableContainer, U>(
|
|
5888
|
-
|
|
5888
|
+
fn: (value: T[number], index: number) => U,
|
|
5889
5889
|
): (data: T) => Mapped<T, U>
|
|
5890
5890
|
```
|
|
5891
5891
|
|
|
5892
5892
|
It returns the result of looping through `iterable` with `fn`.
|
|
5893
5893
|
|
|
5894
|
-
|
|
5894
|
+
> :boom: This function doesn't work with objects (use R.mapObject instead)
|
|
5895
5895
|
|
|
5896
5896
|
```javascript
|
|
5897
5897
|
const fn = x => x * 2
|
|
@@ -5903,7 +5903,7 @@ const result = R.map(fn)(iterable),
|
|
|
5903
5903
|
// => [2, 4]
|
|
5904
5904
|
```
|
|
5905
5905
|
|
|
5906
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
5906
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20x%20%3D%3E%20x%20*%202%0A%0Aconst%20iterable%20%3D%20%5B1%2C%202%5D%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.map(fn)(iterable)%2C%0A%2F%2F%20%3D%3E%20%5B2%2C%204%5D">Try this <strong>R.map</strong> example in Rambda REPL</a>
|
|
5907
5907
|
|
|
5908
5908
|
<details>
|
|
5909
5909
|
|
|
@@ -5911,21 +5911,11 @@ const result = R.map(fn)(iterable),
|
|
|
5911
5911
|
|
|
5912
5912
|
```typescript
|
|
5913
5913
|
map<T extends IterableContainer, U>(
|
|
5914
|
-
|
|
5914
|
+
fn: (value: T[number], index: number) => U,
|
|
5915
5915
|
): (data: T) => Mapped<T, U>;
|
|
5916
5916
|
map<T extends IterableContainer, U>(
|
|
5917
|
-
|
|
5917
|
+
fn: (value: T[number]) => U,
|
|
5918
5918
|
): (data: T) => Mapped<T, U>;
|
|
5919
|
-
map<T extends IterableContainer, U>(
|
|
5920
|
-
fn: (value: T[number], index: number) => U,
|
|
5921
|
-
data: T
|
|
5922
|
-
) : Mapped<T, U>;
|
|
5923
|
-
map<T extends IterableContainer, U>(
|
|
5924
|
-
fn: (value: T[number]) => U,
|
|
5925
|
-
data: T
|
|
5926
|
-
) : Mapped<T, U>;
|
|
5927
|
-
...
|
|
5928
|
-
...
|
|
5929
5919
|
```
|
|
5930
5920
|
|
|
5931
5921
|
</details>
|
|
@@ -5979,7 +5969,7 @@ import { map, pipe } from 'rambda'
|
|
|
5979
5969
|
|
|
5980
5970
|
const list = [1, 2, 3]
|
|
5981
5971
|
|
|
5982
|
-
it('R.map', () => {
|
|
5972
|
+
it('R.map - within pipe', () => {
|
|
5983
5973
|
const result = pipe(
|
|
5984
5974
|
list,
|
|
5985
5975
|
x => x,
|
|
@@ -5990,6 +5980,20 @@ it('R.map', () => {
|
|
|
5990
5980
|
)
|
|
5991
5981
|
result // $ExpectType string[]
|
|
5992
5982
|
})
|
|
5983
|
+
|
|
5984
|
+
it('R.map - without pipe', () => {
|
|
5985
|
+
map(x => {
|
|
5986
|
+
x // $ExpectType unknown
|
|
5987
|
+
})([1, 2, 3])
|
|
5988
|
+
})
|
|
5989
|
+
|
|
5990
|
+
it('R.map - without pipe but explicitly typed', () => {
|
|
5991
|
+
const result = map<number[], string>(x => {
|
|
5992
|
+
x // $ExpectType number
|
|
5993
|
+
return String(x)
|
|
5994
|
+
})([1, 2, 3])
|
|
5995
|
+
result // $ExpectType string[]
|
|
5996
|
+
})
|
|
5993
5997
|
```
|
|
5994
5998
|
|
|
5995
5999
|
</details>
|
|
@@ -6018,7 +6022,7 @@ const result = await R.mapAsync(fn)([1, 2, 3])
|
|
|
6018
6022
|
// `result` resolves after 3 seconds to `[2, 3, 4]`
|
|
6019
6023
|
```
|
|
6020
6024
|
|
|
6021
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6025
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?async%20function%20fn(x)%7B%0A%20%20await%20R.delay(1000)%0A%0A%20%20return%20x%2B1%0A%7D%0A%0Aconst%20result%20%3D%20await%20R.mapAsync(fn)(%5B1%2C%202%2C%203%5D)%0A%2F%2F%20%60result%60%20resolves%20after%203%20seconds%20to%20%60%5B2%2C%203%2C%204%5D%60">Try this <strong>R.mapAsync</strong> example in Rambda REPL</a>
|
|
6022
6026
|
|
|
6023
6027
|
<details>
|
|
6024
6028
|
|
|
@@ -6162,7 +6166,7 @@ const result = R.mapKeys(
|
|
|
6162
6166
|
// => { A1: 1, B2: 2 }
|
|
6163
6167
|
```
|
|
6164
6168
|
|
|
6165
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6169
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.mapKeys(%0A%09(key%2C%20value)%20%3D%3E%20key.toUpperCase()%2Bvalue%0A%09)(%0A%09%7B%20a%3A%201%2C%20b%3A%202%20%7D%0A)%0A%2F%2F%20%3D%3E%20%7B%20A1%3A%201%2C%20B2%3A%202%20%7D">Try this <strong>R.mapKeys</strong> example in Rambda REPL</a>
|
|
6166
6170
|
|
|
6167
6171
|
<details>
|
|
6168
6172
|
|
|
@@ -6253,7 +6257,7 @@ const result = R.mapObject(fn)(obj)
|
|
|
6253
6257
|
// => {a: 'a-1', b: 'b-2'}
|
|
6254
6258
|
```
|
|
6255
6259
|
|
|
6256
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6260
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20(val%2C%20prop)%20%3D%3E%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.mapObject(fn)(obj)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D">Try this <strong>R.mapObject</strong> example in Rambda REPL</a>
|
|
6257
6261
|
|
|
6258
6262
|
<details>
|
|
6259
6263
|
|
|
@@ -6489,22 +6493,22 @@ it('R.mapObjectAsync', async () => {
|
|
|
6489
6493
|
```typescript
|
|
6490
6494
|
|
|
6491
6495
|
mapParallelAsync<T extends IterableContainer, U>(
|
|
6492
|
-
fn: (value: T[number]
|
|
6496
|
+
fn: (value: T[number]) => Promise<U>,
|
|
6497
|
+
batchSize?: number,
|
|
6493
6498
|
): (data: T) => Promise<Mapped<T, U>>
|
|
6494
6499
|
```
|
|
6495
6500
|
|
|
6496
6501
|
Wrapper around `Promise.all` for asynchronous mapping with `fn` over members of `list`.
|
|
6502
|
+
There is optional `batchSize` parameter to allow parallel execution to run in batches. In this case, the whole batch must complete before the next batch starts.
|
|
6497
6503
|
|
|
6498
6504
|
<details>
|
|
6499
6505
|
|
|
6500
6506
|
<summary>All TypeScript definitions</summary>
|
|
6501
6507
|
|
|
6502
6508
|
```typescript
|
|
6503
|
-
mapParallelAsync<T extends IterableContainer, U>(
|
|
6504
|
-
fn: (value: T[number], index: number) => Promise<U>,
|
|
6505
|
-
): (data: T) => Promise<Mapped<T, U>>;
|
|
6506
6509
|
mapParallelAsync<T extends IterableContainer, U>(
|
|
6507
6510
|
fn: (value: T[number]) => Promise<U>,
|
|
6511
|
+
batchSize?: number,
|
|
6508
6512
|
): (data: T) => Promise<Mapped<T, U>>;
|
|
6509
6513
|
```
|
|
6510
6514
|
|
|
@@ -6515,8 +6519,18 @@ mapParallelAsync<T extends IterableContainer, U>(
|
|
|
6515
6519
|
<summary><strong>R.mapParallelAsync</strong> source</summary>
|
|
6516
6520
|
|
|
6517
6521
|
```javascript
|
|
6518
|
-
export function mapParallelAsync(fn)
|
|
6519
|
-
|
|
6522
|
+
export function mapParallelAsync(fn, batchSize){
|
|
6523
|
+
if(!batchSize) return async list => Promise.all(list.map(fn))
|
|
6524
|
+
|
|
6525
|
+
return async list => {
|
|
6526
|
+
const result = []
|
|
6527
|
+
for(let i = 0; i < list.length; i += batchSize){
|
|
6528
|
+
const batch = list.slice(i, i + batchSize)
|
|
6529
|
+
const batchResult = await Promise.all(batch.map((x, j) => fn(x, i + j)))
|
|
6530
|
+
result.push(...batchResult)
|
|
6531
|
+
}
|
|
6532
|
+
return result
|
|
6533
|
+
}
|
|
6520
6534
|
}
|
|
6521
6535
|
```
|
|
6522
6536
|
|
|
@@ -6552,6 +6566,17 @@ test('pipeAsync', async () => {
|
|
|
6552
6566
|
)
|
|
6553
6567
|
expect(result).toEqual([ 2,3,4 ])
|
|
6554
6568
|
})
|
|
6569
|
+
|
|
6570
|
+
test('with batchSize', async () => {
|
|
6571
|
+
const fn = async (x, i) => {
|
|
6572
|
+
await delay(100)
|
|
6573
|
+
return `${x}:${i}`
|
|
6574
|
+
}
|
|
6575
|
+
const result = await mapParallelAsync(fn, 2)([1, 2, 3, 4, 5])
|
|
6576
|
+
expect(result).toEqual(
|
|
6577
|
+
['1:0', '2:1', '3:2', '4:3', '5:4']
|
|
6578
|
+
)
|
|
6579
|
+
})
|
|
6555
6580
|
```
|
|
6556
6581
|
|
|
6557
6582
|
</details>
|
|
@@ -6562,46 +6587,53 @@ test('pipeAsync', async () => {
|
|
|
6562
6587
|
|
|
6563
6588
|
```typescript
|
|
6564
6589
|
|
|
6565
|
-
mapPropObject<T extends object, K extends keyof T, Value>(
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6590
|
+
mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
|
|
6591
|
+
prop: K,
|
|
6592
|
+
valueMapper: (
|
|
6593
|
+
listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
6594
|
+
list: T[K] extends ReadonlyArray<any> ? T[K] : never,
|
|
6595
|
+
) => Value,
|
|
6571
6596
|
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
6572
|
-
|
|
6573
|
-
|
|
6597
|
+
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
6598
|
+
: never
|
|
6574
6599
|
```
|
|
6575
6600
|
|
|
6576
|
-
|
|
6601
|
+
Convenience method, when one needs to maps over a object property that is a list.
|
|
6577
6602
|
|
|
6578
6603
|
```javascript
|
|
6579
6604
|
const result = pipe(
|
|
6580
6605
|
{ a: [1,2,3], b: 'foo' },
|
|
6581
|
-
mapPropObject(x => {
|
|
6582
|
-
x // $ExpectType { a: number; b: string; }
|
|
6606
|
+
mapPropObject('a',x => {
|
|
6583
6607
|
return {
|
|
6584
6608
|
a: x,
|
|
6585
6609
|
flag: x > 2,
|
|
6586
6610
|
}
|
|
6587
|
-
}
|
|
6611
|
+
}),
|
|
6588
6612
|
)
|
|
6589
6613
|
// => { a: [{ a: 1, flag: false },{ a: 2, flag: false }, { a: 3, flag: true }], b: 'foo' }
|
|
6590
6614
|
```
|
|
6591
6615
|
|
|
6592
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6616
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20pipe(%0A%09%7B%20a%3A%20%5B1%2C2%2C3%5D%2C%20b%3A%20'foo'%20%7D%2C%0A%09mapPropObject('a'%2Cx%20%3D%3E%20%7B%0A%09%09return%20%7B%0A%09%09%09a%3A%20x%2C%0A%09%09%09flag%3A%20x%20%3E%202%2C%0A%09%09%7D%0A%09%7D)%2C%0A)%0A%2F%2F%20%3D%3E%20%7B%20a%3A%20%5B%7B%20a%3A%201%2C%20flag%3A%20false%20%7D%2C%7B%20a%3A%202%2C%20flag%3A%20false%20%7D%2C%20%7B%20a%3A%203%2C%20flag%3A%20true%20%7D%5D%2C%20b%3A%20'foo'%20%7D">Try this <strong>R.mapPropObject</strong> example in Rambda REPL</a>
|
|
6593
6617
|
|
|
6594
6618
|
<details>
|
|
6595
6619
|
|
|
6596
6620
|
<summary>All TypeScript definitions</summary>
|
|
6597
6621
|
|
|
6598
6622
|
```typescript
|
|
6599
|
-
mapPropObject<T extends object, K extends keyof T, Value>(
|
|
6623
|
+
mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
|
|
6624
|
+
prop: K,
|
|
6625
|
+
valueMapper: (
|
|
6626
|
+
listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
6627
|
+
list: T[K] extends ReadonlyArray<any> ? T[K] : never,
|
|
6628
|
+
) => Value,
|
|
6629
|
+
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
6630
|
+
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
6631
|
+
: never;
|
|
6632
|
+
mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
|
|
6633
|
+
prop: K,
|
|
6600
6634
|
valueMapper: (
|
|
6601
|
-
|
|
6602
|
-
data: T[K],
|
|
6635
|
+
listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
6603
6636
|
) => Value,
|
|
6604
|
-
prop: K,
|
|
6605
6637
|
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
6606
6638
|
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
6607
6639
|
: never;
|
|
@@ -6660,24 +6692,52 @@ it('happy', () => {
|
|
|
6660
6692
|
<summary><strong>TypeScript</strong> test</summary>
|
|
6661
6693
|
|
|
6662
6694
|
```typescript
|
|
6663
|
-
import { mapPropObject, pipe } from 'rambda'
|
|
6695
|
+
import { map, mapPropObject, pipe } from 'rambda'
|
|
6664
6696
|
|
|
6665
6697
|
describe('R.mapPropObject', () => {
|
|
6666
6698
|
it('iterable with one arguments', () => {
|
|
6667
6699
|
const result = pipe(
|
|
6668
6700
|
{ a: [1,2,3], b: 'foo' },
|
|
6669
|
-
mapPropObject(x => {
|
|
6701
|
+
mapPropObject('a', x => {
|
|
6670
6702
|
x // $ExpectType number
|
|
6671
6703
|
return {
|
|
6672
6704
|
a: x,
|
|
6673
6705
|
flag: x > 2,
|
|
6674
6706
|
}
|
|
6675
|
-
}
|
|
6707
|
+
}),
|
|
6676
6708
|
)
|
|
6677
6709
|
|
|
6678
6710
|
result.a // $ExpectType { a: number; flag: boolean; }[]
|
|
6679
6711
|
result.b // $ExpectType string
|
|
6680
6712
|
})
|
|
6713
|
+
|
|
6714
|
+
it('iterable with two arguments', () => {
|
|
6715
|
+
const result = pipe(
|
|
6716
|
+
{ a: [1,2,3], b: 'foo' },
|
|
6717
|
+
mapPropObject('a', (x, list) => {
|
|
6718
|
+
x // $ExpectType number
|
|
6719
|
+
list // $ExpectType number[]
|
|
6720
|
+
return list.length
|
|
6721
|
+
}),
|
|
6722
|
+
)
|
|
6723
|
+
result.a // $ExpectType number[]
|
|
6724
|
+
result.b // $ExpectType string
|
|
6725
|
+
})
|
|
6726
|
+
|
|
6727
|
+
it('more complex example', () => {
|
|
6728
|
+
const result = pipe(
|
|
6729
|
+
[{a:[true, false, true], b: 'foo'}],
|
|
6730
|
+
map(
|
|
6731
|
+
mapPropObject( 'a',(a) => {
|
|
6732
|
+
a // $ExpectType boolean
|
|
6733
|
+
return {a, b: 2}
|
|
6734
|
+
})
|
|
6735
|
+
)
|
|
6736
|
+
)
|
|
6737
|
+
|
|
6738
|
+
result[0].a[0].a // $ExpectType boolean
|
|
6739
|
+
result[0].a[0].b // $ExpectType number
|
|
6740
|
+
})
|
|
6681
6741
|
})
|
|
6682
6742
|
```
|
|
6683
6743
|
|
|
@@ -6702,7 +6762,7 @@ const result = [
|
|
|
6702
6762
|
// => [[], ['ba', 'na', 'na']]
|
|
6703
6763
|
```
|
|
6704
6764
|
|
|
6705
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6765
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.match('a'%2C%20'foo')%2C%0A%20%20R.match(%2F(%5Ba-z%5Da)%2Fg%2C%20'bananas')%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B%5D%2C%20%5B'ba'%2C%20'na'%2C%20'na'%5D%5D">Try this <strong>R.match</strong> example in Rambda REPL</a>
|
|
6706
6766
|
|
|
6707
6767
|
<details>
|
|
6708
6768
|
|
|
@@ -6788,7 +6848,7 @@ const compareFn = Math.abs
|
|
|
6788
6848
|
R.maxBy(compareFn, 5, -7) // => -7
|
|
6789
6849
|
```
|
|
6790
6850
|
|
|
6791
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
6851
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20compareFn%20%3D%20Math.abs%0A%0Aconst%20result%20%3D%20R.maxBy(compareFn%2C%205%2C%20-7)%20%2F%2F%20%3D%3E%20-7">Try this <strong>R.maxBy</strong> example in Rambda REPL</a>
|
|
6792
6852
|
|
|
6793
6853
|
<details>
|
|
6794
6854
|
|
|
@@ -6971,7 +7031,7 @@ const compareFn = Math.abs
|
|
|
6971
7031
|
R.minBy(compareFn, -5, 2) // => -5
|
|
6972
7032
|
```
|
|
6973
7033
|
|
|
6974
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7034
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20compareFn%20%3D%20Math.abs%0A%0Aconst%20result%20%3D%20R.minBy(compareFn%2C%20-5%2C%202)%20%2F%2F%20%3D%3E%20-5">Try this <strong>R.minBy</strong> example in Rambda REPL</a>
|
|
6975
7035
|
|
|
6976
7036
|
<details>
|
|
6977
7037
|
|
|
@@ -7028,7 +7088,7 @@ const result = R.pipe(
|
|
|
7028
7088
|
) // => [1, 3, 3]
|
|
7029
7089
|
```
|
|
7030
7090
|
|
|
7031
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7091
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%09%5B1%2C%202%2C%203%5D%2C%0A%09R.modifyItemAtIndex(1%2C%20x%20%3D%3E%20x%20%2B%201)%0A)%20%2F%2F%20%3D%3E%20%5B1%2C%203%2C%203%5D">Try this <strong>R.modifyItemAtIndex</strong> example in Rambda REPL</a>
|
|
7032
7092
|
|
|
7033
7093
|
<details>
|
|
7034
7094
|
|
|
@@ -7109,7 +7169,7 @@ const result = R.modifyPath('a.b.c', x=> x+1, {a:{b: {c:1}}})
|
|
|
7109
7169
|
// => {a:{b: {c:2}}}
|
|
7110
7170
|
```
|
|
7111
7171
|
|
|
7112
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7172
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.modifyPath('a.b.c'%2C%20x%3D%3E%20x%2B1%2C%20%7Ba%3A%7Bb%3A%20%7Bc%3A1%7D%7D%7D)%0A%2F%2F%20%3D%3E%20%7Ba%3A%7Bb%3A%20%7Bc%3A2%7D%7D%7D">Try this <strong>R.modifyPath</strong> example in Rambda REPL</a>
|
|
7113
7173
|
|
|
7114
7174
|
<details>
|
|
7115
7175
|
|
|
@@ -7252,7 +7312,7 @@ const result = R.modifyProp('age', x => x + 1)(person)
|
|
|
7252
7312
|
// => {name: 'foo', age: 21}
|
|
7253
7313
|
```
|
|
7254
7314
|
|
|
7255
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7315
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20person%20%3D%20%7B%0A%20%20name%20%3A%20'foo'%2C%0A%20%20age%20%20%3A%2020%2C%0A%7D%0Aconst%20result%20%3D%20R.modifyProp('age'%2C%20x%20%3D%3E%20x%20%2B%201)(person)%0A%2F%2F%20%3D%3E%20%7Bname%3A%20'foo'%2C%20age%3A%2021%7D">Try this <strong>R.modifyProp</strong> example in Rambda REPL</a>
|
|
7256
7316
|
|
|
7257
7317
|
<details>
|
|
7258
7318
|
|
|
@@ -7375,7 +7435,7 @@ const result = R.none(predicate)(arr)
|
|
|
7375
7435
|
// => true
|
|
7376
7436
|
```
|
|
7377
7437
|
|
|
7378
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7438
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%200%2C%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%206%0A%0Aconst%20result%20%3D%20R.none(predicate)(arr)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.none</strong> example in Rambda REPL</a>
|
|
7379
7439
|
|
|
7380
7440
|
<details>
|
|
7381
7441
|
|
|
@@ -7471,7 +7531,7 @@ const result = objectIncludes(specification)(input)
|
|
|
7471
7531
|
// => true
|
|
7472
7532
|
```
|
|
7473
7533
|
|
|
7474
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7534
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20specification%20%3D%20%7B%20a%20%3A%20%7B%20b%20%3A%201%20%7D%20%7D%0Aconst%20input%20%3D%20%7B%0A%20%20a%20%3A%20%7B%20b%20%3A%201%20%7D%2C%0A%20%20c%20%3A%202%0A%7D%0A%0Aconst%20result%20%3D%20objectIncludes(specification)(input)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.objectIncludes</strong> example in Rambda REPL</a>
|
|
7475
7535
|
|
|
7476
7536
|
<details>
|
|
7477
7537
|
|
|
@@ -7595,7 +7655,7 @@ const result = R.objOf('foo')('bar')
|
|
|
7595
7655
|
// => {foo: 'bar'}
|
|
7596
7656
|
```
|
|
7597
7657
|
|
|
7598
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7658
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.objOf('foo')('bar')%0A%2F%2F%20%3D%3E%20%7Bfoo%3A%20'bar'%7D">Try this <strong>R.objOf</strong> example in Rambda REPL</a>
|
|
7599
7659
|
|
|
7600
7660
|
<details>
|
|
7601
7661
|
|
|
@@ -7681,7 +7741,7 @@ const result = [
|
|
|
7681
7741
|
// => [{b: 2}, {b: 2}]
|
|
7682
7742
|
```
|
|
7683
7743
|
|
|
7684
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7744
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%2C%20c%3A%203%7D%0Aconst%20propsToOmit%20%3D%20'a%2Cc%2Cd'%0Aconst%20propsToOmitList%20%3D%20%5B'a'%2C%20'c'%2C%20'd'%5D%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.omit(propsToOmit%2C%20obj)%2C%0A%20%20R.omit(propsToOmitList%2C%20obj)%0A%5D%0A%2F%2F%20%3D%3E%20%5B%7Bb%3A%202%7D%2C%20%7Bb%3A%202%7D%5D">Try this <strong>R.omit</strong> example in Rambda REPL</a>
|
|
7685
7745
|
|
|
7686
7746
|
<details>
|
|
7687
7747
|
|
|
@@ -7823,7 +7883,7 @@ const expected = [[3], [1, 2]]
|
|
|
7823
7883
|
// `result` is equal to `expected`
|
|
7824
7884
|
```
|
|
7825
7885
|
|
|
7826
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
7886
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%202%0A%0Aconst%20result%20%3D%20R.partition(predicate)(list)%0A%0Aconst%20expected%20%3D%20%5B%5B3%5D%2C%20%5B1%2C%202%5D%5D%0A%2F%2F%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.partition</strong> example in Rambda REPL</a>
|
|
7827
7887
|
|
|
7828
7888
|
<details>
|
|
7829
7889
|
|
|
@@ -7948,7 +8008,7 @@ const expected = [{c: 3}, {a: 1, b: 2}]
|
|
|
7948
8008
|
// `result` is equal to `expected`
|
|
7949
8009
|
```
|
|
7950
8010
|
|
|
7951
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8011
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%2C%20c%3A%203%7D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%202%0A%0Aconst%20result%20%3D%20R.partition(predicate)(obj)%0A%0Aconst%20expected%20%3D%20%5B%7Bc%3A%203%7D%2C%20%20%7Ba%3A%201%2C%20b%3A%202%7D%5D%0A%2F%2F%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.partitionObject</strong> example in Rambda REPL</a>
|
|
7952
8012
|
|
|
7953
8013
|
<details>
|
|
7954
8014
|
|
|
@@ -8092,7 +8152,7 @@ const result = [
|
|
|
8092
8152
|
// => [1, 1, undefined]
|
|
8093
8153
|
```
|
|
8094
8154
|
|
|
8095
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8155
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7Ba%3A%20%7Bb%3A%201%7D%7D%0Aconst%20pathToSearch%20%3D%20'a.b'%0Aconst%20pathToSearchList%20%3D%20%5B'a'%2C%20'b'%5D%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.path(pathToSearch%2C%20obj)%2C%0A%20%20R.path(pathToSearchList%2C%20obj)%2C%0A%20%20R.path('a.b.c.d'%2C%20obj)%0A%5D%0A%2F%2F%20%3D%3E%20%5B1%2C%201%2C%20undefined%5D">Try this <strong>R.path</strong> example in Rambda REPL</a>
|
|
8096
8156
|
|
|
8097
8157
|
<details>
|
|
8098
8158
|
|
|
@@ -8248,7 +8308,7 @@ const result = R.pathSatisfies(
|
|
|
8248
8308
|
// => true
|
|
8249
8309
|
```
|
|
8250
8310
|
|
|
8251
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8311
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pathSatisfies(%0A%20%20x%20%3D%3E%20x%20%3E%200%2C%0A%20%20%5B'a'%2C%20'b'%2C%20'c'%5D%2C%0A%20%20%7Ba%3A%20%7Bb%3A%20%7Bc%3A%201%7D%7D%7D%0A)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.pathSatisfies</strong> example in Rambda REPL</a>
|
|
8252
8312
|
|
|
8253
8313
|
<details>
|
|
8254
8314
|
|
|
@@ -8368,7 +8428,7 @@ const result = R.permutations(
|
|
|
8368
8428
|
// => [[1, 2], [2, 1]]
|
|
8369
8429
|
```
|
|
8370
8430
|
|
|
8371
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8431
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.permutations(%0A%09%5B1%2C%202%5D%0A)%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%202%5D%2C%20%5B2%2C%201%5D%5D">Try this <strong>R.permutations</strong> example in Rambda REPL</a>
|
|
8372
8432
|
|
|
8373
8433
|
<details>
|
|
8374
8434
|
|
|
@@ -8435,7 +8495,7 @@ export function permutations(inputArray) {
|
|
|
8435
8495
|
|
|
8436
8496
|
```typescript
|
|
8437
8497
|
|
|
8438
|
-
pick<K extends PropertyKey>(propsToPick: K[]): <T
|
|
8498
|
+
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>
|
|
8439
8499
|
```
|
|
8440
8500
|
|
|
8441
8501
|
It returns a partial copy of an `input` containing only `propsToPick` properties.
|
|
@@ -8471,15 +8531,15 @@ const expected = [
|
|
|
8471
8531
|
// => `result` is equal to `expected`
|
|
8472
8532
|
```
|
|
8473
8533
|
|
|
8474
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8534
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7B%0A%20%20a%20%3A%201%2C%0A%20%20b%20%3A%20false%2C%0A%20%20foo%3A%20'cherry'%0A%7D%0Aconst%20propsToPick%20%3D%20'a%2Cfoo'%0Aconst%20propsToPickList%20%3D%20%5B'a'%2C%20'foo'%5D%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.pick(propsToPick)(obj)%2C%0A%20%20R.pick(propsToPickList)(obj)%2C%0A%20%20R.pick('a%2Cbar')(obj)%2C%0A%20%20R.pick('bar')(obj)%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%7D%2C%0A%20%20%7B%7D%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.pick</strong> example in Rambda REPL</a>
|
|
8475
8535
|
|
|
8476
8536
|
<details>
|
|
8477
8537
|
|
|
8478
8538
|
<summary>All TypeScript definitions</summary>
|
|
8479
8539
|
|
|
8480
8540
|
```typescript
|
|
8481
|
-
pick<K extends PropertyKey>(propsToPick: K[]): <T
|
|
8482
|
-
pick<S extends string
|
|
8541
|
+
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
|
|
8542
|
+
pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
|
|
8483
8543
|
```
|
|
8484
8544
|
|
|
8485
8545
|
</details>
|
|
@@ -8567,15 +8627,19 @@ const input = { a: 'foo', c: 3 }
|
|
|
8567
8627
|
|
|
8568
8628
|
describe('R.pick', () => {
|
|
8569
8629
|
it('with string as input', () => {
|
|
8570
|
-
const result = pipe(input, pick('a,c
|
|
8630
|
+
const result = pipe(input, pick('a,c'))
|
|
8571
8631
|
result.a // $ExpectType string
|
|
8572
8632
|
result.c // $ExpectType number
|
|
8573
8633
|
})
|
|
8574
8634
|
it('with array as input', () => {
|
|
8575
|
-
|
|
8635
|
+
const result = pipe(input, pick(['a', 'c']))
|
|
8576
8636
|
result.a // $ExpectType string
|
|
8577
8637
|
result.c // $ExpectType number
|
|
8578
8638
|
})
|
|
8639
|
+
it('throws error if some keys do not exist', () => {
|
|
8640
|
+
// @ts-expect-error
|
|
8641
|
+
pipe(input, pick('a,c,b,o'))
|
|
8642
|
+
})
|
|
8579
8643
|
})
|
|
8580
8644
|
```
|
|
8581
8645
|
|
|
@@ -8606,7 +8670,7 @@ const result = R.pipe(
|
|
|
8606
8670
|
// => [20, 30]
|
|
8607
8671
|
```
|
|
8608
8672
|
|
|
8609
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
8673
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.pipe(%0A%20%20%5B1%2C%202%2C%203%5D%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%201)%2C%0A%20%20R.map(x%20%3D%3E%20x*10)%2C%0A)%0A%2F%2F%20%3D%3E%20%5B20%2C%2030%5D">Try this <strong>R.pipe</strong> example in Rambda REPL</a>
|
|
8610
8674
|
|
|
8611
8675
|
<details>
|
|
8612
8676
|
|
|
@@ -8959,7 +9023,7 @@ const result = await R.pipeAsync(
|
|
|
8959
9023
|
// `result` resolves to `RAMBDAX_DELAY104`
|
|
8960
9024
|
```
|
|
8961
9025
|
|
|
8962
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9026
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20await%20R.pipeAsync(%0A%20%20100%2C%0A%20%20async%20x%20%3D%3E%20%7B%0A%20%20%20%20await%20R.delay(100)%0A%20%20%20%20return%20x%20%2B%202%0A%20%20%7D%2C%0A%20%20x%20%3D%3E%20x%20%2B2%2C%0A%20%20async%20x%20%3D%3E%20%7B%0A%20%20%20%20const%20delayed%20%3D%20await%20R.delay(100)%0A%20%20%20%20return%20delayed%20%2B%20x%0A%20%20%7D%0A)%0A%2F%2F%20%60result%60%20resolves%20to%20%60RAMBDAX_DELAY104%60">Try this <strong>R.pipeAsync</strong> example in Rambda REPL</a>
|
|
8963
9027
|
|
|
8964
9028
|
<details>
|
|
8965
9029
|
|
|
@@ -9075,7 +9139,7 @@ const result = R.pluck(property)(list)
|
|
|
9075
9139
|
// => [1, 2]
|
|
9076
9140
|
```
|
|
9077
9141
|
|
|
9078
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9142
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%2C%20%7Bb%3A%203%7D%5D%0Aconst%20property%20%3D%20'a'%0A%0Aconst%20result%20%3D%20R.pluck(property)(list)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.pluck</strong> example in Rambda REPL</a>
|
|
9079
9143
|
|
|
9080
9144
|
<details>
|
|
9081
9145
|
|
|
@@ -9181,7 +9245,7 @@ const result = R.prepend('foo', ['bar', 'baz'])
|
|
|
9181
9245
|
// => ['foo', 'bar', 'baz']
|
|
9182
9246
|
```
|
|
9183
9247
|
|
|
9184
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9248
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.prepend('foo'%2C%20%5B'bar'%2C%20'baz'%5D)%0A%2F%2F%20%3D%3E%20%5B'foo'%2C%20'bar'%2C%20'baz'%5D">Try this <strong>R.prepend</strong> example in Rambda REPL</a>
|
|
9185
9249
|
|
|
9186
9250
|
<details>
|
|
9187
9251
|
|
|
@@ -9245,7 +9309,7 @@ const result = [
|
|
|
9245
9309
|
// => [100, undefined]
|
|
9246
9310
|
```
|
|
9247
9311
|
|
|
9248
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9312
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.prop('x')(%7Bx%3A%20100%7D)%2C%0A%20%20R.prop('x')(%7Ba%3A%201%7D)%0A%5D%0A%2F%2F%20%3D%3E%20%5B100%2C%20undefined%5D">Try this <strong>R.prop</strong> example in Rambda REPL</a>
|
|
9249
9313
|
|
|
9250
9314
|
<details>
|
|
9251
9315
|
|
|
@@ -9319,7 +9383,7 @@ const result = [
|
|
|
9319
9383
|
// => [true, false]
|
|
9320
9384
|
```
|
|
9321
9385
|
|
|
9322
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9386
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7B%20foo%3A%20'bar'%20%7D%0Aconst%20secondObj%20%3D%20%7B%20foo%3A%201%20%7D%0A%0Aconst%20propToFind%20%3D%20'foo'%0Aconst%20valueToMatch%20%3D%20'bar'%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.propEq(propToFind%2C%20valueToMatch)(obj)%2C%0A%20%20R.propEq(propToFind%2C%20valueToMatch)(secondObj)%0A%5D%0A%2F%2F%20%3D%3E%20%5Btrue%2C%20false%5D">Try this <strong>R.propEq</strong> example in Rambda REPL</a>
|
|
9323
9387
|
|
|
9324
9388
|
<details>
|
|
9325
9389
|
|
|
@@ -9405,7 +9469,7 @@ const result = [
|
|
|
9405
9469
|
// => [1, 'DEFAULT_VALUE']
|
|
9406
9470
|
```
|
|
9407
9471
|
|
|
9408
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9472
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7Ba%3A%201%7D%0Aconst%20defaultValue%20%3D%20'DEFAULT_VALUE'%0Aconst%20property%20%3D%20'a'%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.propOr(defaultValue%2C%20property)(obj)%2C%0A%20%20R.propOr(defaultValue%2C%20'foo')(obj)%0A%5D%0A%2F%2F%20%3D%3E%20%5B1%2C%20'DEFAULT_VALUE'%5D">Try this <strong>R.propOr</strong> example in Rambda REPL</a>
|
|
9409
9473
|
|
|
9410
9474
|
<details>
|
|
9411
9475
|
|
|
@@ -9493,7 +9557,7 @@ const result = R.propSatisfies(predicate, property, obj)
|
|
|
9493
9557
|
// => true
|
|
9494
9558
|
```
|
|
9495
9559
|
|
|
9496
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9560
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7Ba%3A%20%7Bb%3A1%7D%7D%0Aconst%20property%20%3D%20'a'%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%3F.b%20%3D%3D%3D%201%0A%0Aconst%20result%20%3D%20R.propSatisfies(predicate%2C%20property%2C%20obj)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.propSatisfies</strong> example in Rambda REPL</a>
|
|
9497
9561
|
|
|
9498
9562
|
<details>
|
|
9499
9563
|
|
|
@@ -9580,7 +9644,7 @@ If `start` is greater than `end`, then the result will be in descending order.
|
|
|
9580
9644
|
// => [[0, 1, 2, 3, 4], [5, 4, 3, 2, 1]]
|
|
9581
9645
|
```
|
|
9582
9646
|
|
|
9583
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9647
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5BR.range(0)(5)%2C%20R.range(5)(0)%5D%0A%2F%2F%20%3D%3E%20%5B%5B0%2C%201%2C%202%2C%203%2C%204%5D%2C%20%5B5%2C%204%2C%203%2C%202%2C%201%5D%5D">Try this <strong>R.range</strong> example in Rambda REPL</a>
|
|
9584
9648
|
|
|
9585
9649
|
<details>
|
|
9586
9650
|
|
|
@@ -9687,7 +9751,7 @@ const result = R.reduce(reducer, initialValue, list)
|
|
|
9687
9751
|
// => 60
|
|
9688
9752
|
```
|
|
9689
9753
|
|
|
9690
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9754
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0Aconst%20initialValue%20%3D%2010%0Aconst%20reducer%20%3D%20(prev%2C%20current)%20%3D%3E%20prev%20*%20current%0A%0Aconst%20result%20%3D%20R.reduce(reducer%2C%20initialValue%2C%20list)%0A%2F%2F%20%3D%3E%2060">Try this <strong>R.reduce</strong> example in Rambda REPL</a>
|
|
9691
9755
|
|
|
9692
9756
|
<details>
|
|
9693
9757
|
|
|
@@ -9790,9 +9854,8 @@ it('R.reduce', () => {
|
|
|
9790
9854
|
```typescript
|
|
9791
9855
|
|
|
9792
9856
|
reject<T>(
|
|
9793
|
-
predicate:
|
|
9794
|
-
|
|
9795
|
-
): T[]
|
|
9857
|
+
predicate: BooleanConstructor,
|
|
9858
|
+
): (list: readonly T[]) => ("" | null | undefined | false | 0)[]
|
|
9796
9859
|
```
|
|
9797
9860
|
|
|
9798
9861
|
It has the opposite effect of `R.filter`.
|
|
@@ -9809,17 +9872,13 @@ const result = [
|
|
|
9809
9872
|
// => [[1], {a: 1}]
|
|
9810
9873
|
```
|
|
9811
9874
|
|
|
9812
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
9875
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3E%201%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.reject(predicate)(list)%2C%0A%20%20R.reject(predicate)(obj)%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B1%5D%2C%20%7Ba%3A%201%7D%5D">Try this <strong>R.reject</strong> example in Rambda REPL</a>
|
|
9813
9876
|
|
|
9814
9877
|
<details>
|
|
9815
9878
|
|
|
9816
9879
|
<summary>All TypeScript definitions</summary>
|
|
9817
9880
|
|
|
9818
9881
|
```typescript
|
|
9819
|
-
reject<T>(
|
|
9820
|
-
predicate: (value: T) => boolean,
|
|
9821
|
-
list: T[],
|
|
9822
|
-
): T[];
|
|
9823
9882
|
reject<T>(
|
|
9824
9883
|
predicate: BooleanConstructor,
|
|
9825
9884
|
): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
|
|
@@ -9829,8 +9888,6 @@ reject<T>(
|
|
|
9829
9888
|
reject<T>(
|
|
9830
9889
|
predicate: (value: T) => boolean,
|
|
9831
9890
|
): (list: T[]) => T[];
|
|
9832
|
-
...
|
|
9833
|
-
...
|
|
9834
9891
|
```
|
|
9835
9892
|
|
|
9836
9893
|
</details>
|
|
@@ -9968,7 +10025,7 @@ const result = R.rejectObject(
|
|
|
9968
10025
|
// => {b: 2}
|
|
9969
10026
|
```
|
|
9970
10027
|
|
|
9971
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10028
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.rejectObject(%0A%09(val%2C%20prop)%20%3D%3E%20prop%20%3D%3D%3D%20'a'%20%7C%7C%20val%20%3E%201%0A)(%7Ba%3A%201%2C%20b%3A%202%2C%20c%3A3%7D)%0A%2F%2F%20%3D%3E%20%7Bb%3A%202%7D">Try this <strong>R.rejectObject</strong> example in Rambda REPL</a>
|
|
9972
10029
|
|
|
9973
10030
|
<details>
|
|
9974
10031
|
|
|
@@ -10074,7 +10131,7 @@ const result = [
|
|
|
10074
10131
|
// => ['f|1|o', 'f|1||1|']
|
|
10075
10132
|
```
|
|
10076
10133
|
|
|
10077
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10134
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%09R.replace('o'%2C%20'%7C1%7C')('foo')%2C%0A%09R.replace(%2Fo%2Fg%2C%20'%7C1%7C')('foo')%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B'f%7C1%7Co'%2C%20'f%7C1%7C%7C1%7C'%5D">Try this <strong>R.replace</strong> example in Rambda REPL</a>
|
|
10078
10135
|
|
|
10079
10136
|
<details>
|
|
10080
10137
|
|
|
@@ -10157,7 +10214,7 @@ const result = [
|
|
|
10157
10214
|
// => 'f|1||1|'
|
|
10158
10215
|
```
|
|
10159
10216
|
|
|
10160
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10217
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%09R.replaceAll(%5B'o'%2C%20%2Fa%2Fg%5D%2C%20'%7C1%7C')('foa')%2C%0A%5D%0A%2F%2F%20%3D%3E%20'f%7C1%7C%7C1%7C'">Try this <strong>R.replaceAll</strong> example in Rambda REPL</a>
|
|
10161
10218
|
|
|
10162
10219
|
<details>
|
|
10163
10220
|
|
|
@@ -10249,7 +10306,7 @@ const result = R.shuffle(
|
|
|
10249
10306
|
// => [3, 1, 2] or [2, 3, 1] or ...
|
|
10250
10307
|
```
|
|
10251
10308
|
|
|
10252
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10309
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.shuffle(%0A%09%5B1%2C%202%2C%203%5D%0A)%0A%2F%2F%20%3D%3E%20%5B3%2C%201%2C%202%5D%20or%20%5B2%2C%203%2C%201%5D%20or%20...">Try this <strong>R.shuffle</strong> example in Rambda REPL</a>
|
|
10253
10310
|
|
|
10254
10311
|
<details>
|
|
10255
10312
|
|
|
@@ -10334,7 +10391,7 @@ const expected = [
|
|
|
10334
10391
|
// => `result` is equal to `expected`
|
|
10335
10392
|
```
|
|
10336
10393
|
|
|
10337
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10394
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%203%7D%2C%0A%20%20%7Ba%3A%201%7D%0A%5D%0Aconst%20sortFn%20%3D%20(x%2C%20y)%20%3D%3E%20%7B%0A%20%20return%20x.a%20%3E%20y.a%20%3F%201%20%3A%20-1%0A%7D%0A%0Aconst%20result%20%3D%20R.sort(sortFn%2C%20list)%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A%201%7D%2C%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%203%7D%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sort</strong> example in Rambda REPL</a>
|
|
10338
10395
|
|
|
10339
10396
|
<details>
|
|
10340
10397
|
|
|
@@ -10441,7 +10498,7 @@ const expected = [
|
|
|
10441
10498
|
// => `result` is equal to `expected`
|
|
10442
10499
|
```
|
|
10443
10500
|
|
|
10444
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10501
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%203%7D%2C%0A%20%20%7Ba%3A%201%7D%0A%5D%0Aconst%20sortFn%20%3D%20x%20%3D%3E%20x.a%0A%0Aconst%20result%20%3D%20R.sortBy(sortFn)(list)%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A%201%7D%2C%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%203%7D%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sortBy</strong> example in Rambda REPL</a>
|
|
10445
10502
|
|
|
10446
10503
|
<details>
|
|
10447
10504
|
|
|
@@ -10541,7 +10598,7 @@ describe('R.sortBy', () => {
|
|
|
10541
10598
|
|
|
10542
10599
|
```typescript
|
|
10543
10600
|
|
|
10544
|
-
sortByDescending<T>(sortFn: (
|
|
10601
|
+
sortByDescending<T>(sortFn: (x: T) => Ord): (list: T[]) => T[]
|
|
10545
10602
|
```
|
|
10546
10603
|
|
|
10547
10604
|
```javascript
|
|
@@ -10561,14 +10618,14 @@ const expected = [
|
|
|
10561
10618
|
// => `result` is equal to `expected`
|
|
10562
10619
|
```
|
|
10563
10620
|
|
|
10564
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10621
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%203%7D%2C%0A%20%20%7Ba%3A%201%7D%0A%5D%0Aconst%20sortFn%20%3D%20x%20%3D%3E%20x.a%0A%0Aconst%20result%20%3D%20R.sortByDescending(sortFn)(list)%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A%203%7D%2C%0A%20%20%7Ba%3A%202%7D%2C%0A%20%20%7Ba%3A%201%7D%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sortByDescending</strong> example in Rambda REPL</a>
|
|
10565
10622
|
|
|
10566
10623
|
<details>
|
|
10567
10624
|
|
|
10568
10625
|
<summary>All TypeScript definitions</summary>
|
|
10569
10626
|
|
|
10570
10627
|
```typescript
|
|
10571
|
-
sortByDescending<T>(sortFn: (
|
|
10628
|
+
sortByDescending<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
|
|
10572
10629
|
```
|
|
10573
10630
|
|
|
10574
10631
|
</details>
|
|
@@ -10587,6 +10644,24 @@ export function sortByDescending(sortFn) {
|
|
|
10587
10644
|
|
|
10588
10645
|
</details>
|
|
10589
10646
|
|
|
10647
|
+
<details>
|
|
10648
|
+
|
|
10649
|
+
<summary><strong>Tests</strong></summary>
|
|
10650
|
+
|
|
10651
|
+
```javascript
|
|
10652
|
+
import { sortByDescending } from './sortByDescending.js'
|
|
10653
|
+
import { path } from './path.js'
|
|
10654
|
+
|
|
10655
|
+
const list = [{ a: { b: 3 } }, { a: { b: 1 } }, { a: { b: 2 } }]
|
|
10656
|
+
const sorted = [{ a: { b: 3 } }, { a: { b: 2 } }, { a: { b: 1 } }]
|
|
10657
|
+
|
|
10658
|
+
test('happy', () => {
|
|
10659
|
+
expect(sortByDescending(path('a.b'))(list)).toEqual(sorted)
|
|
10660
|
+
})
|
|
10661
|
+
```
|
|
10662
|
+
|
|
10663
|
+
</details>
|
|
10664
|
+
|
|
10590
10665
|
[](#sortByDescending)
|
|
10591
10666
|
|
|
10592
10667
|
### sortByPath
|
|
@@ -10615,7 +10690,7 @@ const expected = [
|
|
|
10615
10690
|
// => `result` is equal to `expected`
|
|
10616
10691
|
```
|
|
10617
10692
|
|
|
10618
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10693
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%09%7Ba%3A%20%7Bb%3A%202%7D%2C%20id%3A1%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%201%7D%2C%20id%3A2%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%203%7D%2C%20id%3A3%7D%2C%0A%5D%0Aconst%20result%20%3D%20R.sortByPath('a.b')(list)%0Aconst%20expected%20%3D%20%5B%0A%09%7Ba%3A%20%7Bb%3A%201%7D%2C%20id%3A2%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%202%7D%2C%20id%3A1%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%203%7D%2C%20id%3A3%7D%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sortByPath</strong> example in Rambda REPL</a>
|
|
10619
10694
|
|
|
10620
10695
|
<details>
|
|
10621
10696
|
|
|
@@ -10736,7 +10811,7 @@ const expected = [
|
|
|
10736
10811
|
// => `result` is equal to `expected`
|
|
10737
10812
|
```
|
|
10738
10813
|
|
|
10739
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10814
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%09%7Ba%3A%20%7Bb%3A%202%7D%2C%20id%3A1%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%201%7D%2C%20id%3A2%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%203%7D%2C%20id%3A3%7D%2C%0A%5D%0Aconst%20result%20%3D%20R.sortByPathDescending('a.b')(list)%0Aconst%20expected%20%3D%20%5B%0A%09%7Ba%3A%20%7Bb%3A%203%7D%2C%20id%3A3%7D%0A%09%7Ba%3A%20%7Bb%3A%202%7D%2C%20id%3A1%7D%2C%0A%09%7Ba%3A%20%7Bb%3A%201%7D%2C%20id%3A2%7D%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sortByPathDescending</strong> example in Rambda REPL</a>
|
|
10740
10815
|
|
|
10741
10816
|
<details>
|
|
10742
10817
|
|
|
@@ -10815,7 +10890,7 @@ const result = R.sortObject(predicate)({a:1, b: 4, c: 2})
|
|
|
10815
10890
|
// => {b: 4, c: 2, a: 1}
|
|
10816
10891
|
```
|
|
10817
10892
|
|
|
10818
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
10893
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20(propA%2C%20propB%2C%20valueA%2C%20valueB)%20%3D%3E%20valueA%20%3E%20valueB%20%3F%20-1%20%3A%201%0A%0Aconst%20result%20%3D%20R.sortObject(predicate)(%7Ba%3A1%2C%20b%3A%204%2C%20c%3A%202%7D)%0A%2F%2F%20%3D%3E%20%7Bb%3A%204%2C%20c%3A%202%2C%20a%3A%201%7D">Try this <strong>R.sortObject</strong> example in Rambda REPL</a>
|
|
10819
10894
|
|
|
10820
10895
|
<details>
|
|
10821
10896
|
|
|
@@ -10962,7 +11037,7 @@ const expected = [
|
|
|
10962
11037
|
// => `result` is equal to `expected`
|
|
10963
11038
|
```
|
|
10964
11039
|
|
|
10965
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11040
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.sortWith(%5B%0A%20%20%20%20(a%2C%20b)%20%3D%3E%20a.a%20%3D%3D%3D%20b.a%20%3F%200%20%3A%20a.a%20%3E%20b.a%20%3F%201%20%3A%20-1%2C%0A%20%20%20%20(a%2C%20b)%20%3D%3E%20a.b%20%3D%3D%3D%20b.b%20%3F%200%20%3A%20a.b%20%3E%20b.b%20%3F%201%20%3A%20-1%2C%0A%5D)(%5B%0A%20%20%7Ba%3A%201%2C%20b%3A%202%7D%2C%0A%20%20%7Ba%3A%202%2C%20b%3A%201%7D%2C%0A%20%20%7Ba%3A%202%2C%20b%3A%202%7D%2C%0A%20%20%7Ba%3A%201%2C%20b%3A%201%7D%2C%0A%5D)%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A%201%2C%20b%3A%201%7D%2C%0A%20%20%7Ba%3A%201%2C%20b%3A%202%7D%2C%0A%20%20%7Ba%3A%202%2C%20b%3A%201%7D%2C%0A%20%20%7Ba%3A%202%2C%20b%3A%202%7D%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.sortWith</strong> example in Rambda REPL</a>
|
|
10966
11041
|
|
|
10967
11042
|
<details>
|
|
10968
11043
|
|
|
@@ -11187,7 +11262,7 @@ const expected = [
|
|
|
11187
11262
|
// => `result` is equal to `expected`
|
|
11188
11263
|
```
|
|
11189
11264
|
|
|
11190
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11265
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.splitEvery(2)(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.splitEvery(3)('foobar')%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%20%5B%5B1%2C%202%5D%2C%20%5B3%5D%5D%2C%0A%20%20%5B'foo'%2C%20'bar'%5D%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.splitEvery</strong> example in Rambda REPL</a>
|
|
11191
11266
|
|
|
11192
11267
|
<details>
|
|
11193
11268
|
|
|
@@ -11278,7 +11353,7 @@ const result = R.symmetricDifference(x)(y)
|
|
|
11278
11353
|
// => [ 1, 2, 5, 6 ]
|
|
11279
11354
|
```
|
|
11280
11355
|
|
|
11281
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11356
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20x%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20y%20%3D%20%5B%203%2C%204%2C%205%2C%206%20%5D%0A%0Aconst%20result%20%3D%20R.symmetricDifference(x)(y)%0A%2F%2F%20%3D%3E%20%5B%201%2C%202%2C%205%2C%206%20%5D">Try this <strong>R.symmetricDifference</strong> example in Rambda REPL</a>
|
|
11282
11357
|
|
|
11283
11358
|
<details>
|
|
11284
11359
|
|
|
@@ -11375,7 +11450,7 @@ const result = [
|
|
|
11375
11450
|
// => [[2, 3], 'oo']
|
|
11376
11451
|
```
|
|
11377
11452
|
|
|
11378
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11453
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20%5B%0A%20%20R.tail(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.tail('foo')%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B2%2C%203%5D%2C%20'oo'%5D">Try this <strong>R.tail</strong> example in Rambda REPL</a>
|
|
11379
11454
|
|
|
11380
11455
|
<details>
|
|
11381
11456
|
|
|
@@ -11474,7 +11549,7 @@ const result = [
|
|
|
11474
11549
|
// => [[1, 2], 'fo']
|
|
11475
11550
|
```
|
|
11476
11551
|
|
|
11477
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11552
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20howMany%20%3D%202%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.take(howMany)(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.take(howMany%2C%20'foobar')%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%202%5D%2C%20'fo'%5D">Try this <strong>R.take</strong> example in Rambda REPL</a>
|
|
11478
11553
|
|
|
11479
11554
|
<details>
|
|
11480
11555
|
|
|
@@ -11567,7 +11642,7 @@ const result = [
|
|
|
11567
11642
|
// => [[2, 3], 'ar']
|
|
11568
11643
|
```
|
|
11569
11644
|
|
|
11570
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11645
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20howMany%20%3D%202%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.takeLast(howMany)(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.takeLast(howMany)('foobar')%2C%0A%5D%0A%2F%2F%20%3D%3E%20%5B%5B2%2C%203%5D%2C%20'ar'%5D">Try this <strong>R.takeLast</strong> example in Rambda REPL</a>
|
|
11571
11646
|
|
|
11572
11647
|
<details>
|
|
11573
11648
|
|
|
@@ -11655,7 +11730,7 @@ const result = R.takeLastWhile(x => x > 2)([1, 2, 3, 4])
|
|
|
11655
11730
|
// => [3, 4]
|
|
11656
11731
|
```
|
|
11657
11732
|
|
|
11658
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11733
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.takeLastWhile(x%20%3D%3E%20x%20%3E%202)(%5B1%2C%202%2C%203%2C%204%5D)%0A%2F%2F%20%3D%3E%20%5B3%2C%204%5D">Try this <strong>R.takeLastWhile</strong> example in Rambda REPL</a>
|
|
11659
11734
|
|
|
11660
11735
|
<details>
|
|
11661
11736
|
|
|
@@ -11744,7 +11819,7 @@ const result = R.takeWhile(predicate)(list)
|
|
|
11744
11819
|
// => [1, 2]
|
|
11745
11820
|
```
|
|
11746
11821
|
|
|
11747
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11822
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20predicate%20%3D%20x%20%3D%3E%20x%20%3C%203%0A%0Aconst%20result%20%3D%20R.takeWhile(predicate)(list)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.takeWhile</strong> example in Rambda REPL</a>
|
|
11748
11823
|
|
|
11749
11824
|
<details>
|
|
11750
11825
|
|
|
@@ -11854,7 +11929,7 @@ const result = R.pipe(
|
|
|
11854
11929
|
// => `2` and `3` will be logged
|
|
11855
11930
|
```
|
|
11856
11931
|
|
|
11857
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11932
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0A%0Aconst%20result%20%3D%20R.pipe(%0A%09list%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%201)%2C%0A%20%20R.tap(console.log)%2C%0A%20%20R.map(x%20%3D%3E%20x%20*%202)%0A)%0A%2F%2F%20%3D%3E%20%602%60%20and%20%603%60%20will%20be%20logged">Try this <strong>R.tap</strong> example in Rambda REPL</a>
|
|
11858
11933
|
|
|
11859
11934
|
<details>
|
|
11860
11935
|
|
|
@@ -11898,7 +11973,7 @@ R.test(/^f/)('foo')
|
|
|
11898
11973
|
// => true
|
|
11899
11974
|
```
|
|
11900
11975
|
|
|
11901
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
11976
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.test(%2F%5Ef%2F)('foo')%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.test</strong> example in Rambda REPL</a>
|
|
11902
11977
|
|
|
11903
11978
|
<details>
|
|
11904
11979
|
|
|
@@ -11976,7 +12051,7 @@ const result = R.transformPropObject(fn, 'a')(obj)
|
|
|
11976
12051
|
// => {a: false, b: 2}
|
|
11977
12052
|
```
|
|
11978
12053
|
|
|
11979
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12054
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20(x)%20%3D%3E%20x%20%3E%202%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.transformPropObject(fn%2C%20'a')(obj)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20false%2C%20b%3A%202%7D">Try this <strong>R.transformPropObject</strong> example in Rambda REPL</a>
|
|
11980
12055
|
|
|
11981
12056
|
<details>
|
|
11982
12057
|
|
|
@@ -12037,7 +12112,7 @@ const result = [
|
|
|
12037
12112
|
// => [false, 'bar']
|
|
12038
12113
|
```
|
|
12039
12114
|
|
|
12040
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12115
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20x%20%3D%3E%20x.foo%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.tryCatch(fn%2C%20false)(null)%2C%0A%20%20R.tryCatch(fn%2C%20false)(%7Bfoo%3A%20'bar'%7D)%0A%5D%0A%2F%2F%20%3D%3E%20%5Bfalse%2C%20'bar'%5D">Try this <strong>R.tryCatch</strong> example in Rambda REPL</a>
|
|
12041
12116
|
|
|
12042
12117
|
<details>
|
|
12043
12118
|
|
|
@@ -12168,7 +12243,7 @@ const delay = ms => new Promise(resolve => {
|
|
|
12168
12243
|
R.type(delay) // => 'Promise'
|
|
12169
12244
|
```
|
|
12170
12245
|
|
|
12171
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12246
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.type(()%20%3D%3E%20%7B%7D)%20%2F%2F%20%3D%3E%20'Function'%0AR.type(async%20()%20%3D%3E%20%7B%7D)%20%2F%2F%20%3D%3E%20'Async'%0AR.type(%5B%5D)%20%2F%2F%20%3D%3E%20'Array'%0AR.type(%7B%7D)%20%2F%2F%20%3D%3E%20'Object'%0AR.type('foo')%20%2F%2F%20%3D%3E%20'String'%0AR.type(1)%20%2F%2F%20%3D%3E%20'Number'%0AR.type(true)%20%2F%2F%20%3D%3E%20'Boolean'%0AR.type(null)%20%2F%2F%20%3D%3E%20'Null'%0AR.type(%2F%5BA-z%5D%2F)%20%2F%2F%20%3D%3E%20'RegExp'%0AR.type('foo'*1)%20%2F%2F%20%3D%3E%20'NaN'%0A%0Aconst%20delay%20%3D%20ms%20%3D%3E%20new%20Promise(resolve%20%3D%3E%20%7B%0A%20%20setTimeout(function%20()%20%7B%0A%20%20%20%20resolve()%0A%20%20%7D%2C%20ms)%0A%7D)%0AR.type(delay)%20%2F%2F%20%3D%3E%20'Promise'">Try this <strong>R.type</strong> example in Rambda REPL</a>
|
|
12172
12247
|
|
|
12173
12248
|
<details>
|
|
12174
12249
|
|
|
@@ -12418,7 +12493,7 @@ const result = R.union([1,2,3])([3,4,5]);
|
|
|
12418
12493
|
// => [1, 2, 3, 4, 5]
|
|
12419
12494
|
```
|
|
12420
12495
|
|
|
12421
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12496
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20result%20%3D%20R.union(%5B1%2C2%2C3%5D)(%5B3%2C4%2C5%5D)%3B%0A%2F%2F%20%3D%3E%20%5B1%2C%202%2C%203%2C%204%2C%205%5D">Try this <strong>R.union</strong> example in Rambda REPL</a>
|
|
12422
12497
|
|
|
12423
12498
|
<details>
|
|
12424
12499
|
|
|
@@ -12527,7 +12602,7 @@ R.uniq(list)
|
|
|
12527
12602
|
// => [1, {a: 1}, {a: 2}]
|
|
12528
12603
|
```
|
|
12529
12604
|
|
|
12530
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12605
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B1%2C%201%2C%20%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%2C%20%7Ba%3A1%7D%5D%0A%0Aconst%20result%20%3D%20R.uniq(list)%0A%2F%2F%20%3D%3E%20%5B1%2C%20%7Ba%3A%201%7D%2C%20%7Ba%3A%202%7D%5D">Try this <strong>R.uniq</strong> example in Rambda REPL</a>
|
|
12531
12606
|
|
|
12532
12607
|
<details>
|
|
12533
12608
|
|
|
@@ -12634,7 +12709,7 @@ const result = R.uniqBy(x => x)(list)
|
|
|
12634
12709
|
// => [{a:1}, {a:2}]
|
|
12635
12710
|
```
|
|
12636
12711
|
|
|
12637
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12712
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%2C%20%7Ba%3A1%7D%5D%0Aconst%20result%20%3D%20R.uniqBy(x%20%3D%3E%20x)(list)%0A%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%5D">Try this <strong>R.uniqBy</strong> example in Rambda REPL</a>
|
|
12638
12713
|
|
|
12639
12714
|
<details>
|
|
12640
12715
|
|
|
@@ -12740,7 +12815,7 @@ const result = R.uniqWith(predicate)(list)
|
|
|
12740
12815
|
// => `result` is equal to `expected`
|
|
12741
12816
|
```
|
|
12742
12817
|
|
|
12743
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12818
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list%20%3D%20%5B%0A%20%20%7Bid%3A%200%2C%20title%3A'foo'%7D%2C%0A%20%20%7Bid%3A%201%2C%20title%3A'bar'%7D%2C%0A%20%20%7Bid%3A%202%2C%20title%3A'baz'%7D%2C%0A%20%20%7Bid%3A%203%2C%20title%3A'foo'%7D%2C%0A%20%20%7Bid%3A%204%2C%20title%3A'bar'%7D%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Bid%3A%200%2C%20title%3A'foo'%7D%2C%0A%20%20%7Bid%3A%201%2C%20title%3A'bar'%7D%2C%0A%20%20%7Bid%3A%202%2C%20title%3A'baz'%7D%2C%0A%5D%0A%0Aconst%20predicate%20%3D%20(x%2Cy)%20%3D%3E%20x.title%20%3D%3D%3D%20y.title%0A%0Aconst%20result%20%3D%20R.uniqWith(predicate)(list)%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.uniqWith</strong> example in Rambda REPL</a>
|
|
12744
12819
|
|
|
12745
12820
|
<details>
|
|
12746
12821
|
|
|
@@ -12891,7 +12966,7 @@ const result = [
|
|
|
12891
12966
|
// => [11, 5]
|
|
12892
12967
|
```
|
|
12893
12968
|
|
|
12894
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
12969
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20fn%20%3D%20R.unless(%0A%20%20x%20%3D%3E%20x%20%3E%202%2C%0A%20%20x%20%3D%3E%20x%20%2B%2010%0A)%0A%0Aconst%20result%20%3D%20%5B%0A%20%20fn(1)%2C%0A%20%20fn(5)%0A%5D%0A%2F%2F%20%3D%3E%20%5B11%2C%205%5D">Try this <strong>R.unless</strong> example in Rambda REPL</a>
|
|
12895
12970
|
|
|
12896
12971
|
<details>
|
|
12897
12972
|
|
|
@@ -13006,7 +13081,7 @@ const expected = [{a:1, b:2}, {a:1, b:3}]
|
|
|
13006
13081
|
// => `result` is equal to `expected`
|
|
13007
13082
|
```
|
|
13008
13083
|
|
|
13009
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
13084
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20obj%20%3D%20%7B%0A%20%20a%3A%201%2C%0A%20%20b%3A%20%5B2%2C%203%5D%2C%0A%7D%0Aconst%20result%20%3D%20R.unwind('b')(obj)%0Aconst%20expected%20%3D%20%5B%7Ba%3A1%2C%20b%3A2%7D%2C%20%7Ba%3A1%2C%20b%3A3%7D%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.unwind</strong> example in Rambda REPL</a>
|
|
13010
13085
|
|
|
13011
13086
|
<details>
|
|
13012
13087
|
|
|
@@ -13115,7 +13190,7 @@ const result = R.update(index, newValue)(list)
|
|
|
13115
13190
|
// => [1, 2, 88, 4, 5]
|
|
13116
13191
|
```
|
|
13117
13192
|
|
|
13118
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
13193
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20index%20%3D%202%0Aconst%20newValue%20%3D%2088%0Aconst%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%2C%205%5D%0A%0Aconst%20result%20%3D%20R.update(index%2C%20newValue)(list)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%2C%2088%2C%204%2C%205%5D">Try this <strong>R.update</strong> example in Rambda REPL</a>
|
|
13119
13194
|
|
|
13120
13195
|
<details>
|
|
13121
13196
|
|
|
@@ -13216,7 +13291,7 @@ const expected = [
|
|
|
13216
13291
|
// => `result` is equal to `expected`
|
|
13217
13292
|
```
|
|
13218
13293
|
|
|
13219
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
13294
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20predicate%20%3D%20x%20%3D%3E%20typeof%20x%20%3D%3D%3D%20'number'%0Aconst%20fn%20%3D%20R.when(predicate)(x%20%3D%3E%20x%20%2B%201)%0A%0Aconst%20positiveInput%20%3D%2088%0Aconst%20negativeInput%20%3D%20'foo'%0A%0Aconst%20result%20%3D%20%5B%0A%20%20fn(positiveInput)%2C%0A%20%20fn(negativeInput)%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%2089%2C%0A%20%20'foo1'%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.when</strong> example in Rambda REPL</a>
|
|
13220
13295
|
|
|
13221
13296
|
<details>
|
|
13222
13297
|
|
|
@@ -13334,7 +13409,7 @@ R.zip([...x, 3])(['A', 'B'])
|
|
|
13334
13409
|
// => [[1, 'A'], [2, 'B']]
|
|
13335
13410
|
```
|
|
13336
13411
|
|
|
13337
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
13412
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20x%20%3D%20%5B1%2C%202%5D%0Aconst%20y%20%3D%20%5B'A'%2C%20'B'%5D%0AR.zip(x)(y)%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%20'A'%5D%2C%20%5B2%2C%20'B'%5D%5D%0A%0A%2F%2F%20truncates%20to%20shortest%20list%0Aconst%20result%20%3D%20R.zip(%5B...x%2C%203%5D)(%5B'A'%2C%20'B'%5D)%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%20'A'%5D%2C%20%5B2%2C%20'B'%5D%5D">Try this <strong>R.zip</strong> example in Rambda REPL</a>
|
|
13338
13413
|
|
|
13339
13414
|
<details>
|
|
13340
13415
|
|
|
@@ -13452,7 +13527,7 @@ const result = R.zipWith((x, y) => x + y, list1)(list2)
|
|
|
13452
13527
|
// => [110, 220]
|
|
13453
13528
|
```
|
|
13454
13529
|
|
|
13455
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.
|
|
13530
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.netlify.app?const%20list1%20%3D%20%5B%2010%2C%2020%2C%2030%2C%2040%20%5D%0Aconst%20list2%20%3D%20%5B%20100%2C%20200%20%5D%0A%0Aconst%20result%20%3D%20R.zipWith((x%2C%20y)%20%3D%3E%20x%20%2B%20y%2C%20list1)(list2)%0A%2F%2F%20%3D%3E%20%5B110%2C%20220%5D">Try this <strong>R.zipWith</strong> example in Rambda REPL</a>
|
|
13456
13531
|
|
|
13457
13532
|
<details>
|
|
13458
13533
|
|
|
@@ -13541,7 +13616,21 @@ describe('R.zipWith', () => {
|
|
|
13541
13616
|
|
|
13542
13617
|
## ❯ CHANGELOG
|
|
13543
13618
|
|
|
13544
|
-
10.3.
|
|
13619
|
+
10.3.4
|
|
13620
|
+
|
|
13621
|
+
- Fix wrong typing for `R.sortByDescending` - [Issue #797](https://github.com/selfrefactor/rambda/issues/797)
|
|
13622
|
+
|
|
13623
|
+
- Improve `R.mapParallelAsync` typings to allow optional `batchSize` parameter.
|
|
13624
|
+
|
|
13625
|
+
- Change order of inputs in `R.mapPropObject`
|
|
13626
|
+
|
|
13627
|
+
10.3.3
|
|
13628
|
+
|
|
13629
|
+
- Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
|
|
13630
|
+
|
|
13631
|
+
- Improve `R.pick` to not allow non-existing keys as input.
|
|
13632
|
+
|
|
13633
|
+
10.3.2
|
|
13545
13634
|
|
|
13546
13635
|
- Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
|
|
13547
13636
|
|