rambda 10.2.0 → 10.3.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 +125 -10
- package/README.md +892 -259
- package/dist/rambda.cjs +106 -41
- package/dist/rambda.js +102 -42
- package/dist/rambda.umd.js +106 -41
- package/index.d.cts +62 -44
- package/index.d.ts +62 -44
- package/package.json +8 -8
- package/rambda.js +5 -0
- package/src/duplicateBy.js +9 -0
- package/src/filterAsync.js +14 -0
- package/src/indexBy.js +14 -0
- package/src/mapAsync.js +2 -2
- package/src/mapPropObject.js +10 -0
- package/src/replaceAll.js +10 -0
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Rambda
|
|
2
2
|
|
|
3
|
-
`Rambda` is TypeScript-focused utility library similar to `Remeda`, `Ramda` and `Radashi`.
|
|
4
|
-
|
|
5
|
-
Initially it started as faster alternative to functional programming library `Ramda`, but in order to address many TypeScript issues, now `Rambda` takes a separate path. - [Documentation](https://selfrefactor.github.io/rambda/#/)
|
|
3
|
+
`Rambda` is TypeScript-focused utility library similar to `Remeda`, `Ramda` and `Radashi`. - [Documentation site](https://selfrefactor.github.io/rambda/#/)
|
|
6
4
|
|
|
7
5
|

|
|
8
6
|

|
|
@@ -13,17 +11,17 @@ Initially it started as faster alternative to functional programming library `Ra
|
|
|
13
11
|
## ❯ Example use
|
|
14
12
|
|
|
15
13
|
```javascript
|
|
16
|
-
import { pipe,
|
|
14
|
+
import { pipe, filter, map } from 'rambda'
|
|
17
15
|
|
|
18
16
|
const result = pipe(
|
|
19
|
-
|
|
17
|
+
[1, 2, 3, 4],
|
|
20
18
|
filter(x => x > 2),
|
|
21
19
|
map(x => x * 2),
|
|
22
20
|
)
|
|
23
|
-
|
|
21
|
+
//=> [6, 8]
|
|
24
22
|
```
|
|
25
23
|
|
|
26
|
-
You can test this example in <a href="https://rambda.now.sh
|
|
24
|
+
You can test this example in <a href="https://rambda.now.sh/?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>
|
|
27
25
|
|
|
28
26
|
* [API](#api)
|
|
29
27
|
* [Changelog](#-changelog)
|
|
@@ -78,6 +76,8 @@ it('within Ramda.pipe requires explicit types', () => {
|
|
|
78
76
|
});
|
|
79
77
|
```
|
|
80
78
|
|
|
79
|
+
IMPORTANT - all methods are tested to deliver correct types when they are part of `R.pipe/R.pipeAsync` chains. Using them outside(standalone) most likely will result in `unknown` type for inputs.
|
|
80
|
+
|
|
81
81
|
### Keep only the most useful methods
|
|
82
82
|
|
|
83
83
|
The idea is to give `TypeScript` users only the most useful methods and let them implement the rest. No magic logic methods that are hard to remember. You shouldn't need to read the documentation to understand what a method does. Its name and signature should be enough.
|
|
@@ -130,38 +130,13 @@ R.pick('a,b', {a: 1 , b: 2, c: 3} })
|
|
|
130
130
|
// No space allowed between properties
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
### Fast performance compared to Ramda
|
|
134
|
-
|
|
135
|
-
Since `Rambda` methods doesn't use so many internals, it is faster than `Ramda`.
|
|
136
|
-
Prior to version `10`, benchmark summary was included, but now the main selling point is the TypeScript focus, not performance so this is no longer included.
|
|
137
|
-
|
|
138
133
|
### Differences between Rambda and Ramda
|
|
139
134
|
|
|
140
135
|
Up until version `9.4.2`, the aim of Rambda was to match as much as possible the Ramda API.
|
|
141
136
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
From version `10.0.0` onwards, Rambda will start to diverge from Ramda in order to address some of the issues that Ramda has.
|
|
145
|
-
|
|
146
|
-
Currently, `Rambda` includes 32 methods that differ from `Ramda` and shares 83 methods with it.
|
|
147
|
-
|
|
148
|
-
<details>
|
|
149
|
-
<summary>
|
|
150
|
-
Ramda issues
|
|
151
|
-
</summary>
|
|
152
|
-
|
|
153
|
-
-- Typescript support - this is the main reason for the divergence. Most of design decisions in Rambda are made with Typescript in mind.
|
|
154
|
-
|
|
155
|
-
-- Methods that imply side-effect, which is not FP oriented, e.g. `R.forEach`.
|
|
156
|
-
|
|
157
|
-
-- Naming of methods that doesn't match developer's expectation, such as `R.chain`, which should be called `flatMap`.
|
|
137
|
+
You can find documentation site of **Rambda** version **9.4.2** is [here](https://selfrefactor.github.io/rambda-v9/).
|
|
158
138
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
-- Methods that are already present in standard JavaScript, such as `R.toLower`, `R.length`.
|
|
162
|
-
|
|
163
|
-
-- `R.compose` doesn't have the best possible TypeScript support.
|
|
164
|
-
</details>
|
|
139
|
+
From version `10.0.0` onwards, **Rambda** is no longer aiming to be drop-in replacement for *Ramda*.
|
|
165
140
|
|
|
166
141
|
[](#-rambdas-features)
|
|
167
142
|
|
|
@@ -181,13 +156,13 @@ It adds new key-value pair to the object.
|
|
|
181
156
|
|
|
182
157
|
```javascript
|
|
183
158
|
const result = R.pipe(
|
|
184
|
-
{ a: 1, b: 'foo' },
|
|
159
|
+
{ a: 1, b: 'foo' },
|
|
185
160
|
R.addProp('c', 3)
|
|
186
161
|
)
|
|
187
162
|
// => { a: 1, b: 'foo', c: 3 }
|
|
188
163
|
```
|
|
189
164
|
|
|
190
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.pipe(%0A%09%7B%20a%3A%201%2C%20b%3A%20'foo'%20%7D%2C%
|
|
165
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
191
166
|
|
|
192
167
|
<details>
|
|
193
168
|
|
|
@@ -264,7 +239,7 @@ addPropToObjects<
|
|
|
264
239
|
): (list: T[]) => MergeTypes<T & { [P in K]: R }>[]
|
|
265
240
|
```
|
|
266
241
|
|
|
267
|
-
It receives list of objects and add new property to each item.
|
|
242
|
+
It receives list of objects and add new property to each item.
|
|
268
243
|
|
|
269
244
|
The value is based on result of `fn` function, which receives the current object as argument.
|
|
270
245
|
|
|
@@ -591,11 +566,11 @@ It returns `true`, if at least one member of `list` returns true, when passed to
|
|
|
591
566
|
```javascript
|
|
592
567
|
const list = [1, 2, 3]
|
|
593
568
|
const predicate = x => x * x > 8
|
|
594
|
-
R.any(
|
|
569
|
+
R.any(predicate)(list)
|
|
595
570
|
// => true
|
|
596
571
|
```
|
|
597
572
|
|
|
598
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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(
|
|
573
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
599
574
|
|
|
600
575
|
<details>
|
|
601
576
|
|
|
@@ -688,11 +663,11 @@ const fn = R.anyPass(
|
|
|
688
663
|
[isBig, isOdd]
|
|
689
664
|
)
|
|
690
665
|
|
|
691
|
-
const result = fn(input)
|
|
666
|
+
const result = fn(input)
|
|
692
667
|
// => true
|
|
693
668
|
```
|
|
694
669
|
|
|
695
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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)%
|
|
670
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
696
671
|
|
|
697
672
|
<details>
|
|
698
673
|
|
|
@@ -1138,11 +1113,11 @@ const input = {
|
|
|
1138
1113
|
c : 11,
|
|
1139
1114
|
}
|
|
1140
1115
|
|
|
1141
|
-
const result = condition(input)
|
|
1116
|
+
const result = condition(input)
|
|
1142
1117
|
// => true
|
|
1143
1118
|
```
|
|
1144
1119
|
|
|
1145
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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)%
|
|
1120
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
1146
1121
|
|
|
1147
1122
|
<details>
|
|
1148
1123
|
|
|
@@ -2386,6 +2361,76 @@ describe('R.dropWhile', () => {
|
|
|
2386
2361
|
|
|
2387
2362
|
[](#dropWhile)
|
|
2388
2363
|
|
|
2364
|
+
### duplicateBy
|
|
2365
|
+
|
|
2366
|
+
```typescript
|
|
2367
|
+
|
|
2368
|
+
duplicateBy<T, U>(fn: (x: T) => U): (list: T[]) => T[]
|
|
2369
|
+
```
|
|
2370
|
+
|
|
2371
|
+
```javascript
|
|
2372
|
+
const list = [{a:1}, {a:2}, {a:1}]
|
|
2373
|
+
const result = R.duplicateBy(x => x, list)
|
|
2374
|
+
|
|
2375
|
+
// => [{a:1}]
|
|
2376
|
+
```
|
|
2377
|
+
|
|
2378
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
2379
|
+
|
|
2380
|
+
<details>
|
|
2381
|
+
|
|
2382
|
+
<summary>All TypeScript definitions</summary>
|
|
2383
|
+
|
|
2384
|
+
```typescript
|
|
2385
|
+
duplicateBy<T, U>(fn: (x: T) => U): (list: T[]) => T[];
|
|
2386
|
+
```
|
|
2387
|
+
|
|
2388
|
+
</details>
|
|
2389
|
+
|
|
2390
|
+
<details>
|
|
2391
|
+
|
|
2392
|
+
<summary><strong>R.duplicateBy</strong> source</summary>
|
|
2393
|
+
|
|
2394
|
+
```javascript
|
|
2395
|
+
import { _Set } from '../src/_internals/set.js'
|
|
2396
|
+
|
|
2397
|
+
export function duplicateBy(fn) {
|
|
2398
|
+
return list => {
|
|
2399
|
+
const set = new _Set()
|
|
2400
|
+
|
|
2401
|
+
return list.filter(item => !set.checkUniqueness(fn(item)))
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
```
|
|
2405
|
+
|
|
2406
|
+
</details>
|
|
2407
|
+
|
|
2408
|
+
<details>
|
|
2409
|
+
|
|
2410
|
+
<summary><strong>Tests</strong></summary>
|
|
2411
|
+
|
|
2412
|
+
```javascript
|
|
2413
|
+
import { duplicateBy } from './duplicateBy.js'
|
|
2414
|
+
|
|
2415
|
+
test('happy', () => {
|
|
2416
|
+
expect(duplicateBy(Math.abs)([-2, -1, 0, 1, 2])).toEqual([1,2])
|
|
2417
|
+
})
|
|
2418
|
+
|
|
2419
|
+
test('returns an empty array for an empty array', () => {
|
|
2420
|
+
expect(duplicateBy(Math.abs)([])).toEqual([])
|
|
2421
|
+
})
|
|
2422
|
+
|
|
2423
|
+
test('uses R.uniq', () => {
|
|
2424
|
+
const list = [{ a: 1 }, { a: 2 }, { a: 1 }]
|
|
2425
|
+
const expected = [{ a: 1 }]
|
|
2426
|
+
expect(duplicateBy(x => x)(list)).toEqual(expected)
|
|
2427
|
+
})
|
|
2428
|
+
```
|
|
2429
|
+
|
|
2430
|
+
</details>
|
|
2431
|
+
|
|
2432
|
+
[](#duplicateBy)
|
|
2433
|
+
|
|
2389
2434
|
### eqBy
|
|
2390
2435
|
|
|
2391
2436
|
```typescript
|
|
@@ -3050,7 +3095,7 @@ const input = {
|
|
|
3050
3095
|
baz: 'baz',
|
|
3051
3096
|
}
|
|
3052
3097
|
const result = R.pipe(
|
|
3053
|
-
input,
|
|
3098
|
+
input,
|
|
3054
3099
|
evolve({
|
|
3055
3100
|
foo: x => x + 1,
|
|
3056
3101
|
})
|
|
@@ -3058,7 +3103,7 @@ const result = R.pipe(
|
|
|
3058
3103
|
// => result is { foo: 3, baz: 'baz' }
|
|
3059
3104
|
```
|
|
3060
3105
|
|
|
3061
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%
|
|
3106
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%09evolve(%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>
|
|
3062
3107
|
|
|
3063
3108
|
<details>
|
|
3064
3109
|
|
|
@@ -3323,6 +3368,10 @@ test('happy', () => {
|
|
|
3323
3368
|
|
|
3324
3369
|
expect(filter(isEven)([1, 2, 3, 4])).toEqual([2, 4])
|
|
3325
3370
|
})
|
|
3371
|
+
|
|
3372
|
+
test('using Boolean', () => {
|
|
3373
|
+
expect(filter(Boolean)([null, 0, 1, 2])).toEqual([1,2])
|
|
3374
|
+
})
|
|
3326
3375
|
```
|
|
3327
3376
|
|
|
3328
3377
|
</details>
|
|
@@ -3332,7 +3381,7 @@ test('happy', () => {
|
|
|
3332
3381
|
<summary><strong>TypeScript</strong> test</summary>
|
|
3333
3382
|
|
|
3334
3383
|
```typescript
|
|
3335
|
-
import { filter,
|
|
3384
|
+
import { filter, pipe } from 'rambda'
|
|
3336
3385
|
|
|
3337
3386
|
const list = [1, 2, 3]
|
|
3338
3387
|
|
|
@@ -3406,6 +3455,93 @@ describe('R.filter with array', () => {
|
|
|
3406
3455
|
|
|
3407
3456
|
[](#filter)
|
|
3408
3457
|
|
|
3458
|
+
### filterAsync
|
|
3459
|
+
|
|
3460
|
+
```typescript
|
|
3461
|
+
|
|
3462
|
+
filterAsync<T>(
|
|
3463
|
+
predicate: (value: T) => Promise<boolean>,
|
|
3464
|
+
): (list: T[]) => Promise<T[]>
|
|
3465
|
+
```
|
|
3466
|
+
|
|
3467
|
+
<details>
|
|
3468
|
+
|
|
3469
|
+
<summary>All TypeScript definitions</summary>
|
|
3470
|
+
|
|
3471
|
+
```typescript
|
|
3472
|
+
filterAsync<T>(
|
|
3473
|
+
predicate: (value: T) => Promise<boolean>,
|
|
3474
|
+
): (list: T[]) => Promise<T[]>;
|
|
3475
|
+
```
|
|
3476
|
+
|
|
3477
|
+
</details>
|
|
3478
|
+
|
|
3479
|
+
<details>
|
|
3480
|
+
|
|
3481
|
+
<summary><strong>R.filterAsync</strong> source</summary>
|
|
3482
|
+
|
|
3483
|
+
```javascript
|
|
3484
|
+
export function filterAsync(predicate) {
|
|
3485
|
+
return async list => {
|
|
3486
|
+
const willReturn = []
|
|
3487
|
+
let index = 0
|
|
3488
|
+
for (const x of list) {
|
|
3489
|
+
if (await predicate(x, index)) {
|
|
3490
|
+
willReturn.push(list[index])
|
|
3491
|
+
}
|
|
3492
|
+
index++
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
return willReturn
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
```
|
|
3499
|
+
|
|
3500
|
+
</details>
|
|
3501
|
+
|
|
3502
|
+
<details>
|
|
3503
|
+
|
|
3504
|
+
<summary><strong>Tests</strong></summary>
|
|
3505
|
+
|
|
3506
|
+
```javascript
|
|
3507
|
+
import { filterAsync } from './filterAsync.js'
|
|
3508
|
+
|
|
3509
|
+
test('happy', async () => {
|
|
3510
|
+
const isEven = async n => n % 2 === 0
|
|
3511
|
+
|
|
3512
|
+
expect(await filterAsync(isEven)([1, 2, 3, 4])).toEqual([2, 4])
|
|
3513
|
+
})
|
|
3514
|
+
```
|
|
3515
|
+
|
|
3516
|
+
</details>
|
|
3517
|
+
|
|
3518
|
+
<details>
|
|
3519
|
+
|
|
3520
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
3521
|
+
|
|
3522
|
+
```typescript
|
|
3523
|
+
import { filterAsync, pipeAsync } from 'rambda'
|
|
3524
|
+
|
|
3525
|
+
const list = [1, 2, 3]
|
|
3526
|
+
|
|
3527
|
+
describe('R.filter with array', () => {
|
|
3528
|
+
it('within pipe', async () => {
|
|
3529
|
+
const result = await pipeAsync(
|
|
3530
|
+
list,
|
|
3531
|
+
filterAsync(async x => {
|
|
3532
|
+
x // $ExpectType number
|
|
3533
|
+
return x > 1
|
|
3534
|
+
}),
|
|
3535
|
+
)
|
|
3536
|
+
result // $ExpectType number[]
|
|
3537
|
+
})
|
|
3538
|
+
})
|
|
3539
|
+
```
|
|
3540
|
+
|
|
3541
|
+
</details>
|
|
3542
|
+
|
|
3543
|
+
[](#filterAsync)
|
|
3544
|
+
|
|
3409
3545
|
### filterObject
|
|
3410
3546
|
|
|
3411
3547
|
```typescript
|
|
@@ -4070,15 +4206,15 @@ You must pass expected output type as a type argument.
|
|
|
4070
4206
|
|
|
4071
4207
|
```javascript
|
|
4072
4208
|
const result = R.flatten<number>([
|
|
4073
|
-
1,
|
|
4074
|
-
2,
|
|
4075
|
-
[3, 30, [300]],
|
|
4209
|
+
1,
|
|
4210
|
+
2,
|
|
4211
|
+
[3, 30, [300]],
|
|
4076
4212
|
[4]
|
|
4077
4213
|
])
|
|
4078
4214
|
// => [ 1, 2, 3, 30, 300, 4 ]
|
|
4079
4215
|
```
|
|
4080
4216
|
|
|
4081
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.flatten%3Cnumber%3E(%5B%0A%20%201%2C%
|
|
4217
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
4082
4218
|
|
|
4083
4219
|
<details>
|
|
4084
4220
|
|
|
@@ -4497,13 +4633,13 @@ describe('R.groupBy', () => {
|
|
|
4497
4633
|
|
|
4498
4634
|
```typescript
|
|
4499
4635
|
|
|
4500
|
-
head<T>(listOrString: T): T extends string ? string :
|
|
4501
|
-
T extends [] ? undefined:
|
|
4502
|
-
T extends readonly [infer F, ...infer R] ? F :
|
|
4636
|
+
head<T>(listOrString: T): T extends string ? string :
|
|
4637
|
+
T extends [] ? undefined:
|
|
4638
|
+
T extends readonly [infer F, ...infer R] ? F :
|
|
4503
4639
|
T extends readonly [infer F] ? F :
|
|
4504
4640
|
T extends [infer F] ? F :
|
|
4505
|
-
T extends [infer F, ...infer R] ? F :
|
|
4506
|
-
T extends unknown[] ? T[number] :
|
|
4641
|
+
T extends [infer F, ...infer R] ? F :
|
|
4642
|
+
T extends unknown[] ? T[number] :
|
|
4507
4643
|
undefined
|
|
4508
4644
|
```
|
|
4509
4645
|
|
|
@@ -4512,25 +4648,25 @@ It returns the first element of list or string `input`. It returns `undefined` i
|
|
|
4512
4648
|
```javascript
|
|
4513
4649
|
const result = [
|
|
4514
4650
|
R.head([1, 2, 3]),
|
|
4515
|
-
R.head('foo')
|
|
4651
|
+
R.head('foo')
|
|
4516
4652
|
]
|
|
4517
4653
|
// => [1, 'f']
|
|
4518
4654
|
```
|
|
4519
4655
|
|
|
4520
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.head(%5B1%2C%202%2C%203%5D)%2C%0A%20%20R.head('foo')%
|
|
4656
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
4521
4657
|
|
|
4522
4658
|
<details>
|
|
4523
4659
|
|
|
4524
4660
|
<summary>All TypeScript definitions</summary>
|
|
4525
4661
|
|
|
4526
4662
|
```typescript
|
|
4527
|
-
head<T>(listOrString: T): T extends string ? string :
|
|
4528
|
-
T extends [] ? undefined:
|
|
4529
|
-
T extends readonly [infer F, ...infer R] ? F :
|
|
4663
|
+
head<T>(listOrString: T): T extends string ? string :
|
|
4664
|
+
T extends [] ? undefined:
|
|
4665
|
+
T extends readonly [infer F, ...infer R] ? F :
|
|
4530
4666
|
T extends readonly [infer F] ? F :
|
|
4531
4667
|
T extends [infer F] ? F :
|
|
4532
|
-
T extends [infer F, ...infer R] ? F :
|
|
4533
|
-
T extends unknown[] ? T[number] :
|
|
4668
|
+
T extends [infer F, ...infer R] ? F :
|
|
4669
|
+
T extends unknown[] ? T[number] :
|
|
4534
4670
|
undefined;
|
|
4535
4671
|
```
|
|
4536
4672
|
|
|
@@ -4744,6 +4880,109 @@ describe('R.includes', () => {
|
|
|
4744
4880
|
|
|
4745
4881
|
[](#includes)
|
|
4746
4882
|
|
|
4883
|
+
### indexBy
|
|
4884
|
+
|
|
4885
|
+
```typescript
|
|
4886
|
+
|
|
4887
|
+
indexBy<T, K extends keyof T>(
|
|
4888
|
+
property: K
|
|
4889
|
+
): (list: readonly T[]) => Record<string, T>
|
|
4890
|
+
```
|
|
4891
|
+
|
|
4892
|
+
It transforms list of objects to object using specified property as the base for the returned object.
|
|
4893
|
+
|
|
4894
|
+
```javascript
|
|
4895
|
+
const result = R.indexBy(
|
|
4896
|
+
'id'
|
|
4897
|
+
)([{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}])
|
|
4898
|
+
// => {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
|
|
4899
|
+
```
|
|
4900
|
+
|
|
4901
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
4902
|
+
|
|
4903
|
+
<details>
|
|
4904
|
+
|
|
4905
|
+
<summary>All TypeScript definitions</summary>
|
|
4906
|
+
|
|
4907
|
+
```typescript
|
|
4908
|
+
indexBy<T, K extends keyof T>(
|
|
4909
|
+
property: K
|
|
4910
|
+
): (list: readonly T[]) => Record<string, T>;
|
|
4911
|
+
indexBy<T, K extends keyof T>(
|
|
4912
|
+
property: K
|
|
4913
|
+
): (list: T[]) => Record<string, T>;
|
|
4914
|
+
|
|
4915
|
+
// API_MARKER_END
|
|
4916
|
+
// ============================================
|
|
4917
|
+
```
|
|
4918
|
+
|
|
4919
|
+
</details>
|
|
4920
|
+
|
|
4921
|
+
<details>
|
|
4922
|
+
|
|
4923
|
+
<summary><strong>R.indexBy</strong> source</summary>
|
|
4924
|
+
|
|
4925
|
+
```javascript
|
|
4926
|
+
export function indexBy(property){
|
|
4927
|
+
return list => {
|
|
4928
|
+
const toReturn = {}
|
|
4929
|
+
for (let i = 0; i < list.length; i++){
|
|
4930
|
+
const item = list[ i ]
|
|
4931
|
+
const key = item[property]
|
|
4932
|
+
if(key !== undefined){
|
|
4933
|
+
toReturn[ key ] = item
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4937
|
+
return toReturn
|
|
4938
|
+
}
|
|
4939
|
+
}
|
|
4940
|
+
```
|
|
4941
|
+
|
|
4942
|
+
</details>
|
|
4943
|
+
|
|
4944
|
+
<details>
|
|
4945
|
+
|
|
4946
|
+
<summary><strong>Tests</strong></summary>
|
|
4947
|
+
|
|
4948
|
+
```javascript
|
|
4949
|
+
import { indexBy } from './indexBy.js'
|
|
4950
|
+
|
|
4951
|
+
test('happy', () => {
|
|
4952
|
+
const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]
|
|
4953
|
+
|
|
4954
|
+
expect(
|
|
4955
|
+
indexBy('id')(list)
|
|
4956
|
+
).toEqual(
|
|
4957
|
+
{abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
|
|
4958
|
+
)
|
|
4959
|
+
})
|
|
4960
|
+
```
|
|
4961
|
+
|
|
4962
|
+
</details>
|
|
4963
|
+
|
|
4964
|
+
<details>
|
|
4965
|
+
|
|
4966
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4967
|
+
|
|
4968
|
+
```typescript
|
|
4969
|
+
import { pipe, indexBy } from 'rambda'
|
|
4970
|
+
|
|
4971
|
+
it('R.indexBy', () => {
|
|
4972
|
+
const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]
|
|
4973
|
+
const result = pipe(
|
|
4974
|
+
list,
|
|
4975
|
+
indexBy('id')
|
|
4976
|
+
)
|
|
4977
|
+
result.abc // $ExpectType { id: string; title: string; }
|
|
4978
|
+
result.foo // $ExpectType { id: string; title: string; }
|
|
4979
|
+
})
|
|
4980
|
+
```
|
|
4981
|
+
|
|
4982
|
+
</details>
|
|
4983
|
+
|
|
4984
|
+
[](#indexBy)
|
|
4985
|
+
|
|
4747
4986
|
### indexOf
|
|
4748
4987
|
|
|
4749
4988
|
```typescript
|
|
@@ -4802,18 +5041,18 @@ test('will throw with bad input', () => {
|
|
|
4802
5041
|
expect(() => indexOf([])(true)).toThrow()
|
|
4803
5042
|
})
|
|
4804
5043
|
|
|
4805
|
-
test('
|
|
5044
|
+
test('with numbers', () => {
|
|
4806
5045
|
expect(indexOf(3)([1, 2, 3, 4])).toBe(2)
|
|
4807
5046
|
expect(indexOf(10)([1, 2, 3, 4])).toBe(-1)
|
|
4808
5047
|
})
|
|
4809
5048
|
|
|
4810
|
-
test('list of objects
|
|
5049
|
+
test('list of objects use R.equals', () => {
|
|
4811
5050
|
const listOfObjects = [{ a: 1 }, { b: 2 }, { c: 3 }]
|
|
4812
5051
|
expect(indexOf({ c: 4 })(listOfObjects)).toBe(-1)
|
|
4813
5052
|
expect(indexOf({ c: 3 })(listOfObjects)).toBe(2)
|
|
4814
5053
|
})
|
|
4815
5054
|
|
|
4816
|
-
test('list of arrays
|
|
5055
|
+
test('list of arrays use R.equals', () => {
|
|
4817
5056
|
const listOfLists = [[1], [2, 3], [2, 3, 4], [2, 3], [1], []]
|
|
4818
5057
|
expect(indexOf([])(listOfLists)).toBe(5)
|
|
4819
5058
|
expect(indexOf([1])(listOfLists)).toBe(0)
|
|
@@ -4855,13 +5094,13 @@ It returns all but the last element of list or string `input`.
|
|
|
4855
5094
|
|
|
4856
5095
|
```javascript
|
|
4857
5096
|
const result = [
|
|
4858
|
-
R.init([1, 2, 3]) ,
|
|
5097
|
+
R.init([1, 2, 3]) ,
|
|
4859
5098
|
R.init('foo') // => 'fo'
|
|
4860
5099
|
]
|
|
4861
5100
|
// => [[1, 2], 'fo']
|
|
4862
5101
|
```
|
|
4863
5102
|
|
|
4864
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.init(%5B1%2C%202%2C%203%5D)%20%2C%
|
|
5103
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
4865
5104
|
|
|
4866
5105
|
<details>
|
|
4867
5106
|
|
|
@@ -5097,9 +5336,6 @@ const expected = 'foo is BAR even 1 more'
|
|
|
5097
5336
|
|
|
5098
5337
|
```typescript
|
|
5099
5338
|
interpolate(inputWithTags: string): (templateArguments: object) => string;
|
|
5100
|
-
|
|
5101
|
-
// API_MARKER_END
|
|
5102
|
-
// ===========================================
|
|
5103
5339
|
```
|
|
5104
5340
|
|
|
5105
5341
|
</details>
|
|
@@ -5436,13 +5672,13 @@ it('R.join', () => {
|
|
|
5436
5672
|
|
|
5437
5673
|
```typescript
|
|
5438
5674
|
|
|
5439
|
-
last<T>(listOrString: T): T extends string ? string :
|
|
5440
|
-
T extends [] ? undefined :
|
|
5441
|
-
T extends readonly [...infer R, infer L] ? L :
|
|
5675
|
+
last<T>(listOrString: T): T extends string ? string :
|
|
5676
|
+
T extends [] ? undefined :
|
|
5677
|
+
T extends readonly [...infer R, infer L] ? L :
|
|
5442
5678
|
T extends readonly [infer L] ? L :
|
|
5443
5679
|
T extends [infer L] ? L :
|
|
5444
|
-
T extends [...infer R, infer L] ? L :
|
|
5445
|
-
T extends unknown[] ? T[number] :
|
|
5680
|
+
T extends [...infer R, infer L] ? L :
|
|
5681
|
+
T extends unknown[] ? T[number] :
|
|
5446
5682
|
undefined
|
|
5447
5683
|
```
|
|
5448
5684
|
|
|
@@ -5463,13 +5699,13 @@ const result = [
|
|
|
5463
5699
|
<summary>All TypeScript definitions</summary>
|
|
5464
5700
|
|
|
5465
5701
|
```typescript
|
|
5466
|
-
last<T>(listOrString: T): T extends string ? string :
|
|
5467
|
-
T extends [] ? undefined :
|
|
5468
|
-
T extends readonly [...infer R, infer L] ? L :
|
|
5702
|
+
last<T>(listOrString: T): T extends string ? string :
|
|
5703
|
+
T extends [] ? undefined :
|
|
5704
|
+
T extends readonly [...infer R, infer L] ? L :
|
|
5469
5705
|
T extends readonly [infer L] ? L :
|
|
5470
5706
|
T extends [infer L] ? L :
|
|
5471
|
-
T extends [...infer R, infer L] ? L :
|
|
5472
|
-
T extends unknown[] ? T[number] :
|
|
5707
|
+
T extends [...infer R, infer L] ? L :
|
|
5708
|
+
T extends unknown[] ? T[number] :
|
|
5473
5709
|
undefined;
|
|
5474
5710
|
```
|
|
5475
5711
|
|
|
@@ -5766,16 +6002,6 @@ mapAsync<T extends IterableContainer, U>(
|
|
|
5766
6002
|
mapAsync<T extends IterableContainer, U>(
|
|
5767
6003
|
fn: (value: T[number]) => Promise<U>,
|
|
5768
6004
|
): (data: T) => Promise<Mapped<T, U>>;
|
|
5769
|
-
mapAsync<T extends IterableContainer, U>(
|
|
5770
|
-
fn: (value: T[number], index: number) => Promise<U>,
|
|
5771
|
-
data: T
|
|
5772
|
-
): Promise<Mapped<T, U>>;
|
|
5773
|
-
mapAsync<T extends IterableContainer, U>(
|
|
5774
|
-
fn: (value: T[number]) => Promise<U>,
|
|
5775
|
-
data: T
|
|
5776
|
-
): Promise<Mapped<T, U>>;
|
|
5777
|
-
...
|
|
5778
|
-
...
|
|
5779
6005
|
```
|
|
5780
6006
|
|
|
5781
6007
|
</details>
|
|
@@ -5789,8 +6015,8 @@ export function mapAsync(fn) {
|
|
|
5789
6015
|
return async list => {
|
|
5790
6016
|
const willReturn = []
|
|
5791
6017
|
let i = 0
|
|
5792
|
-
for (const
|
|
5793
|
-
willReturn.push(await fn(
|
|
6018
|
+
for (const x of list) {
|
|
6019
|
+
willReturn.push(await fn(x, i++))
|
|
5794
6020
|
}
|
|
5795
6021
|
|
|
5796
6022
|
return willReturn
|
|
@@ -5861,14 +6087,12 @@ test('error', async () => {
|
|
|
5861
6087
|
<summary><strong>TypeScript</strong> test</summary>
|
|
5862
6088
|
|
|
5863
6089
|
```typescript
|
|
5864
|
-
import { mapAsync, pipeAsync } from 'rambda'
|
|
5865
|
-
import { delay } from 'rambdax'
|
|
6090
|
+
import { mapAsync, pipeAsync, map } from 'rambda'
|
|
5866
6091
|
|
|
5867
6092
|
const list = ['a', 'bc', 'def']
|
|
6093
|
+
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
|
|
5868
6094
|
|
|
5869
6095
|
it('R.mapAsync', async () => {
|
|
5870
|
-
const fn = async (x:unknown) => x as number + 1
|
|
5871
|
-
|
|
5872
6096
|
const result = await pipeAsync(
|
|
5873
6097
|
list,
|
|
5874
6098
|
mapAsync(async x => {
|
|
@@ -5877,7 +6101,7 @@ it('R.mapAsync', async () => {
|
|
|
5877
6101
|
return x.length % 2 ? x.length + 1 : x.length + 10
|
|
5878
6102
|
}),
|
|
5879
6103
|
x => x,
|
|
5880
|
-
|
|
6104
|
+
map(x => x +1),
|
|
5881
6105
|
mapAsync(async x => {
|
|
5882
6106
|
await delay(100)
|
|
5883
6107
|
return x + 1
|
|
@@ -6080,7 +6304,18 @@ describe('R.mapObject', () => {
|
|
|
6080
6304
|
|
|
6081
6305
|
result // $ExpectType { a: string; }
|
|
6082
6306
|
})
|
|
6083
|
-
it('iterable with
|
|
6307
|
+
it('iterable with one arguments', () => {
|
|
6308
|
+
const result = pipe(
|
|
6309
|
+
{ a: [1,2,3], b: 'foo' },
|
|
6310
|
+
mapObject(a => {
|
|
6311
|
+
a // $ExpectType string | number[]
|
|
6312
|
+
return typeof a as string
|
|
6313
|
+
}),
|
|
6314
|
+
)
|
|
6315
|
+
|
|
6316
|
+
result // $ExpectType { a: string; b: string; }
|
|
6317
|
+
})
|
|
6318
|
+
it('iterable with two arguments', () => {
|
|
6084
6319
|
const result = pipe(
|
|
6085
6320
|
{ a: 1, b: 'foo' },
|
|
6086
6321
|
mapObject((a, b) => {
|
|
@@ -6242,16 +6477,6 @@ mapParallelAsync<T extends IterableContainer, U>(
|
|
|
6242
6477
|
mapParallelAsync<T extends IterableContainer, U>(
|
|
6243
6478
|
fn: (value: T[number]) => Promise<U>,
|
|
6244
6479
|
): (data: T) => Promise<Mapped<T, U>>;
|
|
6245
|
-
mapParallelAsync<T extends IterableContainer, U>(
|
|
6246
|
-
fn: (value: T[number], index: number) => Promise<U>,
|
|
6247
|
-
data: T
|
|
6248
|
-
): Promise<Mapped<T, U>>;
|
|
6249
|
-
mapParallelAsync<T extends IterableContainer, U>(
|
|
6250
|
-
fn: (value: T[number]) => Promise<U>,
|
|
6251
|
-
data: T
|
|
6252
|
-
): Promise<Mapped<T, U>>;
|
|
6253
|
-
...
|
|
6254
|
-
...
|
|
6255
6480
|
```
|
|
6256
6481
|
|
|
6257
6482
|
</details>
|
|
@@ -6304,46 +6529,173 @@ test('pipeAsync', async () => {
|
|
|
6304
6529
|
|
|
6305
6530
|
[](#mapParallelAsync)
|
|
6306
6531
|
|
|
6307
|
-
###
|
|
6532
|
+
### mapPropObject
|
|
6308
6533
|
|
|
6309
6534
|
```typescript
|
|
6310
6535
|
|
|
6311
|
-
|
|
6536
|
+
mapPropObject<T extends object, K extends keyof T, Value>(
|
|
6537
|
+
valueMapper: (
|
|
6538
|
+
value: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
6539
|
+
data: T[K],
|
|
6540
|
+
) => Value,
|
|
6541
|
+
prop: K,
|
|
6542
|
+
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
6543
|
+
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
6544
|
+
: never
|
|
6312
6545
|
```
|
|
6313
6546
|
|
|
6314
|
-
|
|
6547
|
+
It maps over a property of object that is a list.
|
|
6315
6548
|
|
|
6316
6549
|
```javascript
|
|
6317
|
-
const result =
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6550
|
+
const result = pipe(
|
|
6551
|
+
{ a: [1,2,3], b: 'foo' },
|
|
6552
|
+
mapPropObject(x => {
|
|
6553
|
+
x // $ExpectType { a: number; b: string; }
|
|
6554
|
+
return {
|
|
6555
|
+
a: x,
|
|
6556
|
+
flag: x > 2,
|
|
6557
|
+
}
|
|
6558
|
+
}, 'a'),
|
|
6559
|
+
)
|
|
6560
|
+
// => { a: [{ a: 1, flag: false },{ a: 2, flag: false }, { a: 3, flag: true }], b: 'foo' }
|
|
6322
6561
|
```
|
|
6323
6562
|
|
|
6324
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%
|
|
6563
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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(x%20%3D%3E%20%7B%0A%09%09x%20%2F%2F%20%24ExpectType%20%7B%20a%3A%20number%3B%20b%3A%20string%3B%20%7D%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%20'a')%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>
|
|
6325
6564
|
|
|
6326
6565
|
<details>
|
|
6327
6566
|
|
|
6328
6567
|
<summary>All TypeScript definitions</summary>
|
|
6329
6568
|
|
|
6330
6569
|
```typescript
|
|
6331
|
-
|
|
6570
|
+
mapPropObject<T extends object, K extends keyof T, Value>(
|
|
6571
|
+
valueMapper: (
|
|
6572
|
+
value: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
6573
|
+
data: T[K],
|
|
6574
|
+
) => Value,
|
|
6575
|
+
prop: K,
|
|
6576
|
+
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
6577
|
+
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
6578
|
+
: never;
|
|
6332
6579
|
```
|
|
6333
6580
|
|
|
6334
6581
|
</details>
|
|
6335
6582
|
|
|
6336
6583
|
<details>
|
|
6337
6584
|
|
|
6338
|
-
<summary><strong>R.
|
|
6585
|
+
<summary><strong>R.mapPropObject</strong> source</summary>
|
|
6339
6586
|
|
|
6340
6587
|
```javascript
|
|
6341
|
-
export function
|
|
6342
|
-
return
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6588
|
+
export function mapPropObject(fn, prop) {
|
|
6589
|
+
return obj => {
|
|
6590
|
+
if (!Array.isArray(obj[prop])) return obj
|
|
6591
|
+
|
|
6592
|
+
return {
|
|
6593
|
+
...obj,
|
|
6594
|
+
[prop]: obj[prop].map(fn)
|
|
6595
|
+
}
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
```
|
|
6599
|
+
|
|
6600
|
+
</details>
|
|
6601
|
+
|
|
6602
|
+
<details>
|
|
6603
|
+
|
|
6604
|
+
<summary><strong>Tests</strong></summary>
|
|
6605
|
+
|
|
6606
|
+
```javascript
|
|
6607
|
+
import { mapPropObject } from './mapPropObject.js'
|
|
6608
|
+
import { pipe } from './pipe.js'
|
|
6609
|
+
|
|
6610
|
+
it('happy', () => {
|
|
6611
|
+
const result = pipe(
|
|
6612
|
+
{ a: [1, 2, 3], b: 'foo' },
|
|
6613
|
+
mapPropObject(x => ({ a: x, flag: x > 2 }), 'a'),
|
|
6614
|
+
)
|
|
6615
|
+
|
|
6616
|
+
expect(result).toEqual({
|
|
6617
|
+
a: [
|
|
6618
|
+
{ a: 1, flag: false },
|
|
6619
|
+
{ a: 2, flag: false },
|
|
6620
|
+
{ a: 3, flag: true },
|
|
6621
|
+
],
|
|
6622
|
+
b: 'foo',
|
|
6623
|
+
})
|
|
6624
|
+
})
|
|
6625
|
+
```
|
|
6626
|
+
|
|
6627
|
+
</details>
|
|
6628
|
+
|
|
6629
|
+
<details>
|
|
6630
|
+
|
|
6631
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6632
|
+
|
|
6633
|
+
```typescript
|
|
6634
|
+
import { mapPropObject, pipe } from 'rambda'
|
|
6635
|
+
|
|
6636
|
+
describe('R.mapPropObject', () => {
|
|
6637
|
+
it('iterable with one arguments', () => {
|
|
6638
|
+
const result = pipe(
|
|
6639
|
+
{ a: [1,2,3], b: 'foo' },
|
|
6640
|
+
mapPropObject(x => {
|
|
6641
|
+
x // $ExpectType number
|
|
6642
|
+
return {
|
|
6643
|
+
a: x,
|
|
6644
|
+
flag: x > 2,
|
|
6645
|
+
}
|
|
6646
|
+
}, 'a'),
|
|
6647
|
+
)
|
|
6648
|
+
|
|
6649
|
+
result.a // $ExpectType { a: number; flag: boolean; }[]
|
|
6650
|
+
result.b // $ExpectType string
|
|
6651
|
+
})
|
|
6652
|
+
})
|
|
6653
|
+
```
|
|
6654
|
+
|
|
6655
|
+
</details>
|
|
6656
|
+
|
|
6657
|
+
[](#mapPropObject)
|
|
6658
|
+
|
|
6659
|
+
### match
|
|
6660
|
+
|
|
6661
|
+
```typescript
|
|
6662
|
+
|
|
6663
|
+
match(regExpression: RegExp): (str: string) => string[]
|
|
6664
|
+
```
|
|
6665
|
+
|
|
6666
|
+
Curried version of `String.prototype.match` which returns empty array, when there is no match.
|
|
6667
|
+
|
|
6668
|
+
```javascript
|
|
6669
|
+
const result = [
|
|
6670
|
+
R.match('a', 'foo'),
|
|
6671
|
+
R.match(/([a-z]a)/g, 'bananas')
|
|
6672
|
+
]
|
|
6673
|
+
// => [[], ['ba', 'na', 'na']]
|
|
6674
|
+
```
|
|
6675
|
+
|
|
6676
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
6677
|
+
|
|
6678
|
+
<details>
|
|
6679
|
+
|
|
6680
|
+
<summary>All TypeScript definitions</summary>
|
|
6681
|
+
|
|
6682
|
+
```typescript
|
|
6683
|
+
match(regExpression: RegExp): (str: string) => string[];
|
|
6684
|
+
```
|
|
6685
|
+
|
|
6686
|
+
</details>
|
|
6687
|
+
|
|
6688
|
+
<details>
|
|
6689
|
+
|
|
6690
|
+
<summary><strong>R.match</strong> source</summary>
|
|
6691
|
+
|
|
6692
|
+
```javascript
|
|
6693
|
+
export function match(pattern) {
|
|
6694
|
+
return input => {
|
|
6695
|
+
const willReturn = input.match(pattern)
|
|
6696
|
+
|
|
6697
|
+
return willReturn === null ? [] : willReturn
|
|
6698
|
+
}
|
|
6347
6699
|
}
|
|
6348
6700
|
```
|
|
6349
6701
|
|
|
@@ -6643,11 +6995,11 @@ It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
|
|
|
6643
6995
|
```javascript
|
|
6644
6996
|
const result = R.pipe(
|
|
6645
6997
|
[1, 2, 3],
|
|
6646
|
-
R.modifyItemAtIndex(1,
|
|
6998
|
+
R.modifyItemAtIndex(1, x => x + 1)
|
|
6647
6999
|
) // => [1, 3, 3]
|
|
6648
7000
|
```
|
|
6649
7001
|
|
|
6650
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.pipe(%0A%09%5B1%2C%202%2C%203%5D%2C%0A%09R.modifyItemAtIndex(1%2C%
|
|
7002
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
6651
7003
|
|
|
6652
7004
|
<details>
|
|
6653
7005
|
|
|
@@ -6860,11 +7212,11 @@ const person = {
|
|
|
6860
7212
|
name : 'foo',
|
|
6861
7213
|
age : 20,
|
|
6862
7214
|
}
|
|
6863
|
-
const result = R.modifyProp('age', x => x + 1)(person)
|
|
7215
|
+
const result = R.modifyProp('age', x => x + 1)(person)
|
|
6864
7216
|
// => {name: 'foo', age: 21}
|
|
6865
7217
|
```
|
|
6866
7218
|
|
|
6867
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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)%
|
|
7219
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
6868
7220
|
|
|
6869
7221
|
<details>
|
|
6870
7222
|
|
|
@@ -7287,13 +7639,13 @@ const propsToOmit = 'a,c,d'
|
|
|
7287
7639
|
const propsToOmitList = ['a', 'c', 'd']
|
|
7288
7640
|
|
|
7289
7641
|
const result = [
|
|
7290
|
-
R.omit(propsToOmit, obj),
|
|
7291
|
-
R.omit(propsToOmitList, obj)
|
|
7642
|
+
R.omit(propsToOmit, obj),
|
|
7643
|
+
R.omit(propsToOmitList, obj)
|
|
7292
7644
|
]
|
|
7293
7645
|
// => [{b: 2}, {b: 2}]
|
|
7294
7646
|
```
|
|
7295
7647
|
|
|
7296
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%
|
|
7648
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
7297
7649
|
|
|
7298
7650
|
<details>
|
|
7299
7651
|
|
|
@@ -8370,8 +8722,8 @@ test('happy', () => {
|
|
|
8370
8722
|
```typescript
|
|
8371
8723
|
import {
|
|
8372
8724
|
type MergeTypes,
|
|
8373
|
-
allPass,
|
|
8374
8725
|
append,
|
|
8726
|
+
assertType,
|
|
8375
8727
|
defaultTo,
|
|
8376
8728
|
drop,
|
|
8377
8729
|
dropLast,
|
|
@@ -8380,12 +8732,9 @@ import {
|
|
|
8380
8732
|
find,
|
|
8381
8733
|
head,
|
|
8382
8734
|
map,
|
|
8383
|
-
mapObject,
|
|
8384
|
-
path,
|
|
8385
8735
|
pick,
|
|
8386
8736
|
pipe,
|
|
8387
8737
|
split,
|
|
8388
|
-
tap,
|
|
8389
8738
|
union,
|
|
8390
8739
|
} from 'rambda'
|
|
8391
8740
|
type IsNotNever<T> = [T] extends [never] ? false : true
|
|
@@ -8404,12 +8753,6 @@ interface Book extends BaseBook {
|
|
|
8404
8753
|
}
|
|
8405
8754
|
status?: Status
|
|
8406
8755
|
}
|
|
8407
|
-
interface MustReadBook extends Book {
|
|
8408
|
-
status: 'must-read'
|
|
8409
|
-
}
|
|
8410
|
-
interface FamousBook extends Book {
|
|
8411
|
-
status: 'famous'
|
|
8412
|
-
}
|
|
8413
8756
|
interface BookWithBookmarkStatus extends Book {
|
|
8414
8757
|
bookmarkFlag: boolean
|
|
8415
8758
|
}
|
|
@@ -8417,14 +8760,13 @@ interface BookWithReadStatus extends Book {
|
|
|
8417
8760
|
readFlag: boolean
|
|
8418
8761
|
}
|
|
8419
8762
|
type BookToRead = BookWithBookmarkStatus & BookWithReadStatus
|
|
8420
|
-
|
|
8421
|
-
|
|
8763
|
+
type FamousBook = Book & {
|
|
8764
|
+
status: 'famous'
|
|
8422
8765
|
}
|
|
8423
|
-
interface BookWithUserRating extends Book {
|
|
8424
|
-
userRating: number
|
|
8425
|
-
}
|
|
8426
|
-
type BookWithDetails = BookWithDescription & BookWithUserRating
|
|
8427
8766
|
|
|
8767
|
+
const checkIfFamous = (x: Book): x is FamousBook => {
|
|
8768
|
+
return x.status === 'famous'
|
|
8769
|
+
}
|
|
8428
8770
|
const zaratustra: BaseBook = {
|
|
8429
8771
|
title: 'Zaratustra',
|
|
8430
8772
|
year: 1956,
|
|
@@ -8448,11 +8790,6 @@ const awardedBrothersKaramazov: Book = {
|
|
|
8448
8790
|
years: [1869, 1870],
|
|
8449
8791
|
},
|
|
8450
8792
|
}
|
|
8451
|
-
const awardedBrothersKaramazovToRead: BookToRead = {
|
|
8452
|
-
...awardedBrothersKaramazov,
|
|
8453
|
-
readFlag: true,
|
|
8454
|
-
bookmarkFlag: true,
|
|
8455
|
-
}
|
|
8456
8793
|
const awardedZaratustraToRead: BookToRead = {
|
|
8457
8794
|
...awardedZaratustra,
|
|
8458
8795
|
readFlag: true,
|
|
@@ -8469,40 +8806,9 @@ const awardedBaseValue: Book = {
|
|
|
8469
8806
|
|
|
8470
8807
|
type Status = 'famous' | 'can be skipped' | 'must-read'
|
|
8471
8808
|
|
|
8472
|
-
function checkIfMustRead(x: Book): x is MustReadBook {
|
|
8473
|
-
return (x as MustReadBook).status === 'must-read'
|
|
8474
|
-
}
|
|
8475
|
-
function checkIfFamous(x: Book): x is FamousBook {
|
|
8476
|
-
return (x as FamousBook).status === 'famous'
|
|
8477
|
-
}
|
|
8478
|
-
function checkReadStatus(x: Book): x is BookWithReadStatus {
|
|
8479
|
-
return (x as BookWithReadStatus).readFlag
|
|
8480
|
-
}
|
|
8481
|
-
function checkBookmarkStatus(x: Book): x is BookWithBookmarkStatus {
|
|
8482
|
-
return (x as BookWithBookmarkStatus).bookmarkFlag
|
|
8483
|
-
}
|
|
8484
8809
|
function checkBookToRead(x: Book): x is BookToRead {
|
|
8485
8810
|
return (x as BookToRead).readFlag && (x as BookToRead).bookmarkFlag
|
|
8486
8811
|
}
|
|
8487
|
-
function checkHasDescription(x: Book): x is BookWithDescription {
|
|
8488
|
-
return (x as BookWithDescription).description !== undefined
|
|
8489
|
-
}
|
|
8490
|
-
function checkHasUserRating(x: Book): x is BookWithUserRating {
|
|
8491
|
-
return (x as BookWithUserRating).userRating !== undefined
|
|
8492
|
-
}
|
|
8493
|
-
|
|
8494
|
-
function assertType<T, U extends T>(fn: (x: T) => x is U) {
|
|
8495
|
-
return (x: T) => {
|
|
8496
|
-
if (fn(x)) {
|
|
8497
|
-
return x
|
|
8498
|
-
}
|
|
8499
|
-
throw new Error('type assertion failed')
|
|
8500
|
-
}
|
|
8501
|
-
}
|
|
8502
|
-
function convertToType<T>() {
|
|
8503
|
-
return <U>(x: U) => x as unknown as T
|
|
8504
|
-
}
|
|
8505
|
-
// const convertToType = <T>(x: unknown)=> x as unknown as T
|
|
8506
8812
|
|
|
8507
8813
|
function tapFn<T, U>(
|
|
8508
8814
|
transformFn: (x: T) => U,
|
|
@@ -8552,17 +8858,10 @@ describe('real use cases - books', () => {
|
|
|
8552
8858
|
evolve({
|
|
8553
8859
|
year: x => x + 1,
|
|
8554
8860
|
}),
|
|
8555
|
-
// convertToType<BookWithDescription>(),
|
|
8556
|
-
// dissocPath<Book>('description'),
|
|
8557
|
-
// convertToType<Record<string, string>>(),
|
|
8558
|
-
// mapObject((x) => {
|
|
8559
|
-
// return x as unknown as number;
|
|
8560
|
-
// }),
|
|
8561
8861
|
simplify,
|
|
8562
8862
|
pick('year'),
|
|
8563
8863
|
)
|
|
8564
8864
|
const result = getResult(zaratustra)
|
|
8565
|
-
type Foo = MergeTypes<typeof result>
|
|
8566
8865
|
const final: Expect<IsNotNever<typeof result>> = true
|
|
8567
8866
|
})
|
|
8568
8867
|
it('case 3', () => {
|
|
@@ -8615,7 +8914,7 @@ const result = await R.pipeAsync(
|
|
|
8615
8914
|
await R.delay(100)
|
|
8616
8915
|
return x + 2
|
|
8617
8916
|
},
|
|
8618
|
-
|
|
8917
|
+
x => x +2,
|
|
8619
8918
|
async x => {
|
|
8620
8919
|
const delayed = await R.delay(100)
|
|
8621
8920
|
return delayed + x
|
|
@@ -8624,7 +8923,7 @@ const result = await R.pipeAsync(
|
|
|
8624
8923
|
// `result` resolves to `RAMBDAX_DELAY104`
|
|
8625
8924
|
```
|
|
8626
8925
|
|
|
8627
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%
|
|
8926
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
8628
8927
|
|
|
8629
8928
|
<details>
|
|
8630
8929
|
|
|
@@ -8736,11 +9035,11 @@ Basically, this is `R.map(R.prop(property))`.
|
|
|
8736
9035
|
const list = [{a: 1}, {a: 2}, {b: 3}]
|
|
8737
9036
|
const property = 'a'
|
|
8738
9037
|
|
|
8739
|
-
const result = R.pluck(property)(list)
|
|
9038
|
+
const result = R.pluck(property)(list)
|
|
8740
9039
|
// => [1, 2]
|
|
8741
9040
|
```
|
|
8742
9041
|
|
|
8743
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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)%
|
|
9042
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
8744
9043
|
|
|
8745
9044
|
<details>
|
|
8746
9045
|
|
|
@@ -8748,6 +9047,12 @@ const result = R.pluck(property)(list)
|
|
|
8748
9047
|
|
|
8749
9048
|
```typescript
|
|
8750
9049
|
pluck<T, K extends keyof T>(property: K): (list: T[]) => T[K][];
|
|
9050
|
+
pluck<K extends PropertyKey>(prop: K): {
|
|
9051
|
+
<U extends O[keyof O], UK extends keyof U, O extends Record<string, any>>(obj: K extends UK ? O : never): { [OK in keyof O]: O[OK][K] };
|
|
9052
|
+
<U extends readonly unknown[] | Record<K, any>>(list: readonly U[]): U extends readonly (infer T)[] ? T[] : U extends Record<K, infer T> ? T[] : never;
|
|
9053
|
+
};
|
|
9054
|
+
...
|
|
9055
|
+
...
|
|
8751
9056
|
```
|
|
8752
9057
|
|
|
8753
9058
|
</details>
|
|
@@ -8797,16 +9102,29 @@ test('with undefined', () => {
|
|
|
8797
9102
|
<summary><strong>TypeScript</strong> test</summary>
|
|
8798
9103
|
|
|
8799
9104
|
```typescript
|
|
8800
|
-
import { pipe, pluck } from
|
|
9105
|
+
import { pipe, pluck } from "rambda";
|
|
8801
9106
|
|
|
8802
|
-
it(
|
|
9107
|
+
it("R.pluck", () => {
|
|
8803
9108
|
const input = [
|
|
8804
|
-
{ a: 1, b:
|
|
8805
|
-
{ a: 2, b:
|
|
8806
|
-
]
|
|
8807
|
-
const result = pipe(input, pluck(
|
|
8808
|
-
result // $ExpectType string[]
|
|
8809
|
-
})
|
|
9109
|
+
{ a: 1, b: "foo" },
|
|
9110
|
+
{ a: 2, b: "bar" },
|
|
9111
|
+
];
|
|
9112
|
+
const result = pipe(input, pluck("b"));
|
|
9113
|
+
result; // $ExpectType string[]
|
|
9114
|
+
});
|
|
9115
|
+
|
|
9116
|
+
it("R.pluck without R.pipe", () => {
|
|
9117
|
+
interface Content {
|
|
9118
|
+
text: string;
|
|
9119
|
+
}
|
|
9120
|
+
const content: Content[] = [
|
|
9121
|
+
{
|
|
9122
|
+
text: "foo",
|
|
9123
|
+
},
|
|
9124
|
+
];
|
|
9125
|
+
const sentences = pluck("text")(content);
|
|
9126
|
+
sentences; // $ExpectType string[]
|
|
9127
|
+
});
|
|
8810
9128
|
```
|
|
8811
9129
|
|
|
8812
9130
|
</details>
|
|
@@ -8885,13 +9203,13 @@ If there is no such property, it returns `undefined`.
|
|
|
8885
9203
|
|
|
8886
9204
|
```javascript
|
|
8887
9205
|
const result = [
|
|
8888
|
-
R.prop('x')({x: 100}),
|
|
8889
|
-
R.prop('x')({a: 1})
|
|
9206
|
+
R.prop('x')({x: 100}),
|
|
9207
|
+
R.prop('x')({a: 1})
|
|
8890
9208
|
]
|
|
8891
9209
|
// => [100, undefined]
|
|
8892
9210
|
```
|
|
8893
9211
|
|
|
8894
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.prop('x')(%7Bx%3A%20100%7D)%2C%
|
|
9212
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
8895
9213
|
|
|
8896
9214
|
<details>
|
|
8897
9215
|
|
|
@@ -9789,6 +10107,98 @@ describe('R.replace', () => {
|
|
|
9789
10107
|
|
|
9790
10108
|
[](#replace)
|
|
9791
10109
|
|
|
10110
|
+
### replaceAll
|
|
10111
|
+
|
|
10112
|
+
```typescript
|
|
10113
|
+
|
|
10114
|
+
replaceAll(patterns: (RegExp | string)[], replacer: string): (input: string) => string
|
|
10115
|
+
```
|
|
10116
|
+
|
|
10117
|
+
Same as `R.replace` but it accepts array of string and regular expressions instead of a single value.
|
|
10118
|
+
|
|
10119
|
+
```javascript
|
|
10120
|
+
const result = [
|
|
10121
|
+
R.replaceAll(['o', /a/g], '|1|')('foa'),
|
|
10122
|
+
]
|
|
10123
|
+
// => 'f|1||1|'
|
|
10124
|
+
```
|
|
10125
|
+
|
|
10126
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10127
|
+
|
|
10128
|
+
<details>
|
|
10129
|
+
|
|
10130
|
+
<summary>All TypeScript definitions</summary>
|
|
10131
|
+
|
|
10132
|
+
```typescript
|
|
10133
|
+
replaceAll(patterns: (RegExp | string)[], replacer: string): (input: string) => string;
|
|
10134
|
+
```
|
|
10135
|
+
|
|
10136
|
+
</details>
|
|
10137
|
+
|
|
10138
|
+
<details>
|
|
10139
|
+
|
|
10140
|
+
<summary><strong>R.replaceAll</strong> source</summary>
|
|
10141
|
+
|
|
10142
|
+
```javascript
|
|
10143
|
+
export function replaceAll(patterns, replacer) {
|
|
10144
|
+
return input => {
|
|
10145
|
+
let text = input
|
|
10146
|
+
patterns.forEach(singlePattern => {
|
|
10147
|
+
text = text.replace(singlePattern, replacer)
|
|
10148
|
+
})
|
|
10149
|
+
|
|
10150
|
+
return text
|
|
10151
|
+
}
|
|
10152
|
+
}
|
|
10153
|
+
```
|
|
10154
|
+
|
|
10155
|
+
</details>
|
|
10156
|
+
|
|
10157
|
+
<details>
|
|
10158
|
+
|
|
10159
|
+
<summary><strong>Tests</strong></summary>
|
|
10160
|
+
|
|
10161
|
+
```javascript
|
|
10162
|
+
import { replaceAll } from './replaceAll.js'
|
|
10163
|
+
|
|
10164
|
+
const replacer = '|'
|
|
10165
|
+
const patterns = [/foo/g, 'bar']
|
|
10166
|
+
const input = 'foo bar baz foo bar'
|
|
10167
|
+
|
|
10168
|
+
test('happy', () => {
|
|
10169
|
+
const result = replaceAll(patterns, replacer)(input)
|
|
10170
|
+
const expected = '| | baz | bar'
|
|
10171
|
+
|
|
10172
|
+
expect(result).toEqual(expected)
|
|
10173
|
+
})
|
|
10174
|
+
```
|
|
10175
|
+
|
|
10176
|
+
</details>
|
|
10177
|
+
|
|
10178
|
+
<details>
|
|
10179
|
+
|
|
10180
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10181
|
+
|
|
10182
|
+
```typescript
|
|
10183
|
+
import { pipe, replaceAll } from 'rambda'
|
|
10184
|
+
|
|
10185
|
+
const str = 'foo bar foo'
|
|
10186
|
+
const replacer = 'bar'
|
|
10187
|
+
const patterns = [/foo/g, 'bar']
|
|
10188
|
+
|
|
10189
|
+
describe('R.replaceAll', () => {
|
|
10190
|
+
it('happy', () => {
|
|
10191
|
+
const result = pipe(str, replaceAll(patterns, replacer))
|
|
10192
|
+
|
|
10193
|
+
result // $ExpectType string
|
|
10194
|
+
})
|
|
10195
|
+
})
|
|
10196
|
+
```
|
|
10197
|
+
|
|
10198
|
+
</details>
|
|
10199
|
+
|
|
10200
|
+
[](#replaceAll)
|
|
10201
|
+
|
|
9792
10202
|
### shuffle
|
|
9793
10203
|
|
|
9794
10204
|
```typescript
|
|
@@ -10100,6 +10510,25 @@ describe('R.sortBy', () => {
|
|
|
10100
10510
|
sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[]
|
|
10101
10511
|
```
|
|
10102
10512
|
|
|
10513
|
+
```javascript
|
|
10514
|
+
const list = [
|
|
10515
|
+
{a: 2},
|
|
10516
|
+
{a: 3},
|
|
10517
|
+
{a: 1}
|
|
10518
|
+
]
|
|
10519
|
+
const sortFn = x => x.a
|
|
10520
|
+
|
|
10521
|
+
const result = R.sortByDescending(sortFn)(list)
|
|
10522
|
+
const expected = [
|
|
10523
|
+
{a: 3},
|
|
10524
|
+
{a: 2},
|
|
10525
|
+
{a: 1}
|
|
10526
|
+
]
|
|
10527
|
+
// => `result` is equal to `expected`
|
|
10528
|
+
```
|
|
10529
|
+
|
|
10530
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10531
|
+
|
|
10103
10532
|
<details>
|
|
10104
10533
|
|
|
10105
10534
|
<summary>All TypeScript definitions</summary>
|
|
@@ -10137,6 +10566,23 @@ sortByPath<S, K0 extends string & keyof S>(
|
|
|
10137
10566
|
|
|
10138
10567
|
It sorts `list` by the value of `path` property.
|
|
10139
10568
|
|
|
10569
|
+
```javascript
|
|
10570
|
+
const list = [
|
|
10571
|
+
{a: {b: 2}, id:1},
|
|
10572
|
+
{a: {b: 1}, id:2},
|
|
10573
|
+
{a: {b: 3}, id:3},
|
|
10574
|
+
]
|
|
10575
|
+
const result = R.sortByPath('a.b')(list)
|
|
10576
|
+
const expected = [
|
|
10577
|
+
{a: {b: 1}, id:2},
|
|
10578
|
+
{a: {b: 2}, id:1},
|
|
10579
|
+
{a: {b: 3}, id:3}
|
|
10580
|
+
]
|
|
10581
|
+
// => `result` is equal to `expected`
|
|
10582
|
+
```
|
|
10583
|
+
|
|
10584
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10585
|
+
|
|
10140
10586
|
<details>
|
|
10141
10587
|
|
|
10142
10588
|
<summary>All TypeScript definitions</summary>
|
|
@@ -10241,6 +10687,23 @@ sortByPathDescending<S, K0 extends string & keyof S>(
|
|
|
10241
10687
|
): (list: S[]) => S[]
|
|
10242
10688
|
```
|
|
10243
10689
|
|
|
10690
|
+
```javascript
|
|
10691
|
+
const list = [
|
|
10692
|
+
{a: {b: 2}, id:1},
|
|
10693
|
+
{a: {b: 1}, id:2},
|
|
10694
|
+
{a: {b: 3}, id:3},
|
|
10695
|
+
]
|
|
10696
|
+
const result = R.sortByPathDescending('a.b')(list)
|
|
10697
|
+
const expected = [
|
|
10698
|
+
{a: {b: 3}, id:3}
|
|
10699
|
+
{a: {b: 2}, id:1},
|
|
10700
|
+
{a: {b: 1}, id:2},
|
|
10701
|
+
]
|
|
10702
|
+
// => `result` is equal to `expected`
|
|
10703
|
+
```
|
|
10704
|
+
|
|
10705
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10706
|
+
|
|
10244
10707
|
<details>
|
|
10245
10708
|
|
|
10246
10709
|
<summary>All TypeScript definitions</summary>
|
|
@@ -10314,11 +10777,11 @@ It returns a sorted version of `input` object.
|
|
|
10314
10777
|
```javascript
|
|
10315
10778
|
const predicate = (propA, propB, valueA, valueB) => valueA > valueB ? -1 : 1
|
|
10316
10779
|
|
|
10317
|
-
const result = R.sortObject(predicate
|
|
10780
|
+
const result = R.sortObject(predicate)({a:1, b: 4, c: 2})
|
|
10318
10781
|
// => {b: 4, c: 2, a: 1}
|
|
10319
10782
|
```
|
|
10320
10783
|
|
|
10321
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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%
|
|
10784
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10322
10785
|
|
|
10323
10786
|
<details>
|
|
10324
10787
|
|
|
@@ -10679,8 +11142,8 @@ It splits `input` into slices of `sliceLength`.
|
|
|
10679
11142
|
|
|
10680
11143
|
```javascript
|
|
10681
11144
|
const result = [
|
|
10682
|
-
R.splitEvery(2
|
|
10683
|
-
R.splitEvery(3
|
|
11145
|
+
R.splitEvery(2)([1, 2, 3]),
|
|
11146
|
+
R.splitEvery(3)('foobar')
|
|
10684
11147
|
]
|
|
10685
11148
|
|
|
10686
11149
|
const expected = [
|
|
@@ -10690,7 +11153,7 @@ const expected = [
|
|
|
10690
11153
|
// => `result` is equal to `expected`
|
|
10691
11154
|
```
|
|
10692
11155
|
|
|
10693
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.splitEvery(2%
|
|
11156
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10694
11157
|
|
|
10695
11158
|
<details>
|
|
10696
11159
|
|
|
@@ -10777,11 +11240,11 @@ It returns a merged list of `x` and `y` with all equal elements removed.
|
|
|
10777
11240
|
const x = [ 1, 2, 3, 4 ]
|
|
10778
11241
|
const y = [ 3, 4, 5, 6 ]
|
|
10779
11242
|
|
|
10780
|
-
const result = R.symmetricDifference(x
|
|
11243
|
+
const result = R.symmetricDifference(x)(y)
|
|
10781
11244
|
// => [ 1, 2, 5, 6 ]
|
|
10782
11245
|
```
|
|
10783
11246
|
|
|
10784
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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
|
|
11247
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10785
11248
|
|
|
10786
11249
|
<details>
|
|
10787
11250
|
|
|
@@ -10872,13 +11335,13 @@ It returns all but the first element of `input`.
|
|
|
10872
11335
|
|
|
10873
11336
|
```javascript
|
|
10874
11337
|
const result = [
|
|
10875
|
-
R.tail([1, 2, 3]),
|
|
10876
|
-
R.tail('foo')
|
|
11338
|
+
R.tail([1, 2, 3]),
|
|
11339
|
+
R.tail('foo')
|
|
10877
11340
|
]
|
|
10878
11341
|
// => [[2, 3], 'oo']
|
|
10879
11342
|
```
|
|
10880
11343
|
|
|
10881
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.tail(%5B1%2C%202%2C%203%5D)%2C%
|
|
11344
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
10882
11345
|
|
|
10883
11346
|
<details>
|
|
10884
11347
|
|
|
@@ -11341,23 +11804,23 @@ it('R.takeWhile', () => {
|
|
|
11341
11804
|
tap<T>(fn: (x: T) => void): (input: T) => T
|
|
11342
11805
|
```
|
|
11343
11806
|
|
|
11344
|
-
It applies function `fn` to input `x` and returns `x`.
|
|
11807
|
+
It applies function `fn` to input `x` and returns `x`.
|
|
11345
11808
|
|
|
11346
11809
|
One use case is debugging in the middle of `R.pipe` chain.
|
|
11347
11810
|
|
|
11348
11811
|
```javascript
|
|
11349
11812
|
const list = [1, 2, 3]
|
|
11350
11813
|
|
|
11351
|
-
R.pipe(
|
|
11814
|
+
const result = R.pipe(
|
|
11352
11815
|
list,
|
|
11353
|
-
R.
|
|
11816
|
+
R.filter(x => x > 1),
|
|
11354
11817
|
R.tap(console.log),
|
|
11355
|
-
R.
|
|
11818
|
+
R.map(x => x * 2)
|
|
11356
11819
|
)
|
|
11357
11820
|
// => `2` and `3` will be logged
|
|
11358
11821
|
```
|
|
11359
11822
|
|
|
11360
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0A%
|
|
11823
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
11361
11824
|
|
|
11362
11825
|
<details>
|
|
11363
11826
|
|
|
@@ -11461,6 +11924,63 @@ it('R.test', () => {
|
|
|
11461
11924
|
|
|
11462
11925
|
[](#test)
|
|
11463
11926
|
|
|
11927
|
+
### transformPropObject
|
|
11928
|
+
|
|
11929
|
+
```typescript
|
|
11930
|
+
|
|
11931
|
+
transformPropObject<T extends object, K extends keyof T, Value>(
|
|
11932
|
+
valueMapper: (value: T[K]) => Value,
|
|
11933
|
+
prop: K,
|
|
11934
|
+
): (data: T) => MergeTypes<Omit<T, K> & { [P in K]: Value }>
|
|
11935
|
+
```
|
|
11936
|
+
|
|
11937
|
+
```javascript
|
|
11938
|
+
const fn = (x) => x > 2
|
|
11939
|
+
const obj = {a: 1, b: 2}
|
|
11940
|
+
|
|
11941
|
+
const result = R.transformPropObject(fn, 'a')(obj)
|
|
11942
|
+
// => {a: false, b: 2}
|
|
11943
|
+
```
|
|
11944
|
+
|
|
11945
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
11946
|
+
|
|
11947
|
+
<details>
|
|
11948
|
+
|
|
11949
|
+
<summary>All TypeScript definitions</summary>
|
|
11950
|
+
|
|
11951
|
+
```typescript
|
|
11952
|
+
transformPropObject<T extends object, K extends keyof T, Value>(
|
|
11953
|
+
valueMapper: (value: T[K]) => Value,
|
|
11954
|
+
prop: K,
|
|
11955
|
+
): (data: T) => MergeTypes<Omit<T, K> & { [P in K]: Value }>;
|
|
11956
|
+
```
|
|
11957
|
+
|
|
11958
|
+
</details>
|
|
11959
|
+
|
|
11960
|
+
<details>
|
|
11961
|
+
|
|
11962
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11963
|
+
|
|
11964
|
+
```typescript
|
|
11965
|
+
import { transformPropObject, pipe } from 'rambda'
|
|
11966
|
+
|
|
11967
|
+
it('R.transformPropObject', () => {
|
|
11968
|
+
const result = pipe(
|
|
11969
|
+
{ a: 1, b: 'foo' },
|
|
11970
|
+
transformPropObject(x => {
|
|
11971
|
+
x // $ExpectType number
|
|
11972
|
+
return x > 2
|
|
11973
|
+
}, 'a'),
|
|
11974
|
+
)
|
|
11975
|
+
|
|
11976
|
+
result // $ExpectType { b: string; a: boolean; }
|
|
11977
|
+
})
|
|
11978
|
+
```
|
|
11979
|
+
|
|
11980
|
+
</details>
|
|
11981
|
+
|
|
11982
|
+
[](#transformPropObject)
|
|
11983
|
+
|
|
11464
11984
|
### tryCatch
|
|
11465
11985
|
|
|
11466
11986
|
```typescript
|
|
@@ -11855,16 +12375,16 @@ describe('R.type', () => {
|
|
|
11855
12375
|
union<T>(x: T[]): (y: T[]) => T[]
|
|
11856
12376
|
```
|
|
11857
12377
|
|
|
11858
|
-
It takes two lists and return a new list containing a merger of both list with removed duplicates.
|
|
12378
|
+
It takes two lists and return a new list containing a merger of both list with removed duplicates.
|
|
11859
12379
|
|
|
11860
12380
|
`R.equals` is used to compare for duplication.
|
|
11861
12381
|
|
|
11862
12382
|
```javascript
|
|
11863
|
-
const result = R.union([1,2,3]
|
|
12383
|
+
const result = R.union([1,2,3])([3,4,5]);
|
|
11864
12384
|
// => [1, 2, 3, 4, 5]
|
|
11865
12385
|
```
|
|
11866
12386
|
|
|
11867
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.union(%5B1%2C2%2C3%5D%
|
|
12387
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
11868
12388
|
|
|
11869
12389
|
<details>
|
|
11870
12390
|
|
|
@@ -12075,12 +12595,12 @@ It applies uniqueness to input list based on function that defines what to be us
|
|
|
12075
12595
|
|
|
12076
12596
|
```javascript
|
|
12077
12597
|
const list = [{a:1}, {a:2}, {a:1}]
|
|
12078
|
-
const result = R.uniqBy(x => x
|
|
12598
|
+
const result = R.uniqBy(x => x)(list)
|
|
12079
12599
|
|
|
12080
12600
|
// => [{a:1}, {a:2}]
|
|
12081
12601
|
```
|
|
12082
12602
|
|
|
12083
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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
|
|
12603
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
12084
12604
|
|
|
12085
12605
|
<details>
|
|
12086
12606
|
|
|
@@ -12557,11 +13077,11 @@ const index = 2
|
|
|
12557
13077
|
const newValue = 88
|
|
12558
13078
|
const list = [1, 2, 3, 4, 5]
|
|
12559
13079
|
|
|
12560
|
-
const result = R.update(index, newValue
|
|
13080
|
+
const result = R.update(index, newValue)(list)
|
|
12561
13081
|
// => [1, 2, 88, 4, 5]
|
|
12562
13082
|
```
|
|
12563
13083
|
|
|
12564
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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
|
|
13084
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
12565
13085
|
|
|
12566
13086
|
<details>
|
|
12567
13087
|
|
|
@@ -12640,31 +13160,29 @@ test('with negative index', () => {
|
|
|
12640
13160
|
when<T, U extends T>(predicate: (x: T) => x is U, whenTrueFn: (x: U) => T): (input: T) => T
|
|
12641
13161
|
```
|
|
12642
13162
|
|
|
12643
|
-
It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
|
|
13163
|
+
It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`.
|
|
12644
13164
|
If the `predicate` returns `false`, then it will simply return `input`.
|
|
12645
13165
|
|
|
12646
13166
|
```javascript
|
|
12647
13167
|
const predicate = x => typeof x === 'number'
|
|
12648
|
-
const
|
|
12649
|
-
|
|
12650
|
-
const fn = when(predicate, whenTrueResult)
|
|
13168
|
+
const fn = R.when(predicate)(x => x + 1)
|
|
12651
13169
|
|
|
12652
13170
|
const positiveInput = 88
|
|
12653
13171
|
const negativeInput = 'foo'
|
|
12654
13172
|
|
|
12655
13173
|
const result = [
|
|
12656
13174
|
fn(positiveInput),
|
|
12657
|
-
fn(
|
|
13175
|
+
fn(negativeInput),
|
|
12658
13176
|
]
|
|
12659
13177
|
|
|
12660
13178
|
const expected = [
|
|
12661
|
-
|
|
12662
|
-
'
|
|
13179
|
+
89,
|
|
13180
|
+
'foo1',
|
|
12663
13181
|
]
|
|
12664
13182
|
// => `result` is equal to `expected`
|
|
12665
13183
|
```
|
|
12666
13184
|
|
|
12667
|
-
<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%
|
|
13185
|
+
<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%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>
|
|
12668
13186
|
|
|
12669
13187
|
<details>
|
|
12670
13188
|
|
|
@@ -12767,7 +13285,7 @@ describe('R.when', () => {
|
|
|
12767
13285
|
zip<K>(x: K[]): <V>(y: V[]) => KeyValuePair<K, V>[]
|
|
12768
13286
|
```
|
|
12769
13287
|
|
|
12770
|
-
It will return a new array containing tuples of equally positions items from both `x` and `y` lists.
|
|
13288
|
+
It will return a new array containing tuples of equally positions items from both `x` and `y` lists.
|
|
12771
13289
|
|
|
12772
13290
|
The returned list will be truncated to match the length of the shortest supplied list.
|
|
12773
13291
|
|
|
@@ -12896,11 +13414,11 @@ zipWith<T, U, TResult>(
|
|
|
12896
13414
|
const list1 = [ 10, 20, 30, 40 ]
|
|
12897
13415
|
const list2 = [ 100, 200 ]
|
|
12898
13416
|
|
|
12899
|
-
const result = R.zipWith(
|
|
13417
|
+
const result = R.zipWith((x, y) => x + y, list1)(list2)
|
|
12900
13418
|
// => [110, 220]
|
|
12901
13419
|
```
|
|
12902
13420
|
|
|
12903
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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(
|
|
13421
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?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>
|
|
12904
13422
|
|
|
12905
13423
|
<details>
|
|
12906
13424
|
|
|
@@ -12989,6 +13507,26 @@ describe('R.zipWith', () => {
|
|
|
12989
13507
|
|
|
12990
13508
|
## ❯ CHANGELOG
|
|
12991
13509
|
|
|
13510
|
+
10.3.0
|
|
13511
|
+
|
|
13512
|
+
- Add `R.mapPropObject`
|
|
13513
|
+
|
|
13514
|
+
- Add `R.duplicateBy`
|
|
13515
|
+
|
|
13516
|
+
- Add `R.filterAsync`
|
|
13517
|
+
|
|
13518
|
+
- Add `R.indexBy`
|
|
13519
|
+
|
|
13520
|
+
- Restore `R.replaceAll`
|
|
13521
|
+
|
|
13522
|
+
- Remove option for `R.mapAsync` to be called outside of `R.pipeAsync`. This is done for consistency as all other methods follow this rule, i.e. they are all curried.
|
|
13523
|
+
|
|
13524
|
+
- Fix `R.pluck` to work without `R.pipe`
|
|
13525
|
+
|
|
13526
|
+
10.2.0
|
|
13527
|
+
|
|
13528
|
+
Add `R.modifyPath`
|
|
13529
|
+
|
|
12992
13530
|
10.1.0
|
|
12993
13531
|
|
|
12994
13532
|
- Add `R.assertType` and `R.convertToType` methods
|
|
@@ -13013,7 +13551,7 @@ This is major revamp of `Rambda` library:
|
|
|
13013
13551
|
|
|
13014
13552
|
- Confusing methods are removed. For example, `R.cond` and `R.ifElse` are removed as their usage inside `R.piped` makes the whole chain less readable. Such logic should be part of your codebase, not part of external library.
|
|
13015
13553
|
|
|
13016
|
-
- All methods that expect more than 1 input, will have to be called with `R.methodName(input1)(input2)` or `R.methodName(input1, input2)(input3)`. This is to make TypeScript definitions easier to maintain.
|
|
13554
|
+
- All methods that expect more than 1 input, will have to be called with `R.methodName(input1)(input2)` or `R.methodName(input1, input2)(input3)`. This is to make TypeScript definitions easier to maintain.
|
|
13017
13555
|
|
|
13018
13556
|
- Optimize many methods to better work in TypeScript context with `R.pipe`. The focus was passing objects through the `R.pipe` chain.
|
|
13019
13557
|
|
|
@@ -13025,83 +13563,149 @@ This is major revamp of `Rambda` library:
|
|
|
13025
13563
|
- Remove following methods:
|
|
13026
13564
|
|
|
13027
13565
|
-- Lenses - `R.lens`, `R.lensProp`, `R.lensPath`, `R.view`, `R.set`, `R.over`
|
|
13566
|
+
|
|
13028
13567
|
-- T, F
|
|
13568
|
+
|
|
13029
13569
|
-- add
|
|
13570
|
+
|
|
13030
13571
|
-- addIndex, addIndexRight
|
|
13572
|
+
|
|
13031
13573
|
-- always
|
|
13574
|
+
|
|
13032
13575
|
-- ap
|
|
13576
|
+
|
|
13033
13577
|
-- applySpec
|
|
13578
|
+
|
|
13034
13579
|
-- applyTo
|
|
13580
|
+
|
|
13035
13581
|
-- assoc, assocPath, dissoc, dissocPath
|
|
13582
|
+
|
|
13036
13583
|
-- binary
|
|
13584
|
+
|
|
13037
13585
|
-- bind
|
|
13586
|
+
|
|
13038
13587
|
-- call
|
|
13588
|
+
|
|
13039
13589
|
-- collectBy
|
|
13590
|
+
|
|
13040
13591
|
-- compose
|
|
13592
|
+
|
|
13041
13593
|
-- composeWith
|
|
13594
|
+
|
|
13042
13595
|
-- cond
|
|
13596
|
+
|
|
13043
13597
|
-- converge
|
|
13598
|
+
|
|
13044
13599
|
-- curry
|
|
13600
|
+
|
|
13045
13601
|
-- difference, differenceWith
|
|
13602
|
+
|
|
13046
13603
|
-- divide, multiply, subtract
|
|
13604
|
+
|
|
13047
13605
|
-- endsWith/startsWith
|
|
13606
|
+
|
|
13048
13607
|
-- flip
|
|
13608
|
+
|
|
13049
13609
|
-- forEachObjIndexed
|
|
13610
|
+
|
|
13050
13611
|
-- fromPairs
|
|
13612
|
+
|
|
13051
13613
|
-- gte, lte, lt, gt
|
|
13614
|
+
|
|
13052
13615
|
-- identical
|
|
13616
|
+
|
|
13053
13617
|
-- ifElse
|
|
13618
|
+
|
|
13054
13619
|
-- insert
|
|
13620
|
+
|
|
13055
13621
|
-- juxt
|
|
13622
|
+
|
|
13056
13623
|
-- length
|
|
13624
|
+
|
|
13057
13625
|
-- mapObjIndexed
|
|
13626
|
+
|
|
13058
13627
|
-- mergeAll, mergeLeft, mergeDeepLeft, mergeDeepRight
|
|
13628
|
+
|
|
13059
13629
|
-- move
|
|
13630
|
+
|
|
13060
13631
|
-- partitionIndexed
|
|
13632
|
+
|
|
13061
13633
|
-- pickAll
|
|
13634
|
+
|
|
13062
13635
|
-- pickBy
|
|
13636
|
+
|
|
13063
13637
|
-- repeat
|
|
13638
|
+
|
|
13064
13639
|
-- splitWhen
|
|
13640
|
+
|
|
13065
13641
|
-- toLower/toUpper
|
|
13642
|
+
|
|
13066
13643
|
-- unapply
|
|
13644
|
+
|
|
13067
13645
|
-- unnest
|
|
13646
|
+
|
|
13068
13647
|
-- update
|
|
13648
|
+
|
|
13069
13649
|
-- without
|
|
13070
13650
|
|
|
13071
13651
|
- Add following methods:
|
|
13072
13652
|
|
|
13073
13653
|
-- R.pipeAsync
|
|
13654
|
+
|
|
13074
13655
|
-- R.addProp
|
|
13656
|
+
|
|
13075
13657
|
-- R.createObjectFromKeys
|
|
13658
|
+
|
|
13076
13659
|
-- R.mapAsync
|
|
13660
|
+
|
|
13077
13661
|
-- R.mapParallelAsync
|
|
13662
|
+
|
|
13078
13663
|
-- R.ascend/R.descend
|
|
13664
|
+
|
|
13079
13665
|
-- R.shuffle
|
|
13666
|
+
|
|
13080
13667
|
-- R.permutations
|
|
13668
|
+
|
|
13081
13669
|
-- R.compact
|
|
13670
|
+
|
|
13082
13671
|
-- R.rejectObject
|
|
13672
|
+
|
|
13083
13673
|
-- R.findNth
|
|
13674
|
+
|
|
13084
13675
|
-- R.combinations
|
|
13676
|
+
|
|
13085
13677
|
-- R.sortByPath
|
|
13678
|
+
|
|
13086
13679
|
-- R.sortByPathDescending
|
|
13680
|
+
|
|
13087
13681
|
-- R.sortByDescending
|
|
13682
|
+
|
|
13088
13683
|
-- R.flattenObject
|
|
13684
|
+
|
|
13089
13685
|
-- R.addPropToObjects
|
|
13090
13686
|
|
|
13091
13687
|
- Rename following methods:
|
|
13092
13688
|
|
|
13093
13689
|
-- modifyItemAtIndex -> adjust
|
|
13094
|
-
|
|
13690
|
+
|
|
13691
|
+
-- checkObjectWithSpec -> where
|
|
13692
|
+
|
|
13095
13693
|
-- objectIncludes -> whereEq
|
|
13694
|
+
|
|
13096
13695
|
-- modify -> modifyProp
|
|
13696
|
+
|
|
13097
13697
|
-- chain -> flatMap
|
|
13698
|
+
|
|
13098
13699
|
-- mapObjIndexed -> mapObject
|
|
13099
13700
|
|
|
13100
13701
|
_ Regarding using object as input with TypeScript in methods such as `R.map/filter` - this feature is no longer supported in TypeScript as it has multiple issues when using inside pipes. In JS, it still works as before. Following methods are affected:
|
|
13101
13702
|
|
|
13102
13703
|
-- R.map
|
|
13704
|
+
|
|
13103
13705
|
-- R.mapIndexed
|
|
13706
|
+
|
|
13104
13707
|
-- R.filter
|
|
13708
|
+
|
|
13105
13709
|
-- R.reject
|
|
13106
13710
|
|
|
13107
13711
|
- Regarding using string as path input in `R.omit`, `R.pick` and `R.path` with TypeScript - now it require explicit definition of expected return type.
|
|
@@ -13130,36 +13734,63 @@ _ Regarding using object as input with TypeScript in methods such as `R.map/filt
|
|
|
13130
13734
|
- Sync with typing of `@types/ramda`:
|
|
13131
13735
|
|
|
13132
13736
|
-- allPass
|
|
13737
|
+
|
|
13133
13738
|
-- anyPass
|
|
13739
|
+
|
|
13134
13740
|
-- append
|
|
13741
|
+
|
|
13135
13742
|
-- both
|
|
13743
|
+
|
|
13136
13744
|
-- countBy
|
|
13745
|
+
|
|
13137
13746
|
-- drop
|
|
13747
|
+
|
|
13138
13748
|
-- dropLast
|
|
13749
|
+
|
|
13139
13750
|
-- dropRepeatsBy
|
|
13751
|
+
|
|
13140
13752
|
-- either
|
|
13753
|
+
|
|
13141
13754
|
-- filter
|
|
13755
|
+
|
|
13142
13756
|
-- forEach
|
|
13757
|
+
|
|
13143
13758
|
-- keys
|
|
13759
|
+
|
|
13144
13760
|
-- map
|
|
13761
|
+
|
|
13145
13762
|
-- mergeAll
|
|
13763
|
+
|
|
13146
13764
|
-- modify
|
|
13765
|
+
|
|
13147
13766
|
-- modifyPath
|
|
13767
|
+
|
|
13148
13768
|
-- omit
|
|
13769
|
+
|
|
13149
13770
|
-- partition
|
|
13771
|
+
|
|
13150
13772
|
-- pluck
|
|
13773
|
+
|
|
13151
13774
|
-- prepend
|
|
13775
|
+
|
|
13152
13776
|
-- propEq
|
|
13777
|
+
|
|
13153
13778
|
-- where
|
|
13779
|
+
|
|
13154
13780
|
-- whereAny
|
|
13155
13781
|
|
|
13156
13782
|
- Sync with typing of `remeda`:
|
|
13157
13783
|
|
|
13158
13784
|
-- filter
|
|
13785
|
+
|
|
13159
13786
|
-- reject
|
|
13787
|
+
|
|
13160
13788
|
-- map
|
|
13789
|
+
|
|
13161
13790
|
-- mapObject
|
|
13791
|
+
|
|
13162
13792
|
-- toPairs
|
|
13793
|
+
|
|
13163
13794
|
-- partition
|
|
13164
13795
|
|
|
13165
13796
|
- Publish to JSR registry - https://jsr.io/@rambda/rambda
|
|
@@ -13169,7 +13800,9 @@ _ Regarding using object as input with TypeScript in methods such as `R.map/filt
|
|
|
13169
13800
|
- Improve TypeScript definitions of:
|
|
13170
13801
|
|
|
13171
13802
|
-- objOf
|
|
13803
|
+
|
|
13172
13804
|
-- pluck
|
|
13805
|
+
|
|
13173
13806
|
-- mergeWith
|
|
13174
13807
|
|
|
13175
13808
|
- Change `Jest` with `Vitest`.
|
|
@@ -13215,7 +13848,7 @@ const result = piped(
|
|
|
13215
13848
|
|
|
13216
13849
|
- Add `R.isNotEmpty` as it is new method in `Ramda`
|
|
13217
13850
|
|
|
13218
|
-
- Fix `R.head`/`R.last` TS definition - It returns `undefined` if array has length of 0. Before
|
|
13851
|
+
- Fix `R.head`/`R.last` TS definition - It returns `undefined` if array has length of 0. Before
|
|
13219
13852
|
|
|
13220
13853
|
9.2.1
|
|
13221
13854
|
|
|
@@ -13225,7 +13858,7 @@ const result = piped(
|
|
|
13225
13858
|
|
|
13226
13859
|
- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)
|
|
13227
13860
|
|
|
13228
|
-
- Fix implementation of `R.unless` function - https://github.com/selfrefactor/rambda/pull/726
|
|
13861
|
+
- Fix implementation of `R.unless` function - https://github.com/selfrefactor/rambda/pull/726
|
|
13229
13862
|
|
|
13230
13863
|
9.1.1
|
|
13231
13864
|
|
|
@@ -13301,7 +13934,7 @@ Breaking change in TS definitions of `lenses` as now they are synced to `Ramda`
|
|
|
13301
13934
|
|
|
13302
13935
|
- Fix cannot compare errors in `Deno` with `R.equals` - [Issue #704](https://github.com/selfrefactor/rambda/issues/704).
|
|
13303
13936
|
|
|
13304
|
-
- Fix cannot compare `BigInt` with `R.equals`
|
|
13937
|
+
- Fix cannot compare `BigInt` with `R.equals`
|
|
13305
13938
|
|
|
13306
13939
|
8.3.0
|
|
13307
13940
|
|
|
@@ -13385,7 +14018,7 @@ Add the following methods:
|
|
|
13385
14018
|
|
|
13386
14019
|
7.2.1
|
|
13387
14020
|
|
|
13388
|
-
- Remove bad typings of `R.propIs` which caused the library to cannot be build with TypeScript.
|
|
14021
|
+
- Remove bad typings of `R.propIs` which caused the library to cannot be build with TypeScript.
|
|
13389
14022
|
|
|
13390
14023
|
- Drop support for `Wallaby` as per [https://github.com/wallabyjs/public/issues/3037](https://github.com/wallabyjs/public/issues/3037)
|
|
13391
14024
|
|
|
@@ -13479,11 +14112,11 @@ There are several other changes in `@types/ramda` as stated in [this comment](ht
|
|
|
13479
14112
|
|
|
13480
14113
|
-- R.toUpper
|
|
13481
14114
|
|
|
13482
|
-
- One more reason for the breaking change is changing of export declarations in `package.json` based on [this blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#packagejson-exports-imports-and-self-referencing) and [this merged Ramda's PR](https://github.com/ramda/ramda/pull/2999). This also led to renaming of `babel.config.js` to `babel.config.cjs`.
|
|
14115
|
+
- One more reason for the breaking change is changing of export declarations in `package.json` based on [this blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#packagejson-exports-imports-and-self-referencing) and [this merged Ramda's PR](https://github.com/ramda/ramda/pull/2999). This also led to renaming of `babel.config.js` to `babel.config.cjs`.
|
|
13483
14116
|
|
|
13484
14117
|
- Add `R.apply`, `R.bind` and `R.unapply`
|
|
13485
14118
|
|
|
13486
|
-
- `R.startsWith/R.endsWith` now support lists as inputs. This way, it matches current Ramda behavior.
|
|
14119
|
+
- `R.startsWith/R.endsWith` now support lists as inputs. This way, it matches current Ramda behavior.
|
|
13487
14120
|
|
|
13488
14121
|
- Remove unused typing for `R.chain`.
|
|
13489
14122
|
|
|
@@ -13511,7 +14144,7 @@ There are several other changes in `@types/ramda` as stated in [this comment](ht
|
|
|
13511
14144
|
|
|
13512
14145
|
- Incorrect benchmarks for `R.pipe/R.compose` - [Issue #608](https://github.com/selfrefactor/rambda/issues/608)
|
|
13513
14146
|
|
|
13514
|
-
- Fix `R.last/R.head` typings - [Issue #609](https://github.com/selfrefactor/rambda/issues/609)
|
|
14147
|
+
- Fix `R.last/R.head` typings - [Issue #609](https://github.com/selfrefactor/rambda/issues/609)
|
|
13515
14148
|
|
|
13516
14149
|
6.9.0
|
|
13517
14150
|
|
|
@@ -13526,7 +14159,7 @@ Fixing `R.uniq` was done by improving `R.indexOf` which has performance implicat
|
|
|
13526
14159
|
- R.symmetricDifference
|
|
13527
14160
|
- R.union
|
|
13528
14161
|
|
|
13529
|
-
- R.without no longer support the following case - `without('0:1', ['0', '0:1']) // => ['0']`. Now it throws as the first argument should be a list, not a string. Ramda, on the other hand, returns an empty list - https://github.com/ramda/ramda/issues/3086.
|
|
14162
|
+
- R.without no longer support the following case - `without('0:1', ['0', '0:1']) // => ['0']`. Now it throws as the first argument should be a list, not a string. Ramda, on the other hand, returns an empty list - https://github.com/ramda/ramda/issues/3086.
|
|
13530
14163
|
|
|
13531
14164
|
6.8.3
|
|
13532
14165
|
|
|
@@ -13611,25 +14244,25 @@ Fix wrong versions in changelog
|
|
|
13611
14244
|
|
|
13612
14245
|
> Most influential contributors(in alphabetical order)
|
|
13613
14246
|
|
|
13614
|
-
-
|
|
14247
|
+
- [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;
|
|
13615
14248
|
|
|
13616
|
-
-
|
|
14249
|
+
- [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;
|
|
13617
14250
|
|
|
13618
|
-
-
|
|
14251
|
+
- [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation
|
|
13619
14252
|
|
|
13620
|
-
-
|
|
14253
|
+
- [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;
|
|
13621
14254
|
|
|
13622
|
-
-
|
|
14255
|
+
- [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;
|
|
13623
14256
|
|
|
13624
|
-
-
|
|
14257
|
+
- [@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;
|
|
13625
14258
|
|
|
13626
|
-
-
|
|
14259
|
+
- [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;
|
|
13627
14260
|
|
|
13628
|
-
-
|
|
14261
|
+
- [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;
|
|
13629
14262
|
|
|
13630
|
-
-
|
|
14263
|
+
- [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;
|
|
13631
14264
|
|
|
13632
|
-
-
|
|
14265
|
+
- [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;
|
|
13633
14266
|
|
|
13634
14267
|
> Rambda references
|
|
13635
14268
|
|