rambda 10.1.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/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
  ![Commit activity](https://img.shields.io/github/commit-activity/y/selfrefactor/rambda)
8
6
  ![Library size](https://img.shields.io/bundlephobia/minzip/rambda)
@@ -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, map, filter } from 'rambda'
14
+ import { pipe, filter, map } from 'rambda'
17
15
 
18
16
  const result = pipe(
19
- [1, 2, 3, 4],
17
+ [1, 2, 3, 4],
20
18
  filter(x => x > 2),
21
19
  map(x => x * 2),
22
20
  )
23
- // => [6, 8]
21
+ //=> [6, 8]
24
22
  ```
25
23
 
26
- You can test this example in <a href="https://rambda.now.sh?const%20result%20%3D%20R.compose(%0A%20%20R.map(x%20%3D%3E%20x%20*%202)%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%202)%0A)(%5B1%2C%202%2C%203%2C%204%5D)%0A%0A%2F%2F%20%3D%3E%20%5B6%2C%208%5D">Rambda's REPL</a>
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
- Documentation site of `Rambda` version `9.4.2` is available [here](https://selfrefactor.github.io/rambda-v9/).
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
- -- Naming of methods is sometimes too generic to be remembered such as `R.update`, `R.modify`, `R.where`.
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
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-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%20%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>
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(fn)(list)
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(fn)(list)%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.any</strong> example in Rambda REPL</a>
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)%20%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.anyPass</strong> example in Rambda REPL</a>
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)%20%0A%2F%2F%20%3D%3E%20true">Try this <strong>R.checkObjectWithSpec</strong> example in Rambda REPL</a>
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
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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%20%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>
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, mergeTypes, pipe } from 'rambda'
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
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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%20%0A%20%202%2C%20%0A%20%20%5B3%2C%2030%2C%20%5B300%5D%5D%2C%20%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>
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')%20%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>
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
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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('without list of objects - no R.equals', () => {
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 uses R.equals', () => {
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 uses R.equals', () => {
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%20%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>
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 a of list) {
5793
- willReturn.push(await fn(a, i++))
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
- mapAsync(fn),
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 two three arguments', () => {
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
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mapParallelAsync)
6306
6531
 
6307
- ### match
6532
+ ### mapPropObject
6308
6533
 
6309
6534
  ```typescript
6310
6535
 
6311
- match(regExpression: RegExp): (str: string) => string[]
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
- Curried version of `String.prototype.match` which returns empty array, when there is no match.
6547
+ It maps over a property of object that is a list.
6315
6548
 
6316
6549
  ```javascript
6317
- const result = [
6318
- R.match('a', 'foo'),
6319
- R.match(/([a-z]a)/g, 'bananas')
6320
- ]
6321
- // => [[], ['ba', 'na', 'na']]
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%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>
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
- match(regExpression: RegExp): (str: string) => string[];
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.match</strong> source</summary>
6585
+ <summary><strong>R.mapPropObject</strong> source</summary>
6339
6586
 
6340
6587
  ```javascript
6341
- export function match(pattern) {
6342
- return input => {
6343
- const willReturn = input.match(pattern)
6344
-
6345
- return willReturn === null ? [] : willReturn
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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#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, R.add(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%20R.add(1))%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>
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
 
@@ -6714,6 +7066,135 @@ test('when index is out of bounds', () => {
6714
7066
 
6715
7067
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#modifyItemAtIndex)
6716
7068
 
7069
+ ### modifyPath
7070
+
7071
+ ```typescript
7072
+
7073
+ modifyPath<U, T>(path: [], fn: (value: U) => T): (obj: U) => T
7074
+ ```
7075
+
7076
+ It changes a property of object on the base of provided path and transformer function.
7077
+
7078
+ ```javascript
7079
+ const result = R.modifyPath('a.b.c', x=> x+1, {a:{b: {c:1}}})
7080
+ // => {a:{b: {c:2}}}
7081
+ ```
7082
+
7083
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.modifyPath('a.b.c'%2C%20x%3D%3E%20x%2B1%2C%20%7Ba%3A%7Bb%3A%20%7Bc%3A1%7D%7D%7D)%0A%2F%2F%20%3D%3E%20%7Ba%3A%7Bb%3A%20%7Bc%3A2%7D%7D%7D">Try this <strong>R.modifyPath</strong> example in Rambda REPL</a>
7084
+
7085
+ <details>
7086
+
7087
+ <summary>All TypeScript definitions</summary>
7088
+
7089
+ ```typescript
7090
+ modifyPath<U, T>(path: [], fn: (value: U) => T): (obj: U) => T;
7091
+ modifyPath<
7092
+ K0 extends keyof U,
7093
+ U,
7094
+ T
7095
+ >(path: [K0], fn: (value: U[K0]) => T): (obj: U) => DeepModify<[K0], U, T>;
7096
+ modifyPath<
7097
+ K0 extends string & keyof U,
7098
+ U,
7099
+ T
7100
+ >(path: `${K0}`, fn: (value: U[K0]) => T): (obj: U) => DeepModify<[K0], U, T>;
7101
+ modifyPath<
7102
+ K0 extends keyof U,
7103
+ K1 extends keyof U[K0],
7104
+ U,
7105
+ T
7106
+ >(path: [K0, K1], fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<[K0, K1], U, T>;
7107
+ ...
7108
+ ...
7109
+ ```
7110
+
7111
+ </details>
7112
+
7113
+ <details>
7114
+
7115
+ <summary><strong>R.modifyPath</strong> source</summary>
7116
+
7117
+ ```javascript
7118
+ import { createPath } from './_internals/createPath.js'
7119
+ import { path as pathModule } from './path.js'
7120
+
7121
+ function assoc(prop, newValue) {
7122
+ return obj => Object.assign({}, obj, { [prop]: newValue })
7123
+ }
7124
+
7125
+ function modifyPathFn(pathInput, fn, obj) {
7126
+ const path = createPath(pathInput)
7127
+ if (path.length === 1) {
7128
+ return {
7129
+ ...obj,
7130
+ [path[0]]: fn(obj[path[0]]),
7131
+ }
7132
+ }
7133
+ if (pathModule(path)(obj) === undefined) {
7134
+ return obj
7135
+ }
7136
+
7137
+ const val = modifyPathFn(Array.prototype.slice.call(path, 1), fn, obj[path[0]])
7138
+ if (val === obj[path[0]]) {
7139
+ return obj
7140
+ }
7141
+
7142
+ return assoc(path[0], val)(obj)
7143
+ }
7144
+
7145
+ export function modifyPath(pathInput, fn) {
7146
+ return obj => modifyPathFn(pathInput, fn, obj)
7147
+ }
7148
+ ```
7149
+
7150
+ </details>
7151
+
7152
+ <details>
7153
+
7154
+ <summary><strong>Tests</strong></summary>
7155
+
7156
+ ```javascript
7157
+ import { modifyPath } from './modifyPath.js'
7158
+
7159
+ test('happy', () => {
7160
+ const result = modifyPath('a.b.c', x => x + 1)({ a: { b: { c: 1 } } })
7161
+ expect(result).toEqual({ a: { b: { c: 2 } } })
7162
+ })
7163
+ ```
7164
+
7165
+ </details>
7166
+
7167
+ <details>
7168
+
7169
+ <summary><strong>TypeScript</strong> test</summary>
7170
+
7171
+ ```typescript
7172
+ import { modifyPath, pipe } from 'rambda'
7173
+
7174
+ const obj = { a: { b: { c: 1 } } }
7175
+
7176
+ describe('R.modifyPath', () => {
7177
+ it('array path', () => {
7178
+ const result = pipe(
7179
+ obj,
7180
+ modifyPath(['a', 'b', 'c'], (x: number) => String(x)),
7181
+ )
7182
+ result.a.b.c // $ExpectType string
7183
+ })
7184
+ it('string path', () => {
7185
+ const result = pipe(
7186
+ obj,
7187
+ modifyPath('a.b.c', (x: number) => String(x)),
7188
+ )
7189
+ result.a.b.c // $ExpectType string
7190
+ })
7191
+ })
7192
+ ```
7193
+
7194
+ </details>
7195
+
7196
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#modifyPath)
7197
+
6717
7198
  ### modifyProp
6718
7199
 
6719
7200
  ```typescript
@@ -6731,11 +7212,11 @@ const person = {
6731
7212
  name : 'foo',
6732
7213
  age : 20,
6733
7214
  }
6734
- const result = R.modifyProp('age', x => x + 1)(person)
7215
+ const result = R.modifyProp('age', x => x + 1)(person)
6735
7216
  // => {name: 'foo', age: 21}
6736
7217
  ```
6737
7218
 
6738
- <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)%20%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>
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>
6739
7220
 
6740
7221
  <details>
6741
7222
 
@@ -7158,13 +7639,13 @@ const propsToOmit = 'a,c,d'
7158
7639
  const propsToOmitList = ['a', 'c', 'd']
7159
7640
 
7160
7641
  const result = [
7161
- R.omit(propsToOmit, obj),
7162
- R.omit(propsToOmitList, obj)
7642
+ R.omit(propsToOmit, obj),
7643
+ R.omit(propsToOmitList, obj)
7163
7644
  ]
7164
7645
  // => [{b: 2}, {b: 2}]
7165
7646
  ```
7166
7647
 
7167
- <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%20%0A%20%20R.omit(propsToOmitList%2C%20obj)%20%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>
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>
7168
7649
 
7169
7650
  <details>
7170
7651
 
@@ -8241,8 +8722,8 @@ test('happy', () => {
8241
8722
  ```typescript
8242
8723
  import {
8243
8724
  type MergeTypes,
8244
- allPass,
8245
8725
  append,
8726
+ assertType,
8246
8727
  defaultTo,
8247
8728
  drop,
8248
8729
  dropLast,
@@ -8251,12 +8732,9 @@ import {
8251
8732
  find,
8252
8733
  head,
8253
8734
  map,
8254
- mapObject,
8255
- path,
8256
8735
  pick,
8257
8736
  pipe,
8258
8737
  split,
8259
- tap,
8260
8738
  union,
8261
8739
  } from 'rambda'
8262
8740
  type IsNotNever<T> = [T] extends [never] ? false : true
@@ -8275,12 +8753,6 @@ interface Book extends BaseBook {
8275
8753
  }
8276
8754
  status?: Status
8277
8755
  }
8278
- interface MustReadBook extends Book {
8279
- status: 'must-read'
8280
- }
8281
- interface FamousBook extends Book {
8282
- status: 'famous'
8283
- }
8284
8756
  interface BookWithBookmarkStatus extends Book {
8285
8757
  bookmarkFlag: boolean
8286
8758
  }
@@ -8288,14 +8760,13 @@ interface BookWithReadStatus extends Book {
8288
8760
  readFlag: boolean
8289
8761
  }
8290
8762
  type BookToRead = BookWithBookmarkStatus & BookWithReadStatus
8291
- interface BookWithDescription extends Book {
8292
- description: string
8293
- }
8294
- interface BookWithUserRating extends Book {
8295
- userRating: number
8763
+ type FamousBook = Book & {
8764
+ status: 'famous'
8296
8765
  }
8297
- type BookWithDetails = BookWithDescription & BookWithUserRating
8298
8766
 
8767
+ const checkIfFamous = (x: Book): x is FamousBook => {
8768
+ return x.status === 'famous'
8769
+ }
8299
8770
  const zaratustra: BaseBook = {
8300
8771
  title: 'Zaratustra',
8301
8772
  year: 1956,
@@ -8319,11 +8790,6 @@ const awardedBrothersKaramazov: Book = {
8319
8790
  years: [1869, 1870],
8320
8791
  },
8321
8792
  }
8322
- const awardedBrothersKaramazovToRead: BookToRead = {
8323
- ...awardedBrothersKaramazov,
8324
- readFlag: true,
8325
- bookmarkFlag: true,
8326
- }
8327
8793
  const awardedZaratustraToRead: BookToRead = {
8328
8794
  ...awardedZaratustra,
8329
8795
  readFlag: true,
@@ -8340,40 +8806,9 @@ const awardedBaseValue: Book = {
8340
8806
 
8341
8807
  type Status = 'famous' | 'can be skipped' | 'must-read'
8342
8808
 
8343
- function checkIfMustRead(x: Book): x is MustReadBook {
8344
- return (x as MustReadBook).status === 'must-read'
8345
- }
8346
- function checkIfFamous(x: Book): x is FamousBook {
8347
- return (x as FamousBook).status === 'famous'
8348
- }
8349
- function checkReadStatus(x: Book): x is BookWithReadStatus {
8350
- return (x as BookWithReadStatus).readFlag
8351
- }
8352
- function checkBookmarkStatus(x: Book): x is BookWithBookmarkStatus {
8353
- return (x as BookWithBookmarkStatus).bookmarkFlag
8354
- }
8355
8809
  function checkBookToRead(x: Book): x is BookToRead {
8356
8810
  return (x as BookToRead).readFlag && (x as BookToRead).bookmarkFlag
8357
8811
  }
8358
- function checkHasDescription(x: Book): x is BookWithDescription {
8359
- return (x as BookWithDescription).description !== undefined
8360
- }
8361
- function checkHasUserRating(x: Book): x is BookWithUserRating {
8362
- return (x as BookWithUserRating).userRating !== undefined
8363
- }
8364
-
8365
- function assertType<T, U extends T>(fn: (x: T) => x is U) {
8366
- return (x: T) => {
8367
- if (fn(x)) {
8368
- return x
8369
- }
8370
- throw new Error('type assertion failed')
8371
- }
8372
- }
8373
- function convertToType<T>() {
8374
- return <U>(x: U) => x as unknown as T
8375
- }
8376
- // const convertToType = <T>(x: unknown)=> x as unknown as T
8377
8812
 
8378
8813
  function tapFn<T, U>(
8379
8814
  transformFn: (x: T) => U,
@@ -8423,17 +8858,10 @@ describe('real use cases - books', () => {
8423
8858
  evolve({
8424
8859
  year: x => x + 1,
8425
8860
  }),
8426
- // convertToType<BookWithDescription>(),
8427
- // dissocPath<Book>('description'),
8428
- // convertToType<Record<string, string>>(),
8429
- // mapObject((x) => {
8430
- // return x as unknown as number;
8431
- // }),
8432
8861
  simplify,
8433
8862
  pick('year'),
8434
8863
  )
8435
8864
  const result = getResult(zaratustra)
8436
- type Foo = MergeTypes<typeof result>
8437
8865
  const final: Expect<IsNotNever<typeof result>> = true
8438
8866
  })
8439
8867
  it('case 3', () => {
@@ -8486,7 +8914,7 @@ const result = await R.pipeAsync(
8486
8914
  await R.delay(100)
8487
8915
  return x + 2
8488
8916
  },
8489
- R.add(2),
8917
+ x => x +2,
8490
8918
  async x => {
8491
8919
  const delayed = await R.delay(100)
8492
8920
  return delayed + x
@@ -8495,7 +8923,7 @@ const result = await R.pipeAsync(
8495
8923
  // `result` resolves to `RAMBDAX_DELAY104`
8496
8924
  ```
8497
8925
 
8498
- <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%20R.add(2)%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>
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>
8499
8927
 
8500
8928
  <details>
8501
8929
 
@@ -8607,11 +9035,11 @@ Basically, this is `R.map(R.prop(property))`.
8607
9035
  const list = [{a: 1}, {a: 2}, {b: 3}]
8608
9036
  const property = 'a'
8609
9037
 
8610
- const result = R.pluck(property)(list)
9038
+ const result = R.pluck(property)(list)
8611
9039
  // => [1, 2]
8612
9040
  ```
8613
9041
 
8614
- <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)%20%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.pluck</strong> example in Rambda REPL</a>
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>
8615
9043
 
8616
9044
  <details>
8617
9045
 
@@ -8619,6 +9047,12 @@ const result = R.pluck(property)(list)
8619
9047
 
8620
9048
  ```typescript
8621
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
+ ...
8622
9056
  ```
8623
9057
 
8624
9058
  </details>
@@ -8668,16 +9102,29 @@ test('with undefined', () => {
8668
9102
  <summary><strong>TypeScript</strong> test</summary>
8669
9103
 
8670
9104
  ```typescript
8671
- import { pipe, pluck } from 'rambda'
9105
+ import { pipe, pluck } from "rambda";
8672
9106
 
8673
- it('R.pluck', () => {
9107
+ it("R.pluck", () => {
8674
9108
  const input = [
8675
- { a: 1, b: 'foo' },
8676
- { a: 2, b: 'bar' },
8677
- ]
8678
- const result = pipe(input, pluck('b'))
8679
- result // $ExpectType string[]
8680
- })
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
+ });
8681
9128
  ```
8682
9129
 
8683
9130
  </details>
@@ -8756,13 +9203,13 @@ If there is no such property, it returns `undefined`.
8756
9203
 
8757
9204
  ```javascript
8758
9205
  const result = [
8759
- R.prop('x')({x: 100}),
8760
- R.prop('x')({a: 1})
9206
+ R.prop('x')({x: 100}),
9207
+ R.prop('x')({a: 1})
8761
9208
  ]
8762
9209
  // => [100, undefined]
8763
9210
  ```
8764
9211
 
8765
- <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%20%0A%20%20R.prop('x')(%7Ba%3A%201%7D)%20%0A%5D%0A%2F%2F%20%3D%3E%20%5B100%2C%20undefined%5D">Try this <strong>R.prop</strong> example in Rambda REPL</a>
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>
8766
9213
 
8767
9214
  <details>
8768
9215
 
@@ -9660,6 +10107,98 @@ describe('R.replace', () => {
9660
10107
 
9661
10108
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#replace)
9662
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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#replaceAll)
10201
+
9663
10202
  ### shuffle
9664
10203
 
9665
10204
  ```typescript
@@ -9971,6 +10510,25 @@ describe('R.sortBy', () => {
9971
10510
  sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[]
9972
10511
  ```
9973
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
+
9974
10532
  <details>
9975
10533
 
9976
10534
  <summary>All TypeScript definitions</summary>
@@ -10008,6 +10566,23 @@ sortByPath<S, K0 extends string & keyof S>(
10008
10566
 
10009
10567
  It sorts `list` by the value of `path` property.
10010
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
+
10011
10586
  <details>
10012
10587
 
10013
10588
  <summary>All TypeScript definitions</summary>
@@ -10112,6 +10687,23 @@ sortByPathDescending<S, K0 extends string & keyof S>(
10112
10687
  ): (list: S[]) => S[]
10113
10688
  ```
10114
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
+
10115
10707
  <details>
10116
10708
 
10117
10709
  <summary>All TypeScript definitions</summary>
@@ -10185,11 +10777,11 @@ It returns a sorted version of `input` object.
10185
10777
  ```javascript
10186
10778
  const predicate = (propA, propB, valueA, valueB) => valueA > valueB ? -1 : 1
10187
10779
 
10188
- const result = R.sortObject(predicate, {a:1, b: 4, c: 2})
10780
+ const result = R.sortObject(predicate)({a:1, b: 4, c: 2})
10189
10781
  // => {b: 4, c: 2, a: 1}
10190
10782
  ```
10191
10783
 
10192
- <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%2C%20%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>
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>
10193
10785
 
10194
10786
  <details>
10195
10787
 
@@ -10550,8 +11142,8 @@ It splits `input` into slices of `sliceLength`.
10550
11142
 
10551
11143
  ```javascript
10552
11144
  const result = [
10553
- R.splitEvery(2, [1, 2, 3]),
10554
- R.splitEvery(3, 'foobar')
11145
+ R.splitEvery(2)([1, 2, 3]),
11146
+ R.splitEvery(3)('foobar')
10555
11147
  ]
10556
11148
 
10557
11149
  const expected = [
@@ -10561,7 +11153,7 @@ const expected = [
10561
11153
  // => `result` is equal to `expected`
10562
11154
  ```
10563
11155
 
10564
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20%5B%0A%20%20R.splitEvery(2%2C%20%5B1%2C%202%2C%203%5D)%2C%20%0A%20%20R.splitEvery(3%2C%20'foobar')%20%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>
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>
10565
11157
 
10566
11158
  <details>
10567
11159
 
@@ -10648,11 +11240,11 @@ It returns a merged list of `x` and `y` with all equal elements removed.
10648
11240
  const x = [ 1, 2, 3, 4 ]
10649
11241
  const y = [ 3, 4, 5, 6 ]
10650
11242
 
10651
- const result = R.symmetricDifference(x, y)
11243
+ const result = R.symmetricDifference(x)(y)
10652
11244
  // => [ 1, 2, 5, 6 ]
10653
11245
  ```
10654
11246
 
10655
- <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%2C%20y)%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>
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>
10656
11248
 
10657
11249
  <details>
10658
11250
 
@@ -10743,13 +11335,13 @@ It returns all but the first element of `input`.
10743
11335
 
10744
11336
  ```javascript
10745
11337
  const result = [
10746
- R.tail([1, 2, 3]),
10747
- R.tail('foo')
11338
+ R.tail([1, 2, 3]),
11339
+ R.tail('foo')
10748
11340
  ]
10749
11341
  // => [[2, 3], 'oo']
10750
11342
  ```
10751
11343
 
10752
- <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%20%20%0A%20%20R.tail('foo')%20%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>
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>
10753
11345
 
10754
11346
  <details>
10755
11347
 
@@ -11212,23 +11804,23 @@ it('R.takeWhile', () => {
11212
11804
  tap<T>(fn: (x: T) => void): (input: T) => T
11213
11805
  ```
11214
11806
 
11215
- It applies function `fn` to input `x` and returns `x`.
11807
+ It applies function `fn` to input `x` and returns `x`.
11216
11808
 
11217
11809
  One use case is debugging in the middle of `R.pipe` chain.
11218
11810
 
11219
11811
  ```javascript
11220
11812
  const list = [1, 2, 3]
11221
11813
 
11222
- R.pipe(
11814
+ const result = R.pipe(
11223
11815
  list,
11224
- R.map(x => x * 2)
11816
+ R.filter(x => x > 1),
11225
11817
  R.tap(console.log),
11226
- R.filter(x => x > 1)
11818
+ R.map(x => x * 2)
11227
11819
  )
11228
11820
  // => `2` and `3` will be logged
11229
11821
  ```
11230
11822
 
11231
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0A%0AR.pipe(%0A%09list%2C%0A%20%20R.map(x%20%3D%3E%20x%20*%202)%0A%20%20R.tap(console.log)%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%201)%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>
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>
11232
11824
 
11233
11825
  <details>
11234
11826
 
@@ -11332,6 +11924,63 @@ it('R.test', () => {
11332
11924
 
11333
11925
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#test)
11334
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
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#transformPropObject)
11983
+
11335
11984
  ### tryCatch
11336
11985
 
11337
11986
  ```typescript
@@ -11726,16 +12375,16 @@ describe('R.type', () => {
11726
12375
  union<T>(x: T[]): (y: T[]) => T[]
11727
12376
  ```
11728
12377
 
11729
- 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.
11730
12379
 
11731
12380
  `R.equals` is used to compare for duplication.
11732
12381
 
11733
12382
  ```javascript
11734
- const result = R.union([1,2,3], [3,4,5]);
12383
+ const result = R.union([1,2,3])([3,4,5]);
11735
12384
  // => [1, 2, 3, 4, 5]
11736
12385
  ```
11737
12386
 
11738
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.union(%5B1%2C2%2C3%5D%2C%20%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>
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>
11739
12388
 
11740
12389
  <details>
11741
12390
 
@@ -11946,12 +12595,12 @@ It applies uniqueness to input list based on function that defines what to be us
11946
12595
 
11947
12596
  ```javascript
11948
12597
  const list = [{a:1}, {a:2}, {a:1}]
11949
- const result = R.uniqBy(x => x, list)
12598
+ const result = R.uniqBy(x => x)(list)
11950
12599
 
11951
12600
  // => [{a:1}, {a:2}]
11952
12601
  ```
11953
12602
 
11954
- <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%2C%20list)%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>
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>
11955
12604
 
11956
12605
  <details>
11957
12606
 
@@ -12428,11 +13077,11 @@ const index = 2
12428
13077
  const newValue = 88
12429
13078
  const list = [1, 2, 3, 4, 5]
12430
13079
 
12431
- const result = R.update(index, newValue, list)
13080
+ const result = R.update(index, newValue)(list)
12432
13081
  // => [1, 2, 88, 4, 5]
12433
13082
  ```
12434
13083
 
12435
- <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%2C%20list)%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>
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>
12436
13085
 
12437
13086
  <details>
12438
13087
 
@@ -12511,31 +13160,29 @@ test('with negative index', () => {
12511
13160
  when<T, U extends T>(predicate: (x: T) => x is U, whenTrueFn: (x: U) => T): (input: T) => T
12512
13161
  ```
12513
13162
 
12514
- 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)`.
12515
13164
  If the `predicate` returns `false`, then it will simply return `input`.
12516
13165
 
12517
13166
  ```javascript
12518
13167
  const predicate = x => typeof x === 'number'
12519
- const whenTrueFn = R.add(11)
12520
-
12521
- const fn = when(predicate, whenTrueResult)
13168
+ const fn = R.when(predicate)(x => x + 1)
12522
13169
 
12523
13170
  const positiveInput = 88
12524
13171
  const negativeInput = 'foo'
12525
13172
 
12526
13173
  const result = [
12527
13174
  fn(positiveInput),
12528
- fn(positiveInput),
13175
+ fn(negativeInput),
12529
13176
  ]
12530
13177
 
12531
13178
  const expected = [
12532
- 99,
12533
- 'foo',
13179
+ 89,
13180
+ 'foo1',
12534
13181
  ]
12535
13182
  // => `result` is equal to `expected`
12536
13183
  ```
12537
13184
 
12538
- <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>
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>
12539
13186
 
12540
13187
  <details>
12541
13188
 
@@ -12638,7 +13285,7 @@ describe('R.when', () => {
12638
13285
  zip<K>(x: K[]): <V>(y: V[]) => KeyValuePair<K, V>[]
12639
13286
  ```
12640
13287
 
12641
- 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.
12642
13289
 
12643
13290
  The returned list will be truncated to match the length of the shortest supplied list.
12644
13291
 
@@ -12767,11 +13414,11 @@ zipWith<T, U, TResult>(
12767
13414
  const list1 = [ 10, 20, 30, 40 ]
12768
13415
  const list2 = [ 100, 200 ]
12769
13416
 
12770
- const result = R.zipWith(R.add, list1)(list2)
13417
+ const result = R.zipWith((x, y) => x + y, list1)(list2)
12771
13418
  // => [110, 220]
12772
13419
  ```
12773
13420
 
12774
- <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(R.add%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>
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>
12775
13422
 
12776
13423
  <details>
12777
13424
 
@@ -12860,6 +13507,26 @@ describe('R.zipWith', () => {
12860
13507
 
12861
13508
  ## ❯ CHANGELOG
12862
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
+
12863
13530
  10.1.0
12864
13531
 
12865
13532
  - Add `R.assertType` and `R.convertToType` methods
@@ -12884,7 +13551,7 @@ This is major revamp of `Rambda` library:
12884
13551
 
12885
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.
12886
13553
 
12887
- - 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.
12888
13555
 
12889
13556
  - Optimize many methods to better work in TypeScript context with `R.pipe`. The focus was passing objects through the `R.pipe` chain.
12890
13557
 
@@ -12896,83 +13563,149 @@ This is major revamp of `Rambda` library:
12896
13563
  - Remove following methods:
12897
13564
 
12898
13565
  -- Lenses - `R.lens`, `R.lensProp`, `R.lensPath`, `R.view`, `R.set`, `R.over`
13566
+
12899
13567
  -- T, F
13568
+
12900
13569
  -- add
13570
+
12901
13571
  -- addIndex, addIndexRight
13572
+
12902
13573
  -- always
13574
+
12903
13575
  -- ap
13576
+
12904
13577
  -- applySpec
13578
+
12905
13579
  -- applyTo
13580
+
12906
13581
  -- assoc, assocPath, dissoc, dissocPath
13582
+
12907
13583
  -- binary
13584
+
12908
13585
  -- bind
13586
+
12909
13587
  -- call
13588
+
12910
13589
  -- collectBy
13590
+
12911
13591
  -- compose
13592
+
12912
13593
  -- composeWith
13594
+
12913
13595
  -- cond
13596
+
12914
13597
  -- converge
13598
+
12915
13599
  -- curry
13600
+
12916
13601
  -- difference, differenceWith
13602
+
12917
13603
  -- divide, multiply, subtract
13604
+
12918
13605
  -- endsWith/startsWith
13606
+
12919
13607
  -- flip
13608
+
12920
13609
  -- forEachObjIndexed
13610
+
12921
13611
  -- fromPairs
13612
+
12922
13613
  -- gte, lte, lt, gt
13614
+
12923
13615
  -- identical
13616
+
12924
13617
  -- ifElse
13618
+
12925
13619
  -- insert
13620
+
12926
13621
  -- juxt
13622
+
12927
13623
  -- length
13624
+
12928
13625
  -- mapObjIndexed
13626
+
12929
13627
  -- mergeAll, mergeLeft, mergeDeepLeft, mergeDeepRight
13628
+
12930
13629
  -- move
13630
+
12931
13631
  -- partitionIndexed
13632
+
12932
13633
  -- pickAll
13634
+
12933
13635
  -- pickBy
13636
+
12934
13637
  -- repeat
13638
+
12935
13639
  -- splitWhen
13640
+
12936
13641
  -- toLower/toUpper
13642
+
12937
13643
  -- unapply
13644
+
12938
13645
  -- unnest
13646
+
12939
13647
  -- update
13648
+
12940
13649
  -- without
12941
13650
 
12942
13651
  - Add following methods:
12943
13652
 
12944
13653
  -- R.pipeAsync
13654
+
12945
13655
  -- R.addProp
13656
+
12946
13657
  -- R.createObjectFromKeys
13658
+
12947
13659
  -- R.mapAsync
13660
+
12948
13661
  -- R.mapParallelAsync
13662
+
12949
13663
  -- R.ascend/R.descend
13664
+
12950
13665
  -- R.shuffle
13666
+
12951
13667
  -- R.permutations
13668
+
12952
13669
  -- R.compact
13670
+
12953
13671
  -- R.rejectObject
13672
+
12954
13673
  -- R.findNth
13674
+
12955
13675
  -- R.combinations
13676
+
12956
13677
  -- R.sortByPath
13678
+
12957
13679
  -- R.sortByPathDescending
13680
+
12958
13681
  -- R.sortByDescending
13682
+
12959
13683
  -- R.flattenObject
13684
+
12960
13685
  -- R.addPropToObjects
12961
13686
 
12962
13687
  - Rename following methods:
12963
13688
 
12964
13689
  -- modifyItemAtIndex -> adjust
12965
- -- checkObjectWithSpec -> where
13690
+
13691
+ -- checkObjectWithSpec -> where
13692
+
12966
13693
  -- objectIncludes -> whereEq
13694
+
12967
13695
  -- modify -> modifyProp
13696
+
12968
13697
  -- chain -> flatMap
13698
+
12969
13699
  -- mapObjIndexed -> mapObject
12970
13700
 
12971
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:
12972
13702
 
12973
13703
  -- R.map
13704
+
12974
13705
  -- R.mapIndexed
13706
+
12975
13707
  -- R.filter
13708
+
12976
13709
  -- R.reject
12977
13710
 
12978
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.
@@ -13001,36 +13734,63 @@ _ Regarding using object as input with TypeScript in methods such as `R.map/filt
13001
13734
  - Sync with typing of `@types/ramda`:
13002
13735
 
13003
13736
  -- allPass
13737
+
13004
13738
  -- anyPass
13739
+
13005
13740
  -- append
13741
+
13006
13742
  -- both
13743
+
13007
13744
  -- countBy
13745
+
13008
13746
  -- drop
13747
+
13009
13748
  -- dropLast
13749
+
13010
13750
  -- dropRepeatsBy
13751
+
13011
13752
  -- either
13753
+
13012
13754
  -- filter
13755
+
13013
13756
  -- forEach
13757
+
13014
13758
  -- keys
13759
+
13015
13760
  -- map
13761
+
13016
13762
  -- mergeAll
13763
+
13017
13764
  -- modify
13765
+
13018
13766
  -- modifyPath
13767
+
13019
13768
  -- omit
13769
+
13020
13770
  -- partition
13771
+
13021
13772
  -- pluck
13773
+
13022
13774
  -- prepend
13775
+
13023
13776
  -- propEq
13777
+
13024
13778
  -- where
13779
+
13025
13780
  -- whereAny
13026
13781
 
13027
13782
  - Sync with typing of `remeda`:
13028
13783
 
13029
13784
  -- filter
13785
+
13030
13786
  -- reject
13787
+
13031
13788
  -- map
13789
+
13032
13790
  -- mapObject
13791
+
13033
13792
  -- toPairs
13793
+
13034
13794
  -- partition
13035
13795
 
13036
13796
  - Publish to JSR registry - https://jsr.io/@rambda/rambda
@@ -13040,7 +13800,9 @@ _ Regarding using object as input with TypeScript in methods such as `R.map/filt
13040
13800
  - Improve TypeScript definitions of:
13041
13801
 
13042
13802
  -- objOf
13803
+
13043
13804
  -- pluck
13805
+
13044
13806
  -- mergeWith
13045
13807
 
13046
13808
  - Change `Jest` with `Vitest`.
@@ -13086,7 +13848,7 @@ const result = piped(
13086
13848
 
13087
13849
  - Add `R.isNotEmpty` as it is new method in `Ramda`
13088
13850
 
13089
- - 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
13090
13852
 
13091
13853
  9.2.1
13092
13854
 
@@ -13096,7 +13858,7 @@ const result = piped(
13096
13858
 
13097
13859
  - `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)
13098
13860
 
13099
- - 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
13100
13862
 
13101
13863
  9.1.1
13102
13864
 
@@ -13172,7 +13934,7 @@ Breaking change in TS definitions of `lenses` as now they are synced to `Ramda`
13172
13934
 
13173
13935
  - Fix cannot compare errors in `Deno` with `R.equals` - [Issue #704](https://github.com/selfrefactor/rambda/issues/704).
13174
13936
 
13175
- - Fix cannot compare `BigInt` with `R.equals`
13937
+ - Fix cannot compare `BigInt` with `R.equals`
13176
13938
 
13177
13939
  8.3.0
13178
13940
 
@@ -13256,7 +14018,7 @@ Add the following methods:
13256
14018
 
13257
14019
  7.2.1
13258
14020
 
13259
- - 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.
13260
14022
 
13261
14023
  - Drop support for `Wallaby` as per [https://github.com/wallabyjs/public/issues/3037](https://github.com/wallabyjs/public/issues/3037)
13262
14024
 
@@ -13350,11 +14112,11 @@ There are several other changes in `@types/ramda` as stated in [this comment](ht
13350
14112
 
13351
14113
  -- R.toUpper
13352
14114
 
13353
- - 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`.
13354
14116
 
13355
14117
  - Add `R.apply`, `R.bind` and `R.unapply`
13356
14118
 
13357
- - `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.
13358
14120
 
13359
14121
  - Remove unused typing for `R.chain`.
13360
14122
 
@@ -13382,7 +14144,7 @@ There are several other changes in `@types/ramda` as stated in [this comment](ht
13382
14144
 
13383
14145
  - Incorrect benchmarks for `R.pipe/R.compose` - [Issue #608](https://github.com/selfrefactor/rambda/issues/608)
13384
14146
 
13385
- - 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)
13386
14148
 
13387
14149
  6.9.0
13388
14150
 
@@ -13397,7 +14159,7 @@ Fixing `R.uniq` was done by improving `R.indexOf` which has performance implicat
13397
14159
  - R.symmetricDifference
13398
14160
  - R.union
13399
14161
 
13400
- - 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.
13401
14163
 
13402
14164
  6.8.3
13403
14165
 
@@ -13482,25 +14244,25 @@ Fix wrong versions in changelog
13482
14244
 
13483
14245
  > Most influential contributors(in alphabetical order)
13484
14246
 
13485
- - ![farwayer avatar](https://avatars.githubusercontent.com/farwayer) [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;
14247
+ - [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;
13486
14248
 
13487
- - ![thejohnfreeman avatar](https://avatars.githubusercontent.com/thejohnfreeman) [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;
14249
+ - [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;
13488
14250
 
13489
- - ![peeja avatar](https://avatars.githubusercontent.com/peeja) [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation
14251
+ - [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation
13490
14252
 
13491
- - ![helmuthdu avatar](https://avatars.githubusercontent.com/helmuthdu) [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;
14253
+ - [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;
13492
14254
 
13493
- - ![jpgorman avatar](https://avatars.githubusercontent.com/jpgorman) [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;
14255
+ - [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;
13494
14256
 
13495
- - ![ku8ar avatar](https://avatars.githubusercontent.com/ku8ar) [@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;
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;
13496
14258
 
13497
- - ![romgrk avatar](https://avatars.githubusercontent.com/romgrk) [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;
14259
+ - [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;
13498
14260
 
13499
- - ![squidfunk avatar](https://avatars.githubusercontent.com/squidfunk) [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;
14261
+ - [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;
13500
14262
 
13501
- - ![synthet1c avatar](https://avatars.githubusercontent.com/synthet1c) [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;
14263
+ - [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;
13502
14264
 
13503
- - ![vlad-zhukov avatar](https://avatars.githubusercontent.com/vlad-zhukov) [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;
14265
+ - [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;
13504
14266
 
13505
14267
  > Rambda references
13506
14268