rambda 8.5.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +189 -364
- package/dist/rambda.js +102 -20
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +104 -20
- package/index.d.ts +104 -20
- package/package.json +15 -15
- package/rambda.js +7 -0
- package/src/forEach.js +1 -26
- package/src/forEachObjIndexed.js +25 -0
- package/src/gt.js +6 -0
- package/src/gte.js +6 -0
- package/src/hasIn.js +9 -0
- package/src/innerJoin.js +41 -0
- package/src/prop.js +8 -4
- package/src/reduceBy.js +29 -0
- package/src/sortWith.js +27 -0
- package/src/values.js +1 -2
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|

|
|
10
10
|
[](https://packagephobia.com/result?p=rambda)
|
|
11
11
|
[](https://nest.land/package/rambda)
|
|
12
|
-
[](http://hits.dwyl.com/selfrefactor/rambda)
|
|
13
12
|
|
|
14
13
|
## ❯ Example use
|
|
15
14
|
|
|
@@ -41,7 +40,15 @@ Still, you need to be aware that functional programming features in `TypeScript`
|
|
|
41
40
|
|
|
42
41
|
Important - Rambda version `7.1.0`(or higher) requires TypeScript version `4.3.3`(or higher).
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
### Understandable source code due to little usage of internals
|
|
44
|
+
|
|
45
|
+
`Ramda` uses a lot of internals, which hides a lot of logic. Reading the full source code of a method can be challenging.
|
|
46
|
+
|
|
47
|
+
### Better VSCode experience
|
|
48
|
+
|
|
49
|
+
If the project is written in Javascript, then `go to source definition` action will lead you to actual implementation of the method.
|
|
50
|
+
|
|
51
|
+
### Immutable TS definitions
|
|
45
52
|
|
|
46
53
|
You can use immutable version of Rambda definitions, which is linted with ESLint `functional/prefer-readonly-type` plugin.
|
|
47
54
|
|
|
@@ -59,7 +66,7 @@ Also, `Rambda` provides you with included TS definitions:
|
|
|
59
66
|
// Deno extension(https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno)
|
|
60
67
|
// is installed and initialized
|
|
61
68
|
import * as R from "https://deno.land/x/rambda/mod.ts";
|
|
62
|
-
import * as Ramda from "https://
|
|
69
|
+
import * as Ramda from "https://deno.land/x/ramda/mod.ts";
|
|
63
70
|
|
|
64
71
|
R.add(1)('foo') // => will trigger warning in VSCode as it should
|
|
65
72
|
Ramda.add(1)('foo') // => will not trigger warning in VSCode
|
|
@@ -98,17 +105,9 @@ One of the main issues with `Ramda` is the slow process of releasing new version
|
|
|
98
105
|
|
|
99
106
|
<details>
|
|
100
107
|
<summary>
|
|
101
|
-
Click to see the full list of
|
|
108
|
+
Click to see the full list of 51 Ramda methods not implemented in Rambda and their status.
|
|
102
109
|
</summary>
|
|
103
110
|
|
|
104
|
-
- dropRepeatsBy
|
|
105
|
-
- empty
|
|
106
|
-
- eqBy
|
|
107
|
-
- forEachObjIndexed
|
|
108
|
-
- gt
|
|
109
|
-
- gte
|
|
110
|
-
- hasIn
|
|
111
|
-
- innerJoin
|
|
112
111
|
- insert
|
|
113
112
|
- insertAll
|
|
114
113
|
- into
|
|
@@ -139,14 +138,12 @@ One of the main issues with `Ramda` is the slow process of releasing new version
|
|
|
139
138
|
- pipeWith
|
|
140
139
|
- project
|
|
141
140
|
- promap
|
|
142
|
-
- reduceBy
|
|
143
141
|
- reduceRight
|
|
144
142
|
- reduceWhile
|
|
145
143
|
- reduced
|
|
146
144
|
- remove
|
|
147
145
|
- scan
|
|
148
146
|
- sequence
|
|
149
|
-
- sortWith
|
|
150
147
|
- splitWhenever
|
|
151
148
|
- swap
|
|
152
149
|
- symmetricDifferenceWith
|
|
@@ -226,7 +223,7 @@ There are methods which are benchmarked only with `Ramda` and `Rambda`(i.e. no `
|
|
|
226
223
|
|
|
227
224
|
Note that some of these methods, are called with and without curring. This is done in order to give more detailed performance feedback.
|
|
228
225
|
|
|
229
|
-
The benchmarks results are produced from latest versions of *Rambda*, *Lodash*(4.17.21) and *Ramda*(0.29.
|
|
226
|
+
The benchmarks results are produced from latest versions of *Rambda*, *Lodash*(4.17.21) and *Ramda*(0.29.1).
|
|
230
227
|
|
|
231
228
|
</summary>
|
|
232
229
|
|
|
@@ -333,10 +330,14 @@ It adds `a` and `b`.
|
|
|
333
330
|
|
|
334
331
|
### addIndex
|
|
335
332
|
|
|
333
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.addIndex(R.map)((val%2C%20idx)%20%3D%3E%20val%20%2B%20idx%20%2B%201%2C%20%5B1%2C%202%2C%203%5D)%0A%2F%2F%20%3D%3E%20%5B2%2C%204%2C%206%5D">Try this <strong>R.addIndex</strong> example in Rambda REPL</a>
|
|
334
|
+
|
|
336
335
|
[](#addIndex)
|
|
337
336
|
|
|
338
337
|
### addIndexRight
|
|
339
338
|
|
|
339
|
+
Same as `R.addIndex`, but it will passed indexes are decreasing, instead of increasing.
|
|
340
|
+
|
|
340
341
|
[](#addIndexRight)
|
|
341
342
|
|
|
342
343
|
### adjust
|
|
@@ -957,6 +958,10 @@ describe('anyPass', () => {
|
|
|
957
958
|
ap<T, U>(fns: Array<(a: T) => U>[], vs: T[]): U[]
|
|
958
959
|
```
|
|
959
960
|
|
|
961
|
+
It takes a list of functions and a list of values. Then it returns a list of values obtained by applying each function to each value.
|
|
962
|
+
|
|
963
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.ap(%0A%20%20%5B%0A%20%20%20%20x%20%3D%3E%20x%20%2B%201%2C%0A%20%20%20%20x%20%3D%3E%20x%20%2B%202%2C%0A%20%20%5D%2C%0A%20%20%5B1%2C%202%2C%203%5D%0A)%0A%2F%2F%20%3D%3E%20%5B2%2C%203%2C%204%2C%203%2C%204%2C%205%5D">Try this <strong>R.ap</strong> example in Rambda REPL</a>
|
|
964
|
+
|
|
960
965
|
<details>
|
|
961
966
|
|
|
962
967
|
<summary>All TypeScript definitions</summary>
|
|
@@ -1015,6 +1020,10 @@ test('happy', () => {
|
|
|
1015
1020
|
aperture<N extends number, T>(n: N, list: T[]): Array<Tuple<T, N>> | []
|
|
1016
1021
|
```
|
|
1017
1022
|
|
|
1023
|
+
It returns a new list, composed of consecutive `n`-tuples from a `list`.
|
|
1024
|
+
|
|
1025
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.aperture(2%2C%20%5B1%2C%202%2C%203%2C%204%5D)%0A%2F%2F%20%3D%3E%20%5B%5B1%2C%202%5D%2C%20%5B2%2C%203%5D%2C%20%5B3%2C%204%5D%5D">Try this <strong>R.aperture</strong> example in Rambda REPL</a>
|
|
1026
|
+
|
|
1018
1027
|
<details>
|
|
1019
1028
|
|
|
1020
1029
|
<summary>All TypeScript definitions</summary>
|
|
@@ -1134,8 +1143,7 @@ export function append(x, input){
|
|
|
1134
1143
|
<summary><strong>Tests</strong></summary>
|
|
1135
1144
|
|
|
1136
1145
|
```javascript
|
|
1137
|
-
|
|
1138
|
-
import { append } from 'ramda'
|
|
1146
|
+
import { append } from './append.js'
|
|
1139
1147
|
|
|
1140
1148
|
test('happy', () => {
|
|
1141
1149
|
expect(append('tests', [ 'write', 'more' ])).toEqual([
|
|
@@ -1765,10 +1773,14 @@ describe('applySpec', () => {
|
|
|
1765
1773
|
|
|
1766
1774
|
### applyTo
|
|
1767
1775
|
|
|
1776
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.applyTo(%0A%20%201%2C%0A%20%20x%20%3D%3E%20x%20%2B%201%0A)%0A%2F%2F%20%3D%3E%202">Try this <strong>R.applyTo</strong> example in Rambda REPL</a>
|
|
1777
|
+
|
|
1768
1778
|
[](#applyTo)
|
|
1769
1779
|
|
|
1770
1780
|
### ascend
|
|
1771
1781
|
|
|
1782
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(%0A%20%20R.ascend(x%20%3D%3E%20x)%2C%0A%20%20%5B2%2C%201%5D%0A)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.ascend</strong> example in Rambda REPL</a>
|
|
1783
|
+
|
|
1772
1784
|
[](#ascend)
|
|
1773
1785
|
|
|
1774
1786
|
### assoc
|
|
@@ -2110,6 +2122,8 @@ describe('R.assocPath - curried', () => {
|
|
|
2110
2122
|
|
|
2111
2123
|
### binary
|
|
2112
2124
|
|
|
2125
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.binary(%0A%20%20(a%2C%20b%2C%20c)%20%3D%3E%20a%20%2B%20b%20%2B%20c%2C%0A)(1%2C%202%2C%203%2C%204)%0A%2F%2F%20%3D%3E%203">Try this <strong>R.binary</strong> example in Rambda REPL</a>
|
|
2126
|
+
|
|
2113
2127
|
[](#binary)
|
|
2114
2128
|
|
|
2115
2129
|
### bind
|
|
@@ -2422,6 +2436,8 @@ describe('R.both', () => {
|
|
|
2422
2436
|
|
|
2423
2437
|
### call
|
|
2424
2438
|
|
|
2439
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.call(%0A%20%20(a%2C%20b)%20%3D%3E%20a%20%2B%20b%2C%0A%20%201%2C%0A%20%202%0A)%0A%2F%2F%20%3D%3E%203">Try this <strong>R.call</strong> example in Rambda REPL</a>
|
|
2440
|
+
|
|
2425
2441
|
[](#call)
|
|
2426
2442
|
|
|
2427
2443
|
### chain
|
|
@@ -2581,10 +2597,16 @@ It creates a deep copy of the `input`, which may contain (nested) Arrays and Obj
|
|
|
2581
2597
|
|
|
2582
2598
|
### collectBy
|
|
2583
2599
|
|
|
2600
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.collectBy(%0A%20%20x%20%3D%3E%20x%20%25%202%2C%0A%20%20%5B1%2C%202%2C%203%2C%204%5D%0A)%0A%2F%2F%20%3D%3E%20%5B%5B2%2C%204%5D%2C%20%5B1%2C%203%5D%5D">Try this <strong>R.collectBy</strong> example in Rambda REPL</a>
|
|
2601
|
+
|
|
2584
2602
|
[](#collectBy)
|
|
2585
2603
|
|
|
2586
2604
|
### comparator
|
|
2587
2605
|
|
|
2606
|
+
It returns a comparator function that can be used in `sort` method.
|
|
2607
|
+
|
|
2608
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(%0A%20%20R.comparator((a%2C%20b)%20%3D%3E%20a.x%20%3C%20b.x)%2C%0A%20%20%5B%7Bx%3A%202%7D%2C%20%7Bx%3A%201%7D%5D%0A)%0A%2F%2F%20%3D%3E%20%5B%7Bx%3A%201%7D%2C%20%7Bx%3A%202%7D%5D">Try this <strong>R.comparator</strong> example in Rambda REPL</a>
|
|
2609
|
+
|
|
2588
2610
|
[](#comparator)
|
|
2589
2611
|
|
|
2590
2612
|
### complement
|
|
@@ -2607,6 +2629,8 @@ It performs right-to-left function composition.
|
|
|
2607
2629
|
|
|
2608
2630
|
### composeWith
|
|
2609
2631
|
|
|
2632
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.composeWith(%0A%20%20(fn%2C%20intermediateResult)%20%3D%3E%20fn(intermediateResult)%2C%0A%20%20%5B%0A%20%20%20%20R.map(x%20%3D%3E%20x%20%2B%201)%2C%0A%20%20%20%20R.map(x%20%3D%3E%20x%20*%202)%2C%0A%20%20%5D%0A)(%5B1%2C%202%2C%203%5D)%0A%2F%2F%20%3D%3E%20%5B3%2C%205%2C%207%5D">Try this <strong>R.composeWith</strong> example in Rambda REPL</a>
|
|
2633
|
+
|
|
2610
2634
|
[](#composeWith)
|
|
2611
2635
|
|
|
2612
2636
|
### concat
|
|
@@ -2762,6 +2786,8 @@ It returns a curried equivalent of the provided function, with the specified ari
|
|
|
2762
2786
|
|
|
2763
2787
|
It decrements a number.
|
|
2764
2788
|
|
|
2789
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.dec(2)%20%2F%2F%20%3D%3E%201">Try this <strong>R.dec</strong> example in Rambda REPL</a>
|
|
2790
|
+
|
|
2765
2791
|
[](#dec)
|
|
2766
2792
|
|
|
2767
2793
|
### defaultTo
|
|
@@ -2869,6 +2895,8 @@ describe('R.defaultTo with Ramda spec', () => {
|
|
|
2869
2895
|
|
|
2870
2896
|
### descend
|
|
2871
2897
|
|
|
2898
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?R.sort(%0A%20%20R.descend(x%20%3D%3E%20x)%2C%0A%20%20%5B1%2C%202%5D%0Aconst%20result%20%3D%20)%0A%2F%2F%20%3D%3E%20%5B2%2C%201%5D">Try this <strong>R.descend</strong> example in Rambda REPL</a>
|
|
2899
|
+
|
|
2872
2900
|
[](#descend)
|
|
2873
2901
|
|
|
2874
2902
|
### difference
|
|
@@ -2988,6 +3016,8 @@ differenceWith<T1, T2>(
|
|
|
2988
3016
|
): T1[]
|
|
2989
3017
|
```
|
|
2990
3018
|
|
|
3019
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.differenceWith(%0A%20%20(a%2C%20b)%20%3D%3E%20a.x%20%3D%3D%3D%20b.x%2C%0A%20%20%5B%7Bx%3A%201%7D%2C%20%7Bx%3A%202%7D%5D%2C%0A%20%20%5B%7Bx%3A%201%7D%2C%20%7Bx%3A%203%7D%5D%0A)%0A%2F%2F%20%3D%3E%20%5B%7Bx%3A%202%7D%5D">Try this <strong>R.differenceWith</strong> example in Rambda REPL</a>
|
|
3020
|
+
|
|
2991
3021
|
<details>
|
|
2992
3022
|
|
|
2993
3023
|
<summary>All TypeScript definitions</summary>
|
|
@@ -3072,6 +3102,8 @@ It returns a new object that does not contain property `prop`.
|
|
|
3072
3102
|
|
|
3073
3103
|
### dissocPath
|
|
3074
3104
|
|
|
3105
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.dissocPath(%5B'a'%2C%20'b'%5D%2C%20%7Ba%3A%20%7Bb%3A%201%2C%20c%3A%202%7D%7D)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20%7Bc%3A%202%7D%7D">Try this <strong>R.dissocPath</strong> example in Rambda REPL</a>
|
|
3106
|
+
|
|
3075
3107
|
[](#dissocPath)
|
|
3076
3108
|
|
|
3077
3109
|
### divide
|
|
@@ -3439,6 +3471,8 @@ describe('R.dropRepeats', () => {
|
|
|
3439
3471
|
|
|
3440
3472
|
### dropRepeatsBy
|
|
3441
3473
|
|
|
3474
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
3475
|
+
|
|
3442
3476
|
[](#dropRepeatsBy)
|
|
3443
3477
|
|
|
3444
3478
|
### dropRepeatsWith
|
|
@@ -3608,6 +3642,8 @@ describe('R.either', () => {
|
|
|
3608
3642
|
|
|
3609
3643
|
### empty
|
|
3610
3644
|
|
|
3645
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5BR.empty(%5B1%2C2%2C3%5D)%2C%20R.empty('foo')%2C%20R.empty(%7Bx%3A%201%2C%20y%3A%202%7D)%5D%0A%2F%2F%20%3D%3E%20%5B%5B%5D%2C%20''%2C%20%7B%7D%5D">Try this <strong>R.empty</strong> example in Rambda REPL</a>
|
|
3646
|
+
|
|
3611
3647
|
[](#empty)
|
|
3612
3648
|
|
|
3613
3649
|
### endsWith
|
|
@@ -3773,6 +3809,8 @@ describe('R.endsWith - string', () => {
|
|
|
3773
3809
|
|
|
3774
3810
|
### eqBy
|
|
3775
3811
|
|
|
3812
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.eqBy(Math.abs%2C%205%2C%20-5)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.eqBy</strong> example in Rambda REPL</a>
|
|
3813
|
+
|
|
3776
3814
|
[](#eqBy)
|
|
3777
3815
|
|
|
3778
3816
|
### eqProps
|
|
@@ -5431,35 +5469,10 @@ forEach<T, U>(fn: ObjectIterator<T, void>): (list: Dictionary<T>) => Dictionary<
|
|
|
5431
5469
|
|
|
5432
5470
|
```javascript
|
|
5433
5471
|
import { isArray } from './_internals/isArray.js'
|
|
5434
|
-
import {
|
|
5435
|
-
|
|
5436
|
-
export function forEachObjIndexedFn(fn, obj){
|
|
5437
|
-
let index = 0
|
|
5438
|
-
const listKeys = keys(obj)
|
|
5439
|
-
const len = listKeys.length
|
|
5440
|
-
|
|
5441
|
-
while (index < len){
|
|
5442
|
-
const key = listKeys[ index ]
|
|
5443
|
-
fn(
|
|
5444
|
-
obj[ key ], key, obj
|
|
5445
|
-
)
|
|
5446
|
-
index++
|
|
5447
|
-
}
|
|
5448
|
-
|
|
5449
|
-
return obj
|
|
5450
|
-
}
|
|
5451
|
-
|
|
5452
|
-
export function forEachObjIndexed(fn, list){
|
|
5453
|
-
if (arguments.length === 1) return _list => forEachObjIndexed(fn, _list)
|
|
5454
|
-
|
|
5455
|
-
if (list === undefined) return
|
|
5456
|
-
|
|
5457
|
-
return forEachObjIndexedFn(fn, list)
|
|
5458
|
-
}
|
|
5472
|
+
import { forEachObjIndexedFn } from './forEachObjIndexed.js'
|
|
5459
5473
|
|
|
5460
5474
|
export function forEach(fn, iterable){
|
|
5461
5475
|
if (arguments.length === 1) return _list => forEach(fn, _list)
|
|
5462
|
-
|
|
5463
5476
|
if (iterable === undefined) return
|
|
5464
5477
|
|
|
5465
5478
|
if (isArray(iterable)){
|
|
@@ -5631,6 +5644,18 @@ It returns separated version of list or string `input`, where separation is done
|
|
|
5631
5644
|
|
|
5632
5645
|
[](#groupWith)
|
|
5633
5646
|
|
|
5647
|
+
### gt
|
|
5648
|
+
|
|
5649
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5BR.gt(2%2C%201)%2C%20R.gt(2%2C%203)%5D%0A%2F%2F%20%3D%3E%20%5Btrue%2C%20false%5D">Try this <strong>R.gt</strong> example in Rambda REPL</a>
|
|
5650
|
+
|
|
5651
|
+
[](#gt)
|
|
5652
|
+
|
|
5653
|
+
### gte
|
|
5654
|
+
|
|
5655
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5BR.gte(2%2C%201)%2C%20R.gte(2%2C%202)%2C%20R.gte(2%2C%203)%5D%0A%2F%2F%20%3D%3E%20%5Btrue%2C%20true%2C%20false%5D">Try this <strong>R.gte</strong> example in Rambda REPL</a>
|
|
5656
|
+
|
|
5657
|
+
[](#gte)
|
|
5658
|
+
|
|
5634
5659
|
### has
|
|
5635
5660
|
|
|
5636
5661
|
```typescript
|
|
@@ -5713,6 +5738,12 @@ describe('R.has', () => {
|
|
|
5713
5738
|
|
|
5714
5739
|
[](#has)
|
|
5715
5740
|
|
|
5741
|
+
### hasIn
|
|
5742
|
+
|
|
5743
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.hasIn('a'%2C%20%7Ba%3A%201%7D)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.hasIn</strong> example in Rambda REPL</a>
|
|
5744
|
+
|
|
5745
|
+
[](#hasIn)
|
|
5746
|
+
|
|
5716
5747
|
### hasPath
|
|
5717
5748
|
|
|
5718
5749
|
```typescript
|
|
@@ -6491,6 +6522,14 @@ describe('R.init', () => {
|
|
|
6491
6522
|
|
|
6492
6523
|
[](#init)
|
|
6493
6524
|
|
|
6525
|
+
### innerJoin
|
|
6526
|
+
|
|
6527
|
+
It returns a new list by applying a `predicate` function to all elements of `list1` and `list2` and keeping only these elements where `predicate` returns `true`.
|
|
6528
|
+
|
|
6529
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%2C%20list2)%0A%2F%2F%20%3D%3E%20%5B4%2C%205%5D">Try this <strong>R.innerJoin</strong> example in Rambda REPL</a>
|
|
6530
|
+
|
|
6531
|
+
[](#innerJoin)
|
|
6532
|
+
|
|
6494
6533
|
### intersection
|
|
6495
6534
|
|
|
6496
6535
|
It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
|
|
@@ -7147,7 +7186,7 @@ test('with length as property', () => {
|
|
|
7147
7186
|
|
|
7148
7187
|
```typescript
|
|
7149
7188
|
|
|
7150
|
-
lens<
|
|
7189
|
+
lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>
|
|
7151
7190
|
```
|
|
7152
7191
|
|
|
7153
7192
|
It returns a `lens` for the given `getter` and `setter` functions.
|
|
@@ -7163,7 +7202,7 @@ The setter should not mutate the data structure.
|
|
|
7163
7202
|
<summary>All TypeScript definitions</summary>
|
|
7164
7203
|
|
|
7165
7204
|
```typescript
|
|
7166
|
-
lens<
|
|
7205
|
+
lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>;
|
|
7167
7206
|
```
|
|
7168
7207
|
|
|
7169
7208
|
</details>
|
|
@@ -7189,19 +7228,56 @@ export function lens(getter, setter){
|
|
|
7189
7228
|
<summary><strong>TypeScript</strong> test</summary>
|
|
7190
7229
|
|
|
7191
7230
|
```typescript
|
|
7192
|
-
import {lens, assoc} from 'rambda'
|
|
7231
|
+
import {lens, assoc, lensProp, view, lensIndex, lensPath} from 'rambda'
|
|
7193
7232
|
|
|
7194
7233
|
interface Input {
|
|
7195
7234
|
foo: string,
|
|
7196
7235
|
}
|
|
7236
|
+
const testObject: Input = {
|
|
7237
|
+
foo: 'Jazz',
|
|
7238
|
+
}
|
|
7197
7239
|
|
|
7198
7240
|
describe('R.lens', () => {
|
|
7199
7241
|
it('happy', () => {
|
|
7200
|
-
const fn = lens<Input, string
|
|
7242
|
+
const fn = lens<Input, string>((x: Input) => {
|
|
7201
7243
|
x.foo // $ExpectType string
|
|
7202
7244
|
return x.foo
|
|
7203
7245
|
}, assoc('name'))
|
|
7204
|
-
fn // $ExpectType Lens
|
|
7246
|
+
fn // $ExpectType Lens<Input, string>
|
|
7247
|
+
})
|
|
7248
|
+
})
|
|
7249
|
+
|
|
7250
|
+
describe('R.lensProp', () => {
|
|
7251
|
+
it('happy', () => {
|
|
7252
|
+
const result = view<Input, string>(lensProp('foo'), testObject)
|
|
7253
|
+
result // $ExpectType string
|
|
7254
|
+
})
|
|
7255
|
+
})
|
|
7256
|
+
|
|
7257
|
+
describe('R.lensIndex', () => {
|
|
7258
|
+
const testList: Input[] = [{foo: 'bar'}, {foo: 'baz'}]
|
|
7259
|
+
it('happy', () => {
|
|
7260
|
+
const result = view<Input[], Input>(lensIndex(0), testList)
|
|
7261
|
+
result // $ExpectType Input
|
|
7262
|
+
result.foo // $ExpectType string
|
|
7263
|
+
})
|
|
7264
|
+
})
|
|
7265
|
+
|
|
7266
|
+
describe('R.lensPath', () => {
|
|
7267
|
+
const path = lensPath(['bar', 'a'])
|
|
7268
|
+
it('happy', () => {
|
|
7269
|
+
const result = view<Input, string>(path, testObject)
|
|
7270
|
+
result // $ExpectType string
|
|
7271
|
+
})
|
|
7272
|
+
})
|
|
7273
|
+
|
|
7274
|
+
describe('R.view', () => {
|
|
7275
|
+
const fooLens = lens<Input, string>((x: Input) => {
|
|
7276
|
+
return x.foo
|
|
7277
|
+
}, assoc('foo'))
|
|
7278
|
+
it('happt', () => {
|
|
7279
|
+
const result = view<Input, string>(fooLens, testObject)
|
|
7280
|
+
result // $ExpectType string
|
|
7205
7281
|
})
|
|
7206
7282
|
})
|
|
7207
7283
|
```
|
|
@@ -7214,7 +7290,7 @@ describe('R.lens', () => {
|
|
|
7214
7290
|
|
|
7215
7291
|
```typescript
|
|
7216
7292
|
|
|
7217
|
-
lensIndex(
|
|
7293
|
+
lensIndex<A>(n: number): Lens<A[], A>
|
|
7218
7294
|
```
|
|
7219
7295
|
|
|
7220
7296
|
It returns a lens that focuses on specified `index`.
|
|
@@ -7226,7 +7302,8 @@ It returns a lens that focuses on specified `index`.
|
|
|
7226
7302
|
<summary>All TypeScript definitions</summary>
|
|
7227
7303
|
|
|
7228
7304
|
```typescript
|
|
7229
|
-
lensIndex(
|
|
7305
|
+
lensIndex<A>(n: number): Lens<A[], A>;
|
|
7306
|
+
lensIndex<A extends any[], N extends number>(n: N): Lens<A, A[N]>;
|
|
7230
7307
|
```
|
|
7231
7308
|
|
|
7232
7309
|
</details>
|
|
@@ -7312,250 +7389,21 @@ test('get (set(set s v1) v2) === v2', () => {
|
|
|
7312
7389
|
|
|
7313
7390
|
</details>
|
|
7314
7391
|
|
|
7315
|
-
<details>
|
|
7316
|
-
|
|
7317
|
-
<summary><strong>TypeScript</strong> test</summary>
|
|
7318
|
-
|
|
7319
|
-
```typescript
|
|
7320
|
-
import {view, lensIndex} from 'rambda'
|
|
7321
|
-
|
|
7322
|
-
interface Input {
|
|
7323
|
-
a: number,
|
|
7324
|
-
}
|
|
7325
|
-
const testList: Input[] = [{a: 1}, {a: 2}, {a: 3}]
|
|
7326
|
-
|
|
7327
|
-
describe('R.lensIndex', () => {
|
|
7328
|
-
it('happy', () => {
|
|
7329
|
-
const result = view<Input[], Input>(lensIndex(0), testList)
|
|
7330
|
-
result // $ExpectType Input
|
|
7331
|
-
result.a // $ExpectType number
|
|
7332
|
-
})
|
|
7333
|
-
})
|
|
7334
|
-
```
|
|
7335
|
-
|
|
7336
|
-
</details>
|
|
7337
|
-
|
|
7338
7392
|
[](#lensIndex)
|
|
7339
7393
|
|
|
7340
7394
|
### lensPath
|
|
7341
7395
|
|
|
7342
|
-
```typescript
|
|
7343
|
-
|
|
7344
|
-
lensPath(path: RamdaPath): Lens
|
|
7345
|
-
```
|
|
7346
|
-
|
|
7347
7396
|
It returns a lens that focuses on specified `path`.
|
|
7348
7397
|
|
|
7349
7398
|
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20lensPath%20%3D%20R.lensPath(%5B'x'%2C%200%2C%20'y'%5D)%0Aconst%20input%20%3D%20%7Bx%3A%20%5B%7By%3A%202%2C%20z%3A%203%7D%2C%20%7By%3A%204%2C%20z%3A%205%7D%5D%7D%0A%0AR.view(lensPath%2C%20input)%20%2F%2F%20%3D%3E%202%0A%0AR.set(lensPath%2C%201%2C%20input)%20%0A%2F%2F%20%3D%3E%20%7Bx%3A%20%5B%7By%3A%201%2C%20z%3A%203%7D%2C%20%7By%3A%204%2C%20z%3A%205%7D%5D%7D%0A%0Aconst%20result%20%3D%20R.over(xHeadYLens%2C%20R.negate%2C%20input)%20%0A%2F%2F%20%3D%3E%20%7Bx%3A%20%5B%7By%3A%20-2%2C%20z%3A%203%7D%2C%20%7By%3A%204%2C%20z%3A%205%7D%5D%7D">Try this <strong>R.lensPath</strong> example in Rambda REPL</a>
|
|
7350
7399
|
|
|
7351
|
-
<details>
|
|
7352
|
-
|
|
7353
|
-
<summary>All TypeScript definitions</summary>
|
|
7354
|
-
|
|
7355
|
-
```typescript
|
|
7356
|
-
lensPath(path: RamdaPath): Lens;
|
|
7357
|
-
lensPath(path: string): Lens;
|
|
7358
|
-
```
|
|
7359
|
-
|
|
7360
|
-
</details>
|
|
7361
|
-
|
|
7362
|
-
<details>
|
|
7363
|
-
|
|
7364
|
-
<summary><strong>R.lensPath</strong> source</summary>
|
|
7365
|
-
|
|
7366
|
-
```javascript
|
|
7367
|
-
import { assocPath } from './assocPath.js'
|
|
7368
|
-
import { lens } from './lens.js'
|
|
7369
|
-
import { path } from './path.js'
|
|
7370
|
-
|
|
7371
|
-
export function lensPath(key){
|
|
7372
|
-
return lens(path(key), assocPath(key))
|
|
7373
|
-
}
|
|
7374
|
-
```
|
|
7375
|
-
|
|
7376
|
-
</details>
|
|
7377
|
-
|
|
7378
|
-
<details>
|
|
7379
|
-
|
|
7380
|
-
<summary><strong>Tests</strong></summary>
|
|
7381
|
-
|
|
7382
|
-
```javascript
|
|
7383
|
-
import { compose } from './compose.js'
|
|
7384
|
-
import { identity } from './identity.js'
|
|
7385
|
-
import { inc } from './inc.js'
|
|
7386
|
-
import { lensPath } from './lensPath.js'
|
|
7387
|
-
import { lensProp } from './lensProp.js'
|
|
7388
|
-
import { over } from './over.js'
|
|
7389
|
-
import { set } from './set.js'
|
|
7390
|
-
import { view } from './view.js'
|
|
7391
|
-
|
|
7392
|
-
const testObj = {
|
|
7393
|
-
a : [ { b : 1 }, { b : 2 } ],
|
|
7394
|
-
d : 3,
|
|
7395
|
-
}
|
|
7396
|
-
|
|
7397
|
-
test('view', () => {
|
|
7398
|
-
expect(view(lensPath('d'), testObj)).toBe(3)
|
|
7399
|
-
expect(view(lensPath('a.0.b'), testObj)).toBe(1)
|
|
7400
|
-
// this is different to ramda, as ramda will return a clone of the input object
|
|
7401
|
-
expect(view(lensPath(''), testObj)).toBeUndefined()
|
|
7402
|
-
})
|
|
7403
|
-
|
|
7404
|
-
test('set', () => {
|
|
7405
|
-
expect(set(
|
|
7406
|
-
lensProp('d'), 0, testObj
|
|
7407
|
-
)).toEqual({
|
|
7408
|
-
a : [ { b : 1 }, { b : 2 } ],
|
|
7409
|
-
d : 0,
|
|
7410
|
-
})
|
|
7411
|
-
expect(set(
|
|
7412
|
-
lensPath('a.0.b'), 0, testObj
|
|
7413
|
-
)).toEqual({
|
|
7414
|
-
a : [ { b : 0 }, { b : 2 } ],
|
|
7415
|
-
d : 3,
|
|
7416
|
-
})
|
|
7417
|
-
expect(set(
|
|
7418
|
-
lensPath('a.0.X'), 0, testObj
|
|
7419
|
-
)).toEqual({
|
|
7420
|
-
a : [
|
|
7421
|
-
{
|
|
7422
|
-
b : 1,
|
|
7423
|
-
X : 0,
|
|
7424
|
-
},
|
|
7425
|
-
{ b : 2 },
|
|
7426
|
-
],
|
|
7427
|
-
d : 3,
|
|
7428
|
-
})
|
|
7429
|
-
expect(set(
|
|
7430
|
-
lensPath([]), 0, testObj
|
|
7431
|
-
)).toBe(0)
|
|
7432
|
-
})
|
|
7433
|
-
|
|
7434
|
-
test('over', () => {
|
|
7435
|
-
expect(over(
|
|
7436
|
-
lensPath('d'), inc, testObj
|
|
7437
|
-
)).toEqual({
|
|
7438
|
-
a : [ { b : 1 }, { b : 2 } ],
|
|
7439
|
-
d : 4,
|
|
7440
|
-
})
|
|
7441
|
-
expect(over(
|
|
7442
|
-
lensPath('a.1.b'), inc, testObj
|
|
7443
|
-
)).toEqual({
|
|
7444
|
-
a : [ { b : 1 }, { b : 3 } ],
|
|
7445
|
-
d : 3,
|
|
7446
|
-
})
|
|
7447
|
-
expect(over(
|
|
7448
|
-
lensProp('X'), identity, testObj
|
|
7449
|
-
)).toEqual({
|
|
7450
|
-
a : [ { b : 1 }, { b : 2 } ],
|
|
7451
|
-
d : 3,
|
|
7452
|
-
X : undefined,
|
|
7453
|
-
})
|
|
7454
|
-
expect(over(
|
|
7455
|
-
lensPath('a.0.X'), identity, testObj
|
|
7456
|
-
)).toEqual({
|
|
7457
|
-
a : [
|
|
7458
|
-
{
|
|
7459
|
-
b : 1,
|
|
7460
|
-
X : undefined,
|
|
7461
|
-
},
|
|
7462
|
-
{ b : 2 },
|
|
7463
|
-
],
|
|
7464
|
-
d : 3,
|
|
7465
|
-
})
|
|
7466
|
-
})
|
|
7467
|
-
|
|
7468
|
-
test('compose', () => {
|
|
7469
|
-
const composedLens = compose(lensPath('a'), lensPath('1.b'))
|
|
7470
|
-
expect(view(composedLens, testObj)).toBe(2)
|
|
7471
|
-
})
|
|
7472
|
-
|
|
7473
|
-
test('set s (get s) === s', () => {
|
|
7474
|
-
expect(set(
|
|
7475
|
-
lensPath([ 'd' ]), view(lensPath([ 'd' ]), testObj), testObj
|
|
7476
|
-
)).toEqual(testObj)
|
|
7477
|
-
expect(set(
|
|
7478
|
-
lensPath([ 'a', 0, 'b' ]),
|
|
7479
|
-
view(lensPath([ 'a', 0, 'b' ]), testObj),
|
|
7480
|
-
testObj
|
|
7481
|
-
)).toEqual(testObj)
|
|
7482
|
-
})
|
|
7483
|
-
|
|
7484
|
-
test('get (set s v) === v', () => {
|
|
7485
|
-
expect(view(lensPath([ 'd' ]), set(
|
|
7486
|
-
lensPath([ 'd' ]), 0, testObj
|
|
7487
|
-
))).toBe(0)
|
|
7488
|
-
expect(view(lensPath([ 'a', 0, 'b' ]), set(
|
|
7489
|
-
lensPath([ 'a', 0, 'b' ]), 0, testObj
|
|
7490
|
-
))).toBe(0)
|
|
7491
|
-
})
|
|
7492
|
-
|
|
7493
|
-
test('get (set(set s v1) v2) === v2', () => {
|
|
7494
|
-
const p = [ 'd' ]
|
|
7495
|
-
const q = [ 'a', 0, 'b' ]
|
|
7496
|
-
expect(view(lensPath(p), set(
|
|
7497
|
-
lensPath(p), 11, set(
|
|
7498
|
-
lensPath(p), 10, testObj
|
|
7499
|
-
)
|
|
7500
|
-
))).toBe(11)
|
|
7501
|
-
expect(view(lensPath(q), set(
|
|
7502
|
-
lensPath(q), 11, set(
|
|
7503
|
-
lensPath(q), 10, testObj
|
|
7504
|
-
)
|
|
7505
|
-
))).toBe(11)
|
|
7506
|
-
})
|
|
7507
|
-
```
|
|
7508
|
-
|
|
7509
|
-
</details>
|
|
7510
|
-
|
|
7511
|
-
<details>
|
|
7512
|
-
|
|
7513
|
-
<summary><strong>TypeScript</strong> test</summary>
|
|
7514
|
-
|
|
7515
|
-
```typescript
|
|
7516
|
-
import {lensPath, view} from 'rambda'
|
|
7517
|
-
|
|
7518
|
-
interface Input {
|
|
7519
|
-
foo: number[],
|
|
7520
|
-
bar: {
|
|
7521
|
-
a: string,
|
|
7522
|
-
b: string,
|
|
7523
|
-
},
|
|
7524
|
-
}
|
|
7525
|
-
|
|
7526
|
-
const testObject: Input = {
|
|
7527
|
-
foo: [1, 2],
|
|
7528
|
-
bar: {
|
|
7529
|
-
a: 'x',
|
|
7530
|
-
b: 'y',
|
|
7531
|
-
},
|
|
7532
|
-
}
|
|
7533
|
-
|
|
7534
|
-
const path = lensPath(['bar', 'a'])
|
|
7535
|
-
const pathAsString = lensPath('bar.a')
|
|
7536
|
-
|
|
7537
|
-
describe('R.lensPath', () => {
|
|
7538
|
-
it('happy', () => {
|
|
7539
|
-
const result = view<Input, string>(path, testObject)
|
|
7540
|
-
result // $ExpectType string
|
|
7541
|
-
})
|
|
7542
|
-
it('using string as path input', () => {
|
|
7543
|
-
const result = view<Input, string>(pathAsString, testObject)
|
|
7544
|
-
result // $ExpectType string
|
|
7545
|
-
})
|
|
7546
|
-
})
|
|
7547
|
-
```
|
|
7548
|
-
|
|
7549
|
-
</details>
|
|
7550
|
-
|
|
7551
7400
|
[](#lensPath)
|
|
7552
7401
|
|
|
7553
7402
|
### lensProp
|
|
7554
7403
|
|
|
7555
7404
|
```typescript
|
|
7556
7405
|
|
|
7557
|
-
lensProp(prop:
|
|
7558
|
-
<T, U>(obj: T): U
|
|
7406
|
+
lensProp<S, K extends keyof S = keyof S>(prop: K): Lens<S, S[K]>
|
|
7559
7407
|
```
|
|
7560
7408
|
|
|
7561
7409
|
It returns a lens that focuses on specified property `prop`.
|
|
@@ -7567,10 +7415,7 @@ It returns a lens that focuses on specified property `prop`.
|
|
|
7567
7415
|
<summary>All TypeScript definitions</summary>
|
|
7568
7416
|
|
|
7569
7417
|
```typescript
|
|
7570
|
-
lensProp(prop:
|
|
7571
|
-
<T, U>(obj: T): U;
|
|
7572
|
-
set<T, U, V>(val: T, obj: U): V;
|
|
7573
|
-
};
|
|
7418
|
+
lensProp<S, K extends keyof S = keyof S>(prop: K): Lens<S, S[K]>;
|
|
7574
7419
|
```
|
|
7575
7420
|
|
|
7576
7421
|
</details>
|
|
@@ -7694,33 +7539,6 @@ test('get (set(set s v1) v2) === v2', () => {
|
|
|
7694
7539
|
|
|
7695
7540
|
</details>
|
|
7696
7541
|
|
|
7697
|
-
<details>
|
|
7698
|
-
|
|
7699
|
-
<summary><strong>TypeScript</strong> test</summary>
|
|
7700
|
-
|
|
7701
|
-
```typescript
|
|
7702
|
-
import {lensProp, view} from 'rambda'
|
|
7703
|
-
|
|
7704
|
-
interface Input {
|
|
7705
|
-
foo: string,
|
|
7706
|
-
}
|
|
7707
|
-
|
|
7708
|
-
const testObject: Input = {
|
|
7709
|
-
foo: 'Led Zeppelin',
|
|
7710
|
-
}
|
|
7711
|
-
|
|
7712
|
-
const lens = lensProp('foo')
|
|
7713
|
-
|
|
7714
|
-
describe('R.lensProp', () => {
|
|
7715
|
-
it('happy', () => {
|
|
7716
|
-
const result = view<Input, string>(lens, testObject)
|
|
7717
|
-
result // $ExpectType string
|
|
7718
|
-
})
|
|
7719
|
-
})
|
|
7720
|
-
```
|
|
7721
|
-
|
|
7722
|
-
</details>
|
|
7723
|
-
|
|
7724
7542
|
[](#lensProp)
|
|
7725
7543
|
|
|
7726
7544
|
### map
|
|
@@ -11694,6 +11512,10 @@ test('happy', () => {
|
|
|
11694
11512
|
expect(pluck('a')([ { a : 1 }, { a : 2 }, { b : 1 } ])).toEqual([ 1, 2 ])
|
|
11695
11513
|
})
|
|
11696
11514
|
|
|
11515
|
+
test('with undefined', () => {
|
|
11516
|
+
expect(pluck(undefined)([ { a : 1 }, { a : 2 }, { b : 1 } ])).toEqual([ ])
|
|
11517
|
+
})
|
|
11518
|
+
|
|
11697
11519
|
test('with number', () => {
|
|
11698
11520
|
const input = [
|
|
11699
11521
|
[ 1, 2 ],
|
|
@@ -11918,12 +11740,16 @@ prop<V>(p: keyof never): (value: unknown) => V;
|
|
|
11918
11740
|
<summary><strong>R.prop</strong> source</summary>
|
|
11919
11741
|
|
|
11920
11742
|
```javascript
|
|
11921
|
-
export function
|
|
11922
|
-
if (arguments.length === 1) return _obj => prop(propToFind, _obj)
|
|
11923
|
-
|
|
11743
|
+
export function propFn(searchProperty, obj){
|
|
11924
11744
|
if (!obj) return undefined
|
|
11925
11745
|
|
|
11926
|
-
return obj[
|
|
11746
|
+
return obj[ searchProperty ]
|
|
11747
|
+
}
|
|
11748
|
+
|
|
11749
|
+
export function prop(searchProperty, obj){
|
|
11750
|
+
if (arguments.length === 1) return _obj => prop(searchProperty, _obj)
|
|
11751
|
+
|
|
11752
|
+
return propFn(searchProperty, obj)
|
|
11927
11753
|
}
|
|
11928
11754
|
```
|
|
11929
11755
|
|
|
@@ -12654,6 +12480,12 @@ describe('R.range', () => {
|
|
|
12654
12480
|
|
|
12655
12481
|
[](#reduce)
|
|
12656
12482
|
|
|
12483
|
+
### reduceBy
|
|
12484
|
+
|
|
12485
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.reduceBy(%0A%20%20(acc%2C%20elem)%20%3D%3E%20acc%20%2B%20elem%2C%0A%20%200%2C%0A%20%20x%20%3D%3E%20x%20%3E%202%20%3F%20'big'%20%3A%20'small'%2C%0A%20%20%5B1%2C%202%2C%203%2C%204%2C%205%5D%0A)%0A%2F%2F%20%3D%3E%20%7B%20big%3A%2012%2C%20small%3A%203%20%7D">Try this <strong>R.reduceBy</strong> example in Rambda REPL</a>
|
|
12486
|
+
|
|
12487
|
+
[](#reduceBy)
|
|
12488
|
+
|
|
12657
12489
|
### reject
|
|
12658
12490
|
|
|
12659
12491
|
```typescript
|
|
@@ -13603,6 +13435,12 @@ describe('R.sortBy', () => {
|
|
|
13603
13435
|
|
|
13604
13436
|
[](#sortBy)
|
|
13605
13437
|
|
|
13438
|
+
### sortWith
|
|
13439
|
+
|
|
13440
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%2C%20%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>
|
|
13441
|
+
|
|
13442
|
+
[](#sortWith)
|
|
13443
|
+
|
|
13606
13444
|
### split
|
|
13607
13445
|
|
|
13608
13446
|
```typescript
|
|
@@ -16208,6 +16046,8 @@ describe('R.unless - curried', () => {
|
|
|
16208
16046
|
|
|
16209
16047
|
### unnest
|
|
16210
16048
|
|
|
16049
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.unnest(%5B1%2C%20%5B2%5D%2C%20%5B%5B3%5D%5D%5D)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%2C%20%5B3%5D%5D">Try this <strong>R.unnest</strong> example in Rambda REPL</a>
|
|
16050
|
+
|
|
16211
16051
|
[](#unnest)
|
|
16212
16052
|
|
|
16213
16053
|
### unwind
|
|
@@ -16366,7 +16206,6 @@ import { type } from './type.js'
|
|
|
16366
16206
|
|
|
16367
16207
|
export function values(obj){
|
|
16368
16208
|
if (type(obj) !== 'Object') return []
|
|
16369
|
-
|
|
16370
16209
|
return Object.values(obj)
|
|
16371
16210
|
}
|
|
16372
16211
|
```
|
|
@@ -16430,7 +16269,7 @@ describe('R.values', () => {
|
|
|
16430
16269
|
|
|
16431
16270
|
```typescript
|
|
16432
16271
|
|
|
16433
|
-
view<
|
|
16272
|
+
view<S, A>(lens: Lens<S, A>): (obj: S) => A
|
|
16434
16273
|
```
|
|
16435
16274
|
|
|
16436
16275
|
It returns the value of `lens` focus over `target` object.
|
|
@@ -16442,8 +16281,8 @@ It returns the value of `lens` focus over `target` object.
|
|
|
16442
16281
|
<summary>All TypeScript definitions</summary>
|
|
16443
16282
|
|
|
16444
16283
|
```typescript
|
|
16445
|
-
view<
|
|
16446
|
-
view<
|
|
16284
|
+
view<S, A>(lens: Lens<S, A>): (obj: S) => A;
|
|
16285
|
+
view<S, A>(lens: Lens<S, A>, obj: S): A;
|
|
16447
16286
|
```
|
|
16448
16287
|
|
|
16449
16288
|
</details>
|
|
@@ -16487,35 +16326,6 @@ test('happy', () => {
|
|
|
16487
16326
|
|
|
16488
16327
|
</details>
|
|
16489
16328
|
|
|
16490
|
-
<details>
|
|
16491
|
-
|
|
16492
|
-
<summary><strong>TypeScript</strong> test</summary>
|
|
16493
|
-
|
|
16494
|
-
```typescript
|
|
16495
|
-
import {lens, view, assoc} from 'rambda'
|
|
16496
|
-
|
|
16497
|
-
interface Input {
|
|
16498
|
-
foo: string,
|
|
16499
|
-
}
|
|
16500
|
-
|
|
16501
|
-
const testObject: Input = {
|
|
16502
|
-
foo: 'Led Zeppelin',
|
|
16503
|
-
}
|
|
16504
|
-
|
|
16505
|
-
const fooLens = lens<Input, string, string>((x: Input) => {
|
|
16506
|
-
return x.foo
|
|
16507
|
-
}, assoc('foo'))
|
|
16508
|
-
|
|
16509
|
-
describe('R.view', () => {
|
|
16510
|
-
it('happt', () => {
|
|
16511
|
-
const result = view<Input, string>(fooLens, testObject)
|
|
16512
|
-
result // $ExpectType string
|
|
16513
|
-
})
|
|
16514
|
-
})
|
|
16515
|
-
```
|
|
16516
|
-
|
|
16517
|
-
</details>
|
|
16518
|
-
|
|
16519
16329
|
[](#view)
|
|
16520
16330
|
|
|
16521
16331
|
### when
|
|
@@ -16525,6 +16335,11 @@ describe('R.view', () => {
|
|
|
16525
16335
|
when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T | U
|
|
16526
16336
|
```
|
|
16527
16337
|
|
|
16338
|
+
It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
|
|
16339
|
+
If the `predicate` returns `false`, then it will simply return `input`.
|
|
16340
|
+
|
|
16341
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20predicate%20%3D%20x%20%3D%3E%20typeof%20x%20%3D%3D%3D%20'number'%0Aconst%20whenTrueFn%20%3D%20R.add(11)%0A%0Aconst%20fn%20%3D%20when(predicate%2C%20whenTrueResult)%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(positiveInput)%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%2099%2C%0A%20%20'foo'%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>
|
|
16342
|
+
|
|
16528
16343
|
<details>
|
|
16529
16344
|
|
|
16530
16345
|
<summary>All TypeScript definitions</summary>
|
|
@@ -17427,6 +17242,20 @@ describe('R.zipWith', () => {
|
|
|
17427
17242
|
|
|
17428
17243
|
## ❯ CHANGELOG
|
|
17429
17244
|
|
|
17245
|
+
9.0.0
|
|
17246
|
+
|
|
17247
|
+
Breaking change in TS definitions of `lenses` as now they are synced to `Ramda` types.
|
|
17248
|
+
|
|
17249
|
+
- Add `R.sortWith` - [Issue #707](https://github.com/selfrefactor/rambda/issues/707)
|
|
17250
|
+
|
|
17251
|
+
- Add `R.innerJoin`, `R.gt`, `R.gte`, `R.reduceBy`, `R.hasIn`
|
|
17252
|
+
|
|
17253
|
+
8.6.0
|
|
17254
|
+
|
|
17255
|
+
- Wrong typing for `R.dissocPath` - [Issue #709](https://github.com/selfrefactor/rambda/issues/709)
|
|
17256
|
+
|
|
17257
|
+
- Update build dependencies
|
|
17258
|
+
|
|
17430
17259
|
8.5.0
|
|
17431
17260
|
|
|
17432
17261
|
- Revert changes in `R.anyPass` introduced in `8.4.0` release. The reason is that the change was breaking the library older than `5.2.0` TypeScript.
|
|
@@ -17773,25 +17602,25 @@ Fix wrong versions in changelog
|
|
|
17773
17602
|
|
|
17774
17603
|
> Most influential contributors(in alphabetical order)
|
|
17775
17604
|
|
|
17776
|
-
- [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;
|
|
17605
|
+
-  [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;
|
|
17777
17606
|
|
|
17778
|
-
- [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;
|
|
17607
|
+
-  [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;
|
|
17779
17608
|
|
|
17780
|
-
- [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation
|
|
17609
|
+
-  [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation
|
|
17781
17610
|
|
|
17782
|
-
- [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;
|
|
17611
|
+
-  [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;
|
|
17783
17612
|
|
|
17784
|
-
- [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;
|
|
17613
|
+
-  [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;
|
|
17785
17614
|
|
|
17786
|
-
- [@ku8ar](https://github.com/ku8ar) - add R.slice, R.propOr, R.identical, R.propIs and several math related methods; introduce the idea to display missing Ramda methods;
|
|
17615
|
+
-  [@ku8ar](https://github.com/ku8ar) - add R.slice, R.propOr, R.identical, R.propIs and several math related methods; introduce the idea to display missing Ramda methods;
|
|
17787
17616
|
|
|
17788
|
-
- [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;
|
|
17617
|
+
-  [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;
|
|
17789
17618
|
|
|
17790
|
-
- [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;
|
|
17619
|
+
-  [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;
|
|
17791
17620
|
|
|
17792
|
-
- [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;
|
|
17621
|
+
-  [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;
|
|
17793
17622
|
|
|
17794
|
-
- [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;
|
|
17623
|
+
-  [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;
|
|
17795
17624
|
|
|
17796
17625
|
> Rambda references
|
|
17797
17626
|
|
|
@@ -17803,20 +17632,16 @@ Fix wrong versions in changelog
|
|
|
17803
17632
|
|
|
17804
17633
|
> Links to Rambda
|
|
17805
17634
|
|
|
17806
|
-
- [https://mailchi.mp/webtoolsweekly/web-tools-280](Web Tools Weekly)
|
|
17807
|
-
|
|
17808
17635
|
- [https://github.com/stoeffel/awesome-fp-js](awesome-fp-js)
|
|
17809
17636
|
|
|
17637
|
+
- [ https://mailchi.mp/webtoolsweekly/web-tools-280 ]( Web Tools Weekly #280 )
|
|
17638
|
+
|
|
17810
17639
|
- [https://github.com/docsifyjs/awesome-docsify](awesome-docsify)
|
|
17811
17640
|
|
|
17812
17641
|
> Deprecated from `Used by` section
|
|
17813
17642
|
|
|
17814
17643
|
- [SAP's Cloud SDK](https://github.com/SAP/cloud-sdk) - This repo doesn't uses `Rambda` since *October/2020* [commit that removes Rambda](https://github.com/SAP/cloud-sdk/commit/b29b4f915c4e4e9c2441e7b6b67cf83dac1fdac3)
|
|
17815
17644
|
|
|
17816
|
-
> Releases
|
|
17817
|
-
|
|
17818
|
-
[Rambda's releases](https://github.com/selfrefactor/rambda/releases) before **6.4.0** were used mostly for testing purposes.
|
|
17819
|
-
|
|
17820
17645
|
[](#-additional-info)
|
|
17821
17646
|
|
|
17822
17647
|
## My other libraries
|