rambda 7.3.0 → 7.5.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
@@ -9,6 +9,7 @@
9
9
  ![Library size](https://img.shields.io/bundlephobia/minzip/rambda)
10
10
  [![install size](https://packagephobia.com/badge?p=rambda)](https://packagephobia.com/result?p=rambda)
11
11
  [![nest badge](https://nest.land/badge.svg)](https://nest.land/package/rambda)
12
+ [![HitCount](https://hits.dwyl.com/selfrefactor/rambda.svg?style=flat-square)](http://hits.dwyl.com/selfrefactor/rambda)
12
13
 
13
14
  ## ❯ Example use
14
15
 
@@ -64,17 +65,7 @@ Ramda.add(1)('foo') // => will not trigger warning in VSCode
64
65
 
65
66
  The size of a library affects not only the build bundle size but also the dev bundle size and build time. This is important advantage, expecially for big projects.
66
67
 
67
- ### Tree-shaking
68
-
69
- Currently **Rambda** is more tree-shakable than **Ramda** - proven in the following [repo](https://github.com/selfrefactor/rambda-tree-shaking).
70
-
71
- The repo holds two `Angular9` applications: one with small example code of *Ramda* and the other - same code but with *Rambda* as import library.
72
-
73
- The test shows that **Rambda** bundle size is **2 MB** less than its **Ramda** counterpart.
74
-
75
- There is also [Webpack/Rollup/Parcel/Esbuild tree-shaking example including several libraries](https://github.com/mischnic/tree-shaking-example) including `Ramda`, `Rambda` and `Rambdax`.
76
-
77
- > actually tree-shaking is the initial reason for creation of `Rambda`
68
+ <!-- ### Tree-shaking -->
78
69
 
79
70
  ### Dot notation for `R.path`, `R.paths`, `R.assocPath` and `R.lensPath`
80
71
 
@@ -111,7 +102,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
111
102
 
112
103
  <details>
113
104
  <summary>
114
- Click to see the full list of 77 Ramda methods not implemented in Rambda
105
+ Click to see the full list of 76 Ramda methods not implemented in Rambda
115
106
  </summary>
116
107
 
117
108
  - __
@@ -184,7 +175,6 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
184
175
  - uncurryN
185
176
  - unfold
186
177
  - unionWith
187
- - unnest
188
178
  - until
189
179
  - useWith
190
180
  - valuesIn
@@ -345,157 +335,10 @@ method | Rambda | Ramda | Lodash
345
335
 
346
336
  ### add
347
337
 
348
- ```typescript
349
-
350
- add(a: number, b: number): number
351
- ```
352
-
353
338
  It adds `a` and `b`.
354
339
 
355
340
  <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.add(2%2C%203)%20%2F%2F%20%3D%3E%20%205">Try this <strong>R.add</strong> example in Rambda REPL</a>
356
341
 
357
- <details>
358
-
359
- <summary>All Typescript definitions</summary>
360
-
361
- ```typescript
362
- add(a: number, b: number): number;
363
- add(a: number): (b: number) => number;
364
- ```
365
-
366
- </details>
367
-
368
- <details>
369
-
370
- <summary><strong>R.add</strong> source</summary>
371
-
372
- ```javascript
373
- export function add(a, b){
374
- if (arguments.length === 1) return _b => add(a, _b)
375
-
376
- return Number(a) + Number(b)
377
- }
378
- ```
379
-
380
- </details>
381
-
382
- <details>
383
-
384
- <summary><strong>Tests</strong></summary>
385
-
386
- ```javascript
387
- import { add as addRamda } from 'ramda'
388
-
389
- import { compareCombinations } from './_internals/testUtils.js'
390
- import { add } from './add.js'
391
-
392
- test('with number', () => {
393
- expect(add(2, 3)).toBe(5)
394
- expect(add(7)(10)).toBe(17)
395
- })
396
-
397
- test('string is bad input', () => {
398
- expect(add('foo', 'bar')).toBeNaN()
399
- })
400
-
401
- test('ramda specs', () => {
402
- expect(add('1', '2')).toBe(3)
403
- expect(add(1, '2')).toBe(3)
404
- expect(add(true, false)).toBe(1)
405
- expect(add(null, null)).toBe(0)
406
- expect(add(undefined, undefined)).toBeNaN()
407
- expect(add(new Date(1), new Date(2))).toBe(3)
408
- })
409
-
410
- const possibleInputs = [
411
- /foo/,
412
- 'foo',
413
- true,
414
- 3,
415
- NaN,
416
- 4,
417
- [],
418
- Promise.resolve(1),
419
- ]
420
-
421
- describe('brute force', () => {
422
- compareCombinations({
423
- fn : add,
424
- fnRamda : addRamda,
425
- firstInput : possibleInputs,
426
- secondInput : possibleInputs,
427
- callback : errorsCounters => {
428
- expect(errorsCounters).toMatchInlineSnapshot(`
429
- Object {
430
- "ERRORS_MESSAGE_MISMATCH": 0,
431
- "ERRORS_TYPE_MISMATCH": 0,
432
- "RESULTS_MISMATCH": 0,
433
- "SHOULD_NOT_THROW": 0,
434
- "SHOULD_THROW": 0,
435
- "TOTAL_TESTS": 64,
436
- }
437
- `)
438
- },
439
- })
440
- })
441
- ```
442
-
443
- </details>
444
-
445
- <details>
446
-
447
- <summary><strong>Typescript</strong> test</summary>
448
-
449
- ```typescript
450
- import {add} from 'rambda'
451
-
452
- describe('R.add', () => {
453
- it('happy', () => {
454
- const result = add(4, 1)
455
-
456
- result // $ExpectType number
457
- })
458
- it('curried', () => {
459
- const result = add(4)(1)
460
-
461
- result // $ExpectType number
462
- })
463
- })
464
- ```
465
-
466
- </details>
467
-
468
- <details>
469
-
470
- <summary>Rambda is fastest. Ramda is 21.52% slower and Lodash is 82.15% slower</summary>
471
-
472
- ```text
473
- const R = require('../../dist/rambda.js')
474
-
475
- const add = [
476
- {
477
- label : 'Rambda',
478
- fn : () => {
479
- R.add(1, 1)
480
- },
481
- },
482
- {
483
- label : 'Ramda',
484
- fn : () => {
485
- Ramda.add(1, 1)
486
- },
487
- },
488
- {
489
- label : 'Lodash',
490
- fn : () => {
491
- _.add(1, 1)
492
- },
493
- },
494
- ]
495
- ```
496
-
497
- </details>
498
-
499
342
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#add)
500
343
 
501
344
  ### adjust
@@ -596,41 +439,6 @@ test('when index is out of bounds', () => {
596
439
 
597
440
  </details>
598
441
 
599
- <details>
600
-
601
- <summary>Rambda is slower than Ramda with 8.48%</summary>
602
-
603
- ```text
604
- const R = require('../../dist/rambda.js')
605
-
606
- const list = [ 0, 1, 2 ]
607
- const fn = x => x + 1
608
- const index = 1
609
-
610
- const adjust = [
611
- {
612
- label : 'Rambda',
613
- fn : () => {
614
- R.adjust(
615
- index, fn, list
616
- )
617
- R.adjust(index, fn)(list)
618
- },
619
- },
620
- {
621
- label : 'Ramda',
622
- fn : () => {
623
- Ramda.adjust(
624
- index, fn, list
625
- )
626
- Ramda.adjust(index, fn)(list)
627
- },
628
- },
629
- ]
630
- ```
631
-
632
- </details>
633
-
634
442
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#adjust)
635
443
 
636
444
  ### all
@@ -727,50 +535,6 @@ describe('all', () => {
727
535
 
728
536
  </details>
729
537
 
730
- <details>
731
-
732
- <summary>Rambda is faster than Ramda with 1.81%</summary>
733
-
734
- ```text
735
- const R = require('../../dist/rambda.js')
736
-
737
- const {
738
- uniqListOfObjects,
739
- uniqListOfStrings,
740
- rangeOfNumbers,
741
- uniqListOfLists,
742
- } = require('./_utils.js')
743
-
744
- const limit = 100
745
-
746
- const modes = [
747
- [ uniqListOfObjects(limit), x => Object.keys(x).length > 2 ],
748
- [ uniqListOfStrings(limit), x => x.length > 0 ],
749
- [ uniqListOfLists(limit), x => x.length > 0 ],
750
- [ rangeOfNumbers(limit), x => x > -1 ],
751
- ]
752
-
753
- const applyBenchmark = (fn, input) => fn(input[ 1 ], input[ 0 ])
754
-
755
- const tests = [
756
- {
757
- label : 'Rambda',
758
- fn : R.all,
759
- },
760
- {
761
- label : 'Ramda',
762
- fn : Ramda.all,
763
- },
764
- ]
765
-
766
- tests,
767
- applyBenchmark,
768
- modes,
769
- }
770
- ```
771
-
772
- </details>
773
-
774
538
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#all)
775
539
 
776
540
  ### allPass
@@ -908,61 +672,6 @@ describe('allPass', () => {
908
672
 
909
673
  </details>
910
674
 
911
- <details>
912
-
913
- <summary>Rambda is faster than Ramda with 91.09%</summary>
914
-
915
- ```text
916
- const R = require('../../dist/rambda.js')
917
-
918
- const { random } = require('rambdax')
919
-
920
- const limit = 100
921
- const min = 10
922
- const max = 1200
923
- function createListOfFunctions(fn, fnLimit){
924
- return Array(fnLimit)
925
- .fill(null)
926
- .map(() => fn())
927
- }
928
-
929
- const modes = [
930
- [
931
- { foo : 1500 },
932
- createListOfFunctions(() => x => Number(x.foo) > random(min, max),
933
- limit),
934
- ],
935
- [
936
- '1500',
937
- createListOfFunctions(() => x => Number(x) > random(min, max), limit),
938
- ],
939
- [
940
- [ 1, 2, 1500 ],
941
- createListOfFunctions(() => x => x[ 2 ] > random(min, max), limit),
942
- ],
943
- [ 1500, createListOfFunctions(() => x => x > random(min, max), limit) ],
944
- ]
945
-
946
- const applyBenchmark = (fn, input) => fn(input[ 1 ])(input[ 0 ])
947
- const tests = [
948
- {
949
- label : 'Rambda',
950
- fn : R.allPass,
951
- },
952
- {
953
- label : 'Ramda',
954
- fn : Ramda.allPass,
955
- },
956
- ]
957
-
958
- tests,
959
- modes,
960
- applyBenchmark,
961
- }
962
- ```
963
-
964
- </details>
965
-
966
675
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#allPass)
967
676
 
968
677
  ### always
@@ -1076,40 +785,6 @@ describe('R.any', () => {
1076
785
 
1077
786
  </details>
1078
787
 
1079
- <details>
1080
-
1081
- <summary>Rambda is fastest. Ramda is 92.87% slower and Lodash is 45.82% slower</summary>
1082
-
1083
- ```text
1084
- const R = require('../../dist/rambda.js')
1085
-
1086
- const input = [ 1, 2, 3, 4 ]
1087
- const fn = val => val > 2
1088
-
1089
- const any = [
1090
- {
1091
- label : 'Rambda',
1092
- fn : () => {
1093
- R.any(fn, input)
1094
- },
1095
- },
1096
- {
1097
- label : 'Ramda',
1098
- fn : () => {
1099
- Ramda.any(fn, input)
1100
- },
1101
- },
1102
- {
1103
- label : 'Lodash.some',
1104
- fn : () => {
1105
- _.some(input, fn)
1106
- },
1107
- },
1108
- ]
1109
- ```
1110
-
1111
- </details>
1112
-
1113
788
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#any)
1114
789
 
1115
790
  ### anyPass
@@ -1260,33 +935,6 @@ describe('anyPass', () => {
1260
935
 
1261
936
  </details>
1262
937
 
1263
- <details>
1264
-
1265
- <summary>Rambda is faster than Ramda with 98.25%</summary>
1266
-
1267
- ```text
1268
- const R = require('../../dist/rambda.js')
1269
-
1270
- const rules = [ x => typeof x === 'boolean', x => x > 20, x => x * 7 < 100 ]
1271
-
1272
- const anyPass = [
1273
- {
1274
- label : 'Rambda',
1275
- fn : () => {
1276
- R.anyPass(rules)(11)
1277
- },
1278
- },
1279
- {
1280
- label : 'Ramda',
1281
- fn : () => {
1282
- Ramda.anyPass(rules)(11)
1283
- },
1284
- },
1285
- ]
1286
- ```
1287
-
1288
- </details>
1289
-
1290
938
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#anyPass)
1291
939
 
1292
940
  ### append
@@ -1383,33 +1031,6 @@ describe('R.append', () => {
1383
1031
 
1384
1032
  </details>
1385
1033
 
1386
- <details>
1387
-
1388
- <summary>Rambda is faster than Ramda with 2.07%</summary>
1389
-
1390
- ```text
1391
- const R = require('../../dist/rambda.js')
1392
-
1393
- const append = [
1394
- {
1395
- label : 'Rambda',
1396
- fn : () => {
1397
- R.append(0)([ 1, 2, 3, 4 ])
1398
- R.append('bar')('foo')
1399
- },
1400
- },
1401
- {
1402
- label : 'Ramda',
1403
- fn : () => {
1404
- Ramda.append(0)([ 1, 2, 3, 4 ])
1405
- Ramda.append('bar')('foo')
1406
- },
1407
- },
1408
- ]
1409
- ```
1410
-
1411
- </details>
1412
-
1413
1034
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#append)
1414
1035
 
1415
1036
  ### apply
@@ -1948,51 +1569,6 @@ describe('applySpec', () => {
1948
1569
 
1949
1570
  </details>
1950
1571
 
1951
- <details>
1952
-
1953
- <summary>Rambda is faster than Ramda with 80.43%</summary>
1954
-
1955
- ```text
1956
- const R = require('../../dist/rambda.js')
1957
-
1958
- const curryN = [
1959
- {
1960
- label : 'Rambda',
1961
- fn : () => {
1962
- const data = {
1963
- a : {
1964
- b : { c : 1 },
1965
- d : 2,
1966
- },
1967
- }
1968
- const spec = {
1969
- c : R.path([ 'a', 'b', 'c' ]),
1970
- d : R.path([ 'a', 'd' ]),
1971
- }
1972
- R.applySpec(spec, data)
1973
- },
1974
- },
1975
- {
1976
- label : 'Ramda',
1977
- fn : () => {
1978
- const data = {
1979
- a : {
1980
- b : { c : 1 },
1981
- d : 2,
1982
- },
1983
- }
1984
- const spec = {
1985
- c : Ramda.path([ 'a', 'b', 'c' ]),
1986
- d : Ramda.path([ 'a', 'd' ]),
1987
- }
1988
- Ramda.applySpec(spec, data)
1989
- },
1990
- },
1991
- ]
1992
- ```
1993
-
1994
- </details>
1995
-
1996
1572
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#applySpec)
1997
1573
 
1998
1574
  ### assoc
@@ -3033,39 +2609,6 @@ describe('R.defaultTo with Ramda spec', () => {
3033
2609
 
3034
2610
  </details>
3035
2611
 
3036
- <details>
3037
-
3038
- <summary>Rambda is faster than Ramda with 48.91%</summary>
3039
-
3040
- ```text
3041
- const R = require('../../dist/rambda.js')
3042
-
3043
- const input = [ null, undefined, 5 ]
3044
-
3045
- const defaultTo = [
3046
- {
3047
- label : 'Rambda',
3048
- fn : () => {
3049
- R.defaultTo(3, input[ 0 ])
3050
- },
3051
- },
3052
- {
3053
- label : 'Ramda',
3054
- fn : () => {
3055
- Ramda.defaultTo(3, input[ 0 ])
3056
- },
3057
- },
3058
- {
3059
- label : 'Rambda with multiple arguments',
3060
- fn : () => {
3061
- R.defaultTo(3, ...input)
3062
- },
3063
- },
3064
- ]
3065
- ```
3066
-
3067
- </details>
3068
-
3069
2612
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#defaultTo)
3070
2613
 
3071
2614
  ### difference
@@ -3079,7 +2622,7 @@ It returns the uniq set of all elements in the first list `a` not contained in t
3079
2622
 
3080
2623
  `R.equals` is used to determine equality.
3081
2624
 
3082
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20a%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20b%20%3D%20%5B%203%2C%204%2C%205%2C%206%20%5D%0A%0Aconst%20result%20%3D%20difference(a%2C%20b)%0A%2F%2F%20%3D%3E%20%5B%201%2C%202%20%5D">Try this <strong>R.difference</strong> example in Rambda REPL</a>
2625
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20a%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20b%20%3D%20%5B%203%2C%204%2C%205%2C%206%20%5D%0A%0Aconst%20result%20%3D%20R.difference(a%2C%20b)%0A%2F%2F%20%3D%3E%20%5B%201%2C%202%20%5D">Try this <strong>R.difference</strong> example in Rambda REPL</a>
3083
2626
 
3084
2627
  <details>
3085
2628
 
@@ -3299,33 +2842,6 @@ describe('R.drop - string', () => {
3299
2842
 
3300
2843
  </details>
3301
2844
 
3302
- <details>
3303
-
3304
- <summary>Rambda is faster than Ramda with 82.35%</summary>
3305
-
3306
- ```text
3307
- const R = require('../../dist/rambda.js')
3308
-
3309
- const input = [ 1, 2, 3, 4 ]
3310
-
3311
- const drop = [
3312
- {
3313
- label : 'Rambda',
3314
- fn : () => {
3315
- R.drop(3, input)
3316
- },
3317
- },
3318
- {
3319
- label : 'Ramda',
3320
- fn : () => {
3321
- Ramda.drop(3, input)
3322
- },
3323
- },
3324
- ]
3325
- ```
3326
-
3327
- </details>
3328
-
3329
2845
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#drop)
3330
2846
 
3331
2847
  ### dropLast
@@ -3443,33 +2959,6 @@ describe('R.dropLast - string', () => {
3443
2959
 
3444
2960
  </details>
3445
2961
 
3446
- <details>
3447
-
3448
- <summary>Rambda is faster than Ramda with 86.74%</summary>
3449
-
3450
- ```text
3451
- const R = require('../../dist/rambda.js')
3452
-
3453
- const input = [ 1, 2, 3, 4 ]
3454
-
3455
- const dropLast = [
3456
- {
3457
- label : 'Rambda',
3458
- fn : () => {
3459
- R.dropLast(3, input)
3460
- },
3461
- },
3462
- {
3463
- label : 'Ramda',
3464
- fn : () => {
3465
- Ramda.dropLast(3, input)
3466
- },
3467
- },
3468
- ]
3469
- ```
3470
-
3471
- </details>
3472
-
3473
2962
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropLast)
3474
2963
 
3475
2964
  ### dropLastWhile
@@ -3561,7 +3050,7 @@ describe('brute force', () => {
3561
3050
  firstInput : possibleLists,
3562
3051
  callback : errorsCounters => {
3563
3052
  expect(errorsCounters).toMatchInlineSnapshot(`
3564
- Object {
3053
+ {
3565
3054
  "ERRORS_MESSAGE_MISMATCH": 0,
3566
3055
  "ERRORS_TYPE_MISMATCH": 0,
3567
3056
  "RESULTS_MISMATCH": 1,
@@ -3871,7 +3360,7 @@ describe('brute force', () => {
3871
3360
  secondInput : possibleIterables,
3872
3361
  callback : errorsCounters => {
3873
3362
  expect(errorsCounters).toMatchInlineSnapshot(`
3874
- Object {
3363
+ {
3875
3364
  "ERRORS_MESSAGE_MISMATCH": 0,
3876
3365
  "ERRORS_TYPE_MISMATCH": 0,
3877
3366
  "RESULTS_MISMATCH": 0,
@@ -4050,18 +3539,6 @@ function parseRegex(maybeRegex){
4050
3539
  return [ true, maybeRegex.toString() ]
4051
3540
  }
4052
3541
 
4053
- function equalsSets(a, b){
4054
- if (a.size !== b.size){
4055
- return false
4056
- }
4057
- const aList = _arrayFromIterator(a.values())
4058
- const bList = _arrayFromIterator(b.values())
4059
-
4060
- const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1)
4061
-
4062
- return filtered.length === 0
4063
- }
4064
-
4065
3542
  export function equals(a, b){
4066
3543
  if (arguments.length === 1) return _b => equals(a, _b)
4067
3544
 
@@ -4470,7 +3947,7 @@ describe('brute force', () => {
4470
3947
  secondInput : possibleInputs,
4471
3948
  callback : errorsCounters => {
4472
3949
  expect(errorsCounters).toMatchInlineSnapshot(`
4473
- Object {
3950
+ {
4474
3951
  "ERRORS_MESSAGE_MISMATCH": 0,
4475
3952
  "ERRORS_TYPE_MISMATCH": 0,
4476
3953
  "RESULTS_MISMATCH": 5,
@@ -4514,43 +3991,6 @@ describe('R.equals', () => {
4514
3991
 
4515
3992
  </details>
4516
3993
 
4517
- <details>
4518
-
4519
- <summary>Lodash is fastest. Rambda is 58.37% slower and Ramda is 96.73% slower</summary>
4520
-
4521
- ```text
4522
- const R = require('../../dist/rambda.js')
4523
-
4524
- const limit = 10000
4525
-
4526
- const strings = Array(limit)
4527
- .fill(null)
4528
- .map(() => Math.floor(Math.random() * 1000))
4529
-
4530
- const equals = [
4531
- {
4532
- label : 'Rambda',
4533
- fn : () => {
4534
- strings.forEach(x => R.equals(x, 'ss'))
4535
- },
4536
- },
4537
- {
4538
- label : 'Ramda',
4539
- fn : () => {
4540
- strings.forEach(x => Ramda.equals(x, 'ss'))
4541
- },
4542
- },
4543
- {
4544
- label : 'Lodash',
4545
- fn : () => {
4546
- strings.forEach(x => _.isEqual(x, 'ss'))
4547
- },
4548
- },
4549
- ]
4550
- ```
4551
-
4552
- </details>
4553
-
4554
3994
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#equals)
4555
3995
 
4556
3996
  ### evolve
@@ -4753,7 +4193,7 @@ describe('brute force', () => {
4753
4193
  firstInput : possibleRules,
4754
4194
  callback : errorsCounters => {
4755
4195
  expect(errorsCounters).toMatchInlineSnapshot(`
4756
- Object {
4196
+ {
4757
4197
  "ERRORS_MESSAGE_MISMATCH": 0,
4758
4198
  "ERRORS_TYPE_MISMATCH": 4,
4759
4199
  "RESULTS_MISMATCH": 0,
@@ -5056,39 +4496,6 @@ describe('R.filter with objects', () => {
5056
4496
 
5057
4497
  </details>
5058
4498
 
5059
- <details>
5060
-
5061
- <summary>Lodash is fastest. Rambda is 6.7% slower and Ramda is 72.03% slower</summary>
5062
-
5063
- ```text
5064
- const R = require('../../dist/rambda.js')
5065
-
5066
- const arr = [ 1, 2, 3, 4 ]
5067
- const fn = x => x > 2
5068
- const filter = [
5069
- {
5070
- label : 'Rambda',
5071
- fn : () => {
5072
- R.filter(fn, arr)
5073
- },
5074
- },
5075
- {
5076
- label : 'Ramda',
5077
- fn : () => {
5078
- Ramda.filter(fn, arr)
5079
- },
5080
- },
5081
- {
5082
- label : 'Lodash',
5083
- fn : () => {
5084
- _.filter(arr, fn)
5085
- },
5086
- },
5087
- ]
5088
- ```
5089
-
5090
- </details>
5091
-
5092
4499
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#filter)
5093
4500
 
5094
4501
  ### find
@@ -5180,47 +4587,13 @@ describe('R.find', () => {
5180
4587
  const predicate = (x: number) => x > 2
5181
4588
  const result = find(predicate, list)
5182
4589
  result // $ExpectType number | undefined
5183
- })
5184
- it('curried', () => {
5185
- const predicate = (x: number) => x > 2
5186
- const result = find(predicate)(list)
5187
- result // $ExpectType number | undefined
5188
- })
5189
- })
5190
- ```
5191
-
5192
- </details>
5193
-
5194
- <details>
5195
-
5196
- <summary>Rambda is fastest. Ramda is 85.14% slower and Lodash is 42.65% slower</summary>
5197
-
5198
- ```text
5199
- const R = require('../../dist/rambda.js')
5200
-
5201
- const fn = x => x > 2
5202
- const list = [ 1, 2, 3, 4 ]
5203
-
5204
- const find = [
5205
- {
5206
- label : 'Rambda',
5207
- fn : () => {
5208
- R.find(fn, list)
5209
- },
5210
- },
5211
- {
5212
- label : 'Ramda',
5213
- fn : () => {
5214
- Ramda.find(fn, list)
5215
- },
5216
- },
5217
- {
5218
- label : 'Lodash',
5219
- fn : () => {
5220
- _.find(list, fn)
5221
- },
5222
- },
5223
- ]
4590
+ })
4591
+ it('curried', () => {
4592
+ const predicate = (x: number) => x > 2
4593
+ const result = find(predicate)(list)
4594
+ result // $ExpectType number | undefined
4595
+ })
4596
+ })
5224
4597
  ```
5225
4598
 
5226
4599
  </details>
@@ -5320,40 +4693,6 @@ describe('R.findIndex', () => {
5320
4693
 
5321
4694
  </details>
5322
4695
 
5323
- <details>
5324
-
5325
- <summary>Rambda is fastest. Ramda is 86.48% slower and Lodash is 72.27% slower</summary>
5326
-
5327
- ```text
5328
- const R = require('../../dist/rambda.js')
5329
-
5330
- const fn = x => x > 2
5331
- const list = [ 1, 2, 3, 4 ]
5332
-
5333
- const findIndex = [
5334
- {
5335
- label : 'Rambda',
5336
- fn : () => {
5337
- R.findIndex(fn, list)
5338
- },
5339
- },
5340
- {
5341
- label : 'Ramda',
5342
- fn : () => {
5343
- Ramda.findIndex(fn, list)
5344
- },
5345
- },
5346
- {
5347
- label : 'Lodash',
5348
- fn : () => {
5349
- _.findIndex(list, fn)
5350
- },
5351
- },
5352
- ]
5353
- ```
5354
-
5355
- </details>
5356
-
5357
4696
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#findIndex)
5358
4697
 
5359
4698
  ### findLast
@@ -5702,47 +5041,6 @@ describe('flatten', () => {
5702
5041
 
5703
5042
  </details>
5704
5043
 
5705
- <details>
5706
-
5707
- <summary>Lodash is fastest. Rambda is 6.56% slower and Ramda is 86.64% slower</summary>
5708
-
5709
- ```text
5710
- const R = require('../../dist/rambda.js')
5711
-
5712
- const { uniqListOfStrings, applyBenchmarkUnary } = require('./_utils.js')
5713
-
5714
- const modes = [
5715
- [ 1, [ 2, [ 3, 4, 6 ] ] ],
5716
- uniqListOfStrings,
5717
- [],
5718
- [{a:[1,2]}, [], [{a:[1,2]}, []]],
5719
- Array(1000).fill([ 1, [ 2, [ 3, 4, 6 ] ] ]),
5720
- Array(1000).fill([[]]),
5721
- ]
5722
-
5723
- const tests = [
5724
- {
5725
- label : 'Rambda',
5726
- fn : R.flatten,
5727
- },
5728
- {
5729
- label : 'Ramda',
5730
- fn : Ramda.flatten,
5731
- },
5732
- {
5733
- label : 'Lodash',
5734
- fn : _.flattenDeep,
5735
- },
5736
- ]
5737
-
5738
- tests,
5739
- applyBenchmark: applyBenchmarkUnary,
5740
- modes,
5741
- }
5742
- ```
5743
-
5744
- </details>
5745
-
5746
5044
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#flatten)
5747
5045
 
5748
5046
  ### flip
@@ -6534,55 +5832,6 @@ describe('R.ifElse', () => {
6534
5832
 
6535
5833
  </details>
6536
5834
 
6537
- <details>
6538
-
6539
- <summary>Rambda is faster than Ramda with 58.56%</summary>
6540
-
6541
- ```text
6542
- const R = require('../../dist/rambda.js')
6543
-
6544
- const condition = R.has('foo')
6545
- const v = function (a){
6546
- return typeof a === 'number'
6547
- }
6548
- const t = function (a){
6549
- return a + 1
6550
- }
6551
- const ifFn = x => R.prop('foo', x).length
6552
- const elseFn = () => false
6553
-
6554
- const ifElse = [
6555
- {
6556
- label : 'Rambda',
6557
- fn : () => {
6558
- const fn = R.ifElse(condition, ifFn)(elseFn)
6559
-
6560
- fn({ foo : 'bar' })
6561
- fn({ fo : 'bar' })
6562
-
6563
- const ifIsNumber = R.ifElse(v)
6564
- ifIsNumber(t, R.identity)(15)
6565
- ifIsNumber(t, R.identity)('hello')
6566
- },
6567
- },
6568
- {
6569
- label : 'Ramda',
6570
- fn : () => {
6571
- const fn = Ramda.ifElse(condition, ifFn)(elseFn)
6572
-
6573
- fn({ foo : 'bar' })
6574
- fn({ fo : 'bar' })
6575
-
6576
- const ifIsNumber = Ramda.ifElse(v)
6577
- ifIsNumber(t, R.identity)(15)
6578
- ifIsNumber(t, R.identity)('hello')
6579
- },
6580
- },
6581
- ]
6582
- ```
6583
-
6584
- </details>
6585
-
6586
5835
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#ifElse)
6587
5836
 
6588
5837
  ### inc
@@ -6733,68 +5982,6 @@ describe('R.includes', () => {
6733
5982
 
6734
5983
  </details>
6735
5984
 
6736
- <details>
6737
-
6738
- <summary>Rambda is faster than Ramda with 84.63%</summary>
6739
-
6740
- ```text
6741
- const R = require('../../dist/rambda.js')
6742
-
6743
- const {
6744
- uniqListOfStrings,
6745
- uniqListOfBooleans,
6746
- uniqListOfObjects,
6747
- uniqListOfLists,
6748
- listOfVariousTypes,
6749
- rangeOfNumbers,
6750
- } = require('./_utils.js')
6751
-
6752
- const limit = 100
6753
- const additionalModes = listOfVariousTypes.map(unknownType => [
6754
- unknownType,
6755
- uniqListOfLists(limit),
6756
- ])
6757
-
6758
- const modes = [
6759
- [ 99, rangeOfNumbers(limit) ],
6760
- [ 200, rangeOfNumbers(limit) ],
6761
- ...additionalModes,
6762
- [ 'zeppelin', uniqListOfStrings(limit) ],
6763
- [ null, uniqListOfBooleans(limit) ],
6764
- [
6765
- {
6766
- foo : true,
6767
- bar : true,
6768
- },
6769
- uniqListOfObjects(limit),
6770
- ],
6771
- [ 1, uniqListOfLists(limit) ],
6772
- [ [ 1 ], uniqListOfLists(limit) ],
6773
- ]
6774
-
6775
- function applyBenchmark(fn, input){
6776
- return fn(input[ 0 ], input[ 1 ])
6777
- }
6778
-
6779
- const tests = [
6780
- {
6781
- label : 'Rambda',
6782
- fn : R.includes,
6783
- },
6784
- {
6785
- label : 'Ramda',
6786
- fn : Ramda.includes,
6787
- },
6788
- ]
6789
-
6790
- tests,
6791
- modes,
6792
- applyBenchmark,
6793
- }
6794
- ```
6795
-
6796
- </details>
6797
-
6798
5985
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#includes)
6799
5986
 
6800
5987
  ### indexBy
@@ -6914,39 +6101,6 @@ describe('R.init', () => {
6914
6101
 
6915
6102
  </details>
6916
6103
 
6917
- <details>
6918
-
6919
- <summary>Rambda is fastest. Ramda is 92.24% slower and Lodash is 13.3% slower</summary>
6920
-
6921
- ```text
6922
- const R = require('../../dist/rambda.js')
6923
-
6924
- const list = [ 1, 2, 3, 4 ]
6925
-
6926
- const init = [
6927
- {
6928
- label : 'Rambda',
6929
- fn : () => {
6930
- R.init(list)
6931
- },
6932
- },
6933
- {
6934
- label : 'Ramda',
6935
- fn : () => {
6936
- Ramda.init(list)
6937
- },
6938
- },
6939
- {
6940
- label : 'Lodash',
6941
- fn : () => {
6942
- _.initial(list)
6943
- },
6944
- },
6945
- ]
6946
- ```
6947
-
6948
- </details>
6949
-
6950
6104
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#init)
6951
6105
 
6952
6106
  ### intersection
@@ -7063,70 +6217,6 @@ describe('R.isEmpty', () => {
7063
6217
 
7064
6218
  </details>
7065
6219
 
7066
- <details>
7067
-
7068
- <summary>Rambda is fastest. Ramda is 97.14% slower and Lodash is 54.99% slower</summary>
7069
-
7070
- ```text
7071
- const R = require('../../dist/rambda.js')
7072
-
7073
- const isEmpty = [
7074
- {
7075
- label : 'Rambda',
7076
- fn : () => {
7077
- R.isEmpty(undefined)
7078
- R.isEmpty('')
7079
- R.isEmpty(null)
7080
- R.isEmpty(' ')
7081
- R.isEmpty(new RegExp(''))
7082
- R.isEmpty([])
7083
- R.isEmpty([ [] ])
7084
- R.isEmpty({})
7085
- R.isEmpty({ x : 0 })
7086
- R.isEmpty(0)
7087
- R.isEmpty(NaN)
7088
- R.isEmpty([ '' ])
7089
- },
7090
- },
7091
- {
7092
- label : 'Ramda',
7093
- fn : () => {
7094
- Ramda.isEmpty(undefined)
7095
- Ramda.isEmpty('')
7096
- Ramda.isEmpty(null)
7097
- Ramda.isEmpty(' ')
7098
- Ramda.isEmpty(new RegExp(''))
7099
- Ramda.isEmpty([])
7100
- Ramda.isEmpty([ [] ])
7101
- Ramda.isEmpty({})
7102
- Ramda.isEmpty({ x : 0 })
7103
- Ramda.isEmpty(0)
7104
- Ramda.isEmpty(NaN)
7105
- Ramda.isEmpty([ '' ])
7106
- },
7107
- },
7108
- {
7109
- label : 'Lodash',
7110
- fn : () => {
7111
- _.isEmpty(undefined)
7112
- _.isEmpty('')
7113
- _.isEmpty(null)
7114
- _.isEmpty(' ')
7115
- _.isEmpty(new RegExp(''))
7116
- _.isEmpty([])
7117
- _.isEmpty([ [] ])
7118
- _.isEmpty({})
7119
- _.isEmpty({ x : 0 })
7120
- _.isEmpty(0)
7121
- _.isEmpty(NaN)
7122
- _.isEmpty([ '' ])
7123
- },
7124
- },
7125
- ]
7126
- ```
7127
-
7128
- </details>
7129
-
7130
6220
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#isEmpty)
7131
6221
 
7132
6222
  ### isNil
@@ -7493,39 +6583,6 @@ describe('R.last', () => {
7493
6583
 
7494
6584
  </details>
7495
6585
 
7496
- <details>
7497
-
7498
- <summary>Rambda is fastest. Ramda is 93.43% slower and Lodash is 5.28% slower</summary>
7499
-
7500
- ```text
7501
- const R = require('../../dist/rambda.js')
7502
-
7503
- const list = [ 1, 2, 3, 4 ]
7504
-
7505
- const last = [
7506
- {
7507
- label : 'Rambda',
7508
- fn : () => {
7509
- R.last(list)
7510
- },
7511
- },
7512
- {
7513
- label : 'Ramda',
7514
- fn : () => {
7515
- Ramda.last(list)
7516
- },
7517
- },
7518
- {
7519
- label : 'Lodash',
7520
- fn : () => {
7521
- _.last(list)
7522
- },
7523
- },
7524
- ]
7525
- ```
7526
-
7527
- </details>
7528
-
7529
6586
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#last)
7530
6587
 
7531
6588
  ### lastIndexOf
@@ -7624,7 +6681,7 @@ describe('brute force', () => {
7624
6681
  secondInput : possibleIterables,
7625
6682
  callback : errorsCounters => {
7626
6683
  expect(errorsCounters).toMatchInlineSnapshot(`
7627
- Object {
6684
+ {
7628
6685
  "ERRORS_MESSAGE_MISMATCH": 0,
7629
6686
  "ERRORS_TYPE_MISMATCH": 34,
7630
6687
  "RESULTS_MISMATCH": 0,
@@ -7663,36 +6720,6 @@ describe('R.lastIndexOf', () => {
7663
6720
 
7664
6721
  </details>
7665
6722
 
7666
- <details>
7667
-
7668
- <summary>Rambda is faster than Ramda with 85.19%</summary>
7669
-
7670
- ```text
7671
- const R = require('../../dist/rambda.js')
7672
-
7673
- const isEven = n => n % 2 === 0
7674
- const arr = [ 1, 3, 5, 7, 9, 11 ]
7675
-
7676
- const lastIndexOf = [
7677
- {
7678
- label : 'Rambda',
7679
- fn : () => {
7680
- R.lastIndexOf(1, [ 1, 2, 3, 1, 2 ])
7681
- R.lastIndexOf(1)([ 1, 2, 3, 1, 2 ])
7682
- },
7683
- },
7684
- {
7685
- label : 'Ramda',
7686
- fn : () => {
7687
- Ramda.lastIndexOf(1, [ 1, 2, 3, 1, 2 ])
7688
- Ramda.lastIndexOf(1)([ 1, 2, 3, 1, 2 ])
7689
- },
7690
- },
7691
- ]
7692
- ```
7693
-
7694
- </details>
7695
-
7696
6723
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lastIndexOf)
7697
6724
 
7698
6725
  ### length
@@ -8390,6 +7417,7 @@ map<T>(fn: Iterator<T, T>, iterable: T[]): T[];
8390
7417
  <summary><strong>R.map</strong> source</summary>
8391
7418
 
8392
7419
  ```javascript
7420
+ import { INCORRECT_ITERABLE_INPUT } from './_internals/constants.js'
8393
7421
  import { isArray } from './_internals/isArray.js'
8394
7422
  import { keys } from './_internals/keys.js'
8395
7423
 
@@ -8449,74 +7477,63 @@ export function map(fn, iterable){
8449
7477
  <summary><strong>Tests</strong></summary>
8450
7478
 
8451
7479
  ```javascript
8452
- import { map as mapRamda } from "ramda";
7480
+ import { map as mapRamda } from 'ramda'
8453
7481
 
8454
- import { map } from "./map.js";
7482
+ import { map } from './map.js'
8455
7483
 
8456
- const double = (x) => x * 2;
7484
+ const double = x => x * 2
8457
7485
 
8458
- describe("with array", () => {
8459
- it("happy", () => {
8460
- expect(map(double, [1, 2, 3])).toEqual([2, 4, 6]);
8461
- });
7486
+ describe('with array', () => {
7487
+ it('happy', () => {
7488
+ expect(map(double, [ 1, 2, 3 ])).toEqual([ 2, 4, 6 ])
7489
+ })
8462
7490
 
8463
- it("curried", () => {
8464
- expect(map(double)([1, 2, 3])).toEqual([2, 4, 6]);
8465
- });
8466
- });
7491
+ it('curried', () => {
7492
+ expect(map(double)([ 1, 2, 3 ])).toEqual([ 2, 4, 6 ])
7493
+ })
7494
+ })
8467
7495
 
8468
- describe("with object", () => {
7496
+ describe('with object', () => {
8469
7497
  const obj = {
8470
- a: 1,
8471
- b: 2,
8472
- };
7498
+ a : 1,
7499
+ b : 2,
7500
+ }
8473
7501
 
8474
- it("happy", () => {
7502
+ it('happy', () => {
8475
7503
  expect(map(double, obj)).toEqual({
8476
- a: 2,
8477
- b: 4,
8478
- });
8479
- });
7504
+ a : 2,
7505
+ b : 4,
7506
+ })
7507
+ })
8480
7508
 
8481
- it("property as second and input object as third argument", () => {
7509
+ it('property as second and input object as third argument', () => {
8482
7510
  const obj = {
8483
- a: 1,
8484
- b: 2,
8485
- };
8486
- const iterator = (val, prop, inputObject) => {
8487
- expect(prop).toBeString();
8488
- expect(inputObject).toEqual(obj);
7511
+ a : 1,
7512
+ b : 2,
7513
+ }
7514
+ const iterator = (
7515
+ val, prop, inputObject
7516
+ ) => {
7517
+ expect(prop).toBeString()
7518
+ expect(inputObject).toEqual(obj)
8489
7519
 
8490
- return val * 2;
8491
- };
7520
+ return val * 2
7521
+ }
8492
7522
 
8493
7523
  expect(map(iterator)(obj)).toEqual({
8494
- a: 2,
8495
- b: 4,
8496
- });
8497
- });
8498
- });
8499
-
8500
- test("bad inputs difference between Ramda and Rambda", () => {
8501
- expect(() => map(double, null)).toThrowErrorMatchingInlineSnapshot(
8502
- '"Incorrect iterable input"',
8503
- "undefined",
8504
- "undefined",
8505
- `undefined`
8506
- );
8507
- expect(() => map(double)(undefined)).toThrowErrorMatchingInlineSnapshot(
8508
- '"Incorrect iterable input"',
8509
- "undefined",
8510
- "undefined",
8511
- `undefined`
8512
- );
8513
- expect(() => mapRamda(double, null)).toThrowErrorMatchingInlineSnapshot(
8514
- "\"Cannot read properties of null (reading 'fantasy-land/map')\""
8515
- );
8516
- expect(() => mapRamda(double, undefined)).toThrowErrorMatchingInlineSnapshot(
8517
- "\"Cannot read properties of undefined (reading 'fantasy-land/map')\""
8518
- );
8519
- });
7524
+ a : 2,
7525
+ b : 4,
7526
+ })
7527
+ })
7528
+ })
7529
+
7530
+ test('bad inputs difference between Ramda and Rambda', () => {
7531
+ expect(() => map(double, null)).toThrowErrorMatchingInlineSnapshot('"Incorrect iterable input"')
7532
+ expect(() => map(double)(undefined)).toThrowErrorMatchingInlineSnapshot('"Incorrect iterable input"')
7533
+ expect(() => mapRamda(double, null)).toThrowErrorMatchingInlineSnapshot('"Cannot read properties of null (reading \'fantasy-land/map\')"')
7534
+ expect(() =>
7535
+ mapRamda(double, undefined)).toThrowErrorMatchingInlineSnapshot('"Cannot read properties of undefined (reading \'fantasy-land/map\')"')
7536
+ })
8520
7537
  ```
8521
7538
 
8522
7539
  </details>
@@ -8594,14 +7611,91 @@ describe('R.map with objects', () => {
8594
7611
  )
8595
7612
  result // $ExpectType Dictionary<string>
8596
7613
  })
8597
- it('iterable with no property argument', () => {
8598
- const result = map<number, string>(
8599
- a => {
8600
- a // $ExpectType number
8601
- return `${a}`
8602
- },
8603
- {a: 1, b: 2}
8604
- )
7614
+ it('iterable with no property argument', () => {
7615
+ const result = map<number, string>(
7616
+ a => {
7617
+ a // $ExpectType number
7618
+ return `${a}`
7619
+ },
7620
+ {a: 1, b: 2}
7621
+ )
7622
+ result // $ExpectType Dictionary<string>
7623
+ })
7624
+ })
7625
+ ```
7626
+
7627
+ </details>
7628
+
7629
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#map)
7630
+
7631
+ ### mapObjIndexed
7632
+
7633
+ ```typescript
7634
+
7635
+ mapObjIndexed<T>(fn: ObjectIterator<T, T>, iterable: Dictionary<T>): Dictionary<T>
7636
+ ```
7637
+
7638
+ It works the same way as `R.map` does for objects. It is added as Ramda also has this method.
7639
+
7640
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20(val%2C%20prop)%20%3D%3E%20%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.map(mapObjIndexed%2C%20Record%3Cstring%2C%20unknown%3E)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D">Try this <strong>R.mapObjIndexed</strong> example in Rambda REPL</a>
7641
+
7642
+ <details>
7643
+
7644
+ <summary>All Typescript definitions</summary>
7645
+
7646
+ ```typescript
7647
+ mapObjIndexed<T>(fn: ObjectIterator<T, T>, iterable: Dictionary<T>): Dictionary<T>;
7648
+ mapObjIndexed<T, U>(fn: ObjectIterator<T, U>, iterable: Dictionary<T>): Dictionary<U>;
7649
+ mapObjIndexed<T>(fn: ObjectIterator<T, T>): (iterable: Dictionary<T>) => Dictionary<T>;
7650
+ mapObjIndexed<T, U>(fn: ObjectIterator<T, U>): (iterable: Dictionary<T>) => Dictionary<U>;
7651
+ ```
7652
+
7653
+ </details>
7654
+
7655
+ <details>
7656
+
7657
+ <summary><strong>Typescript</strong> test</summary>
7658
+
7659
+ ```typescript
7660
+ import {mapObjIndexed} from 'rambda'
7661
+
7662
+ const obj = {a: 1, b: 2, c: 3}
7663
+
7664
+ describe('R.mapObjIndexed', () => {
7665
+ it('without type transform', () => {
7666
+ const result = mapObjIndexed((x, prop, obj) => {
7667
+ x // $ExpectType number
7668
+ prop // $ExpectType string
7669
+ obj // $ExpectType Dictionary<number>
7670
+ return x + 2
7671
+ }, obj)
7672
+ result // $ExpectType Dictionary<number>
7673
+ })
7674
+ it('without type transform - curried', () => {
7675
+ const result = mapObjIndexed<number>((x, prop, obj) => {
7676
+ x // $ExpectType number
7677
+ prop // $ExpectType string
7678
+ obj // $ExpectType Dictionary<number>
7679
+ return x + 2
7680
+ })(obj)
7681
+ result // $ExpectType Dictionary<number>
7682
+ })
7683
+ it('change of type', () => {
7684
+ const result = mapObjIndexed((x, prop, obj) => {
7685
+ x // $ExpectType number
7686
+ prop // $ExpectType string
7687
+ obj // $ExpectType Dictionary<number>
7688
+ return String(x + 2)
7689
+ }, obj)
7690
+ result // $ExpectType Dictionary<string>
7691
+ })
7692
+ it('change of type - curried', () => {
7693
+ const result = mapObjIndexed<number, string>((x, prop, obj) => {
7694
+ x // $ExpectType number
7695
+ prop // $ExpectType string
7696
+ obj // $ExpectType Dictionary<number>
7697
+ return String(x + 2)
7698
+ })(obj)
8605
7699
  result // $ExpectType Dictionary<string>
8606
7700
  })
8607
7701
  })
@@ -8609,47 +7703,6 @@ describe('R.map with objects', () => {
8609
7703
 
8610
7704
  </details>
8611
7705
 
8612
- <details>
8613
-
8614
- <summary>Rambda is fastest. Ramda is 86.6% slower and Lodash is 11.73% slower</summary>
8615
-
8616
- ```text
8617
- const R = require('../../dist/rambda.js')
8618
-
8619
- const arr = [ 1, 2, 3, 4 ]
8620
- const fn = x => x * 2
8621
- const map = [
8622
- {
8623
- label : 'Rambda',
8624
- fn : () => {
8625
- R.map(fn, arr)
8626
- },
8627
- },
8628
- {
8629
- label : 'Ramda',
8630
- fn : () => {
8631
- Ramda.map(fn, arr)
8632
- },
8633
- },
8634
- {
8635
- label : 'Lodash',
8636
- fn : () => {
8637
- _.map(arr, fn)
8638
- },
8639
- },
8640
- ]
8641
- ```
8642
-
8643
- </details>
8644
-
8645
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#map)
8646
-
8647
- ### mapObjIndexed
8648
-
8649
- It works the same way as `R.map` does for objects. It is added as Ramda also has this method.
8650
-
8651
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20(val%2C%20prop)%20%3D%3E%20%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.map(mapObjIndexed%2C%20Record%3Cstring%2C%20unknown%3E)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D">Try this <strong>R.mapObjIndexed</strong> example in Rambda REPL</a>
8652
-
8653
7706
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mapObjIndexed)
8654
7707
 
8655
7708
  ### match
@@ -8743,33 +7796,6 @@ describe('R.match', () => {
8743
7796
 
8744
7797
  </details>
8745
7798
 
8746
- <details>
8747
-
8748
- <summary>Rambda is faster than Ramda with 44.83%</summary>
8749
-
8750
- ```text
8751
- const R = require('../../dist/rambda.js')
8752
-
8753
- const match = [
8754
- {
8755
- label : 'Rambda',
8756
- fn : () => {
8757
- R.match(/a./g)('foo bar baz')
8758
- R.match(/a./g, 'foo bar baz')
8759
- },
8760
- },
8761
- {
8762
- label : 'Ramda',
8763
- fn : () => {
8764
- Ramda.match(/a./g)('foo bar baz')
8765
- Ramda.match(/a./g, 'foo bar baz')
8766
- },
8767
- },
8768
- ]
8769
- ```
8770
-
8771
- </details>
8772
-
8773
7799
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#match)
8774
7800
 
8775
7801
  ### mathMod
@@ -8957,71 +7983,8 @@ describe('R.median', () => {
8957
7983
 
8958
7984
  ### merge
8959
7985
 
8960
- ```typescript
8961
-
8962
- merge<A, B>(target: A, newProps: B): A & B
8963
- export function merge<Output>(target: any): (newProps: any) => Output
8964
- ```
8965
-
8966
7986
  Same as `R.mergeRight`.
8967
7987
 
8968
- <details>
8969
-
8970
- <summary>All Typescript definitions</summary>
8971
-
8972
- ```typescript
8973
- merge<A, B>(target: A, newProps: B): A & B
8974
- merge<Output>(target: any): (newProps: any) => Output;
8975
- ```
8976
-
8977
- </details>
8978
-
8979
- <details>
8980
-
8981
- <summary><strong>R.merge</strong> source</summary>
8982
-
8983
- ```javascript
8984
- export { mergeRight as merge } from './mergeRight.js'
8985
- ```
8986
-
8987
- </details>
8988
-
8989
- <details>
8990
-
8991
- <summary>Rambda is fastest. Ramda is 12.21% slower and Lodash is 55.76% slower</summary>
8992
-
8993
- ```text
8994
- const R = require('../../dist/rambda.js')
8995
-
8996
- const obj = { bar : 'yes' }
8997
- const a = {
8998
- foo : 'bar',
8999
- bar : 'baz',
9000
- }
9001
- const merge = [
9002
- {
9003
- label : 'Rambda',
9004
- fn : () => {
9005
- R.merge(a, obj)
9006
- },
9007
- },
9008
- {
9009
- label : 'Ramda',
9010
- fn : () => {
9011
- Ramda.merge(a, obj)
9012
- },
9013
- },
9014
- {
9015
- label : 'Lodash',
9016
- fn : () => {
9017
- _.merge(a, obj)
9018
- },
9019
- },
9020
- ]
9021
- ```
9022
-
9023
- </details>
9024
-
9025
7988
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#merge)
9026
7989
 
9027
7990
  ### mergeAll
@@ -9184,8 +8147,6 @@ export function mergeDeepRight(target, source){
9184
8147
  <summary><strong>Tests</strong></summary>
9185
8148
 
9186
8149
  ```javascript
9187
- import { mergeDeepRight as mergeDeepRightRamda } from 'ramda'
9188
-
9189
8150
  import { mergeDeepRight } from './mergeDeepRight.js'
9190
8151
 
9191
8152
  const student = {
@@ -9202,6 +8163,23 @@ const teacher = {
9202
8163
  songs : { title : 'Remains the same' },
9203
8164
  }
9204
8165
 
8166
+ test('when merging object with lists inside them', () => {
8167
+ const a = {
8168
+ a : [ 1, 2, 3 ],
8169
+ b : [ 4, 5, 6 ],
8170
+ }
8171
+ const b = {
8172
+ a : [ 7, 8, 9 ],
8173
+ b : [ 10, 11, 12 ],
8174
+ }
8175
+ const result = mergeDeepRight(a, b)
8176
+ const expected = {
8177
+ a : [ 7, 8, 9 ],
8178
+ b : [ 10, 11, 12 ],
8179
+ }
8180
+ expect(result).toEqual(expected)
8181
+ })
8182
+
9205
8183
  test('happy', () => {
9206
8184
  const result = mergeDeepRight(student, teacher)
9207
8185
  const curryResult = mergeDeepRight(student)(teacher)
@@ -9292,9 +8270,9 @@ test('ramda compatible test 3', () => {
9292
8270
  expect(result).toEqual(expected)
9293
8271
  })
9294
8272
 
9295
- test('functions are discarded', () => {
8273
+ test('functions are not discarded', () => {
9296
8274
  const obj = { foo : () => {} }
9297
- expect(mergeDeepRight(obj, {})).toEqual({})
8275
+ expect(typeof mergeDeepRight(obj, {}).foo).toBe('function')
9298
8276
  })
9299
8277
  ```
9300
8278
 
@@ -9426,7 +8404,7 @@ describe('R.mergeLeft', () => {
9426
8404
 
9427
8405
  ### mergeRight
9428
8406
 
9429
- It creates a copy of `target` object with overidden `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
8407
+ It creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
9430
8408
 
9431
8409
  <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20target%20%3D%20%7B%20'foo'%3A%200%2C%20'bar'%3A%201%20%7D%0Aconst%20newProps%20%3D%20%7B%20'foo'%3A%207%20%7D%0A%0Aconst%20result%20%3D%20R.mergeRight(target%2C%20newProps)%0A%2F%2F%20%3D%3E%20%7B%20'foo'%3A%207%2C%20'bar'%3A%201%20%7D">Try this <strong>R.mergeRight</strong> example in Rambda REPL</a>
9432
8410
 
@@ -9742,7 +8720,7 @@ describe('brute force', () => {
9742
8720
  thirdInput : possibleObjects,
9743
8721
  callback : errorsCounters => {
9744
8722
  expect(errorsCounters).toMatchInlineSnapshot(`
9745
- Object {
8723
+ {
9746
8724
  "ERRORS_MESSAGE_MISMATCH": 0,
9747
8725
  "ERRORS_TYPE_MISMATCH": 0,
9748
8726
  "RESULTS_MISMATCH": 0,
@@ -10024,37 +9002,71 @@ describe('R.none', () => {
10024
9002
 
10025
9003
  </details>
10026
9004
 
9005
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#none)
9006
+
9007
+ ### nop
9008
+
9009
+ ```typescript
9010
+
9011
+ nop(): void
9012
+ ```
9013
+
9014
+ It returns `undefined`.
9015
+
9016
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.nop()%0A%2F%2F%20%3D%3E%20undefined">Try this <strong>R.nop</strong> example in Rambda REPL</a>
9017
+
10027
9018
  <details>
10028
9019
 
10029
- <summary>Rambda is faster than Ramda with 96.48%</summary>
9020
+ <summary>All Typescript definitions</summary>
10030
9021
 
10031
- ```text
10032
- const R = require('../../dist/rambda.js')
9022
+ ```typescript
9023
+ nop(): void;
9024
+ ```
10033
9025
 
10034
- const isEven = n => n % 2 === 0
10035
- const arr = [ 1, 3, 5, 7, 9, 11 ]
9026
+ </details>
10036
9027
 
10037
- const none = [
10038
- {
10039
- label : 'Rambda',
10040
- fn : () => {
10041
- R.none(isEven, arr)
10042
- R.none(isEven)(arr)
10043
- },
10044
- },
10045
- {
10046
- label : 'Ramda',
10047
- fn : () => {
10048
- Ramda.none(isEven, arr)
10049
- Ramda.none(isEven)(arr)
10050
- },
10051
- },
10052
- ]
9028
+ <details>
9029
+
9030
+ <summary><strong>R.nop</strong> source</summary>
9031
+
9032
+ ```javascript
9033
+ export function nop(){}
10053
9034
  ```
10054
9035
 
10055
9036
  </details>
10056
9037
 
10057
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#none)
9038
+ <details>
9039
+
9040
+ <summary><strong>Tests</strong></summary>
9041
+
9042
+ ```javascript
9043
+ import { nop } from './nop.js'
9044
+
9045
+ test('call', () => {
9046
+ expect(nop).not.toThrow()
9047
+ })
9048
+ ```
9049
+
9050
+ </details>
9051
+
9052
+ <details>
9053
+
9054
+ <summary><strong>Typescript</strong> test</summary>
9055
+
9056
+ ```typescript
9057
+ import {nop} from 'rambda'
9058
+
9059
+ describe('R.nop', () => {
9060
+ it('call', () => {
9061
+ const result = nop()
9062
+ result // $ExpectType void
9063
+ })
9064
+ })
9065
+ ```
9066
+
9067
+ </details>
9068
+
9069
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#nop)
10058
9070
 
10059
9071
  ### not
10060
9072
 
@@ -10301,7 +9313,7 @@ test('happy', () => {
10301
9313
  <summary><strong>Typescript</strong> test</summary>
10302
9314
 
10303
9315
  ```typescript
10304
- import {of} from 'ramda'
9316
+ import {of} from 'rambda'
10305
9317
 
10306
9318
  const list = [1, 2, 3]
10307
9319
 
@@ -10512,43 +9524,6 @@ describe('R.omit with string as props input', () => {
10512
9524
 
10513
9525
  </details>
10514
9526
 
10515
- <details>
10516
-
10517
- <summary>Rambda is fastest. Ramda is 69.95% slower and Lodash is 97.34% slower</summary>
10518
-
10519
- ```text
10520
- const R = require('../../dist/rambda.js')
10521
-
10522
- const obj = {
10523
- a : 'foo',
10524
- b : 'bar',
10525
- c : 'baz',
10526
- }
10527
- const toOmit = [ 'a', 'c' ]
10528
- const omit = [
10529
- {
10530
- label : 'Rambda',
10531
- fn : () => {
10532
- R.omit(toOmit, obj)
10533
- },
10534
- },
10535
- {
10536
- label : 'Ramda',
10537
- fn : () => {
10538
- Ramda.omit(toOmit, obj)
10539
- },
10540
- },
10541
- {
10542
- label : 'Lodash',
10543
- fn : () => {
10544
- _.omit(obj, toOmit)
10545
- },
10546
- },
10547
- ]
10548
- ```
10549
-
10550
- </details>
10551
-
10552
9527
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#omit)
10553
9528
 
10554
9529
  ### on
@@ -10787,37 +9762,6 @@ test('index lens', () => {
10787
9762
 
10788
9763
  </details>
10789
9764
 
10790
- <details>
10791
-
10792
- <summary>Rambda is faster than Ramda with 56.23%</summary>
10793
-
10794
- ```text
10795
- const R = require('../../dist/rambda.js')
10796
-
10797
- const testObj = { a : 1 }
10798
-
10799
- const last = [
10800
- {
10801
- label : 'Rambda',
10802
- fn : () => {
10803
- R.over(
10804
- R.lensProp('a'), R.inc, testObj
10805
- )
10806
- },
10807
- },
10808
- {
10809
- label : 'Ramda',
10810
- fn : () => {
10811
- Ramda.over(
10812
- Ramda.lensProp('a'), Ramda.inc, testObj
10813
- )
10814
- },
10815
- },
10816
- ]
10817
- ```
10818
-
10819
- </details>
10820
-
10821
9765
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#over)
10822
9766
 
10823
9767
  ### partial
@@ -11351,7 +10295,7 @@ describe('R.partition', () => {
11351
10295
 
11352
10296
  ```typescript
11353
10297
 
11354
- path<Input, T>(pathToSearch: Path, obj: Input): T | undefined
10298
+ path<S, K0 extends keyof S = keyof S>(path: [K0], obj: S): S[K0]
11355
10299
  ```
11356
10300
 
11357
10301
  If `pathToSearch` is `'a.b'` then it will return `1` if `obj` is `{a:{b:1}}`.
@@ -11365,10 +10309,42 @@ It will return `undefined`, if such path is not found.
11365
10309
  <summary>All Typescript definitions</summary>
11366
10310
 
11367
10311
  ```typescript
11368
- path<Input, T>(pathToSearch: Path, obj: Input): T | undefined;
11369
- path<T>(pathToSearch: Path, obj: any): T | undefined;
11370
- path<T>(pathToSearch: Path): (obj: any) => T | undefined;
11371
- path<Input, T>(pathToSearch: Path): (obj: Input) => T | undefined;
10312
+ path<S, K0 extends keyof S = keyof S>(path: [K0], obj: S): S[K0];
10313
+ path<S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0]>(path: [K0, K1], obj: S): S[K0][K1];
10314
+ path<
10315
+ S,
10316
+ K0 extends keyof S = keyof S,
10317
+ K1 extends keyof S[K0] = keyof S[K0],
10318
+ K2 extends keyof S[K0][K1] = keyof S[K0][K1]
10319
+ >(path: [K0, K1, K2], obj: S): S[K0][K1][K2];
10320
+ path<
10321
+ S,
10322
+ K0 extends keyof S = keyof S,
10323
+ K1 extends keyof S[K0] = keyof S[K0],
10324
+ K2 extends keyof S[K0][K1] = keyof S[K0][K1],
10325
+ K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
10326
+ >(path: [K0, K1, K2, K3], obj: S): S[K0][K1][K2][K3];
10327
+ path<
10328
+ S,
10329
+ K0 extends keyof S = keyof S,
10330
+ K1 extends keyof S[K0] = keyof S[K0],
10331
+ K2 extends keyof S[K0][K1] = keyof S[K0][K1],
10332
+ K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
10333
+ K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
10334
+ >(path: [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4];
10335
+ path<
10336
+ S,
10337
+ K0 extends keyof S = keyof S,
10338
+ K1 extends keyof S[K0] = keyof S[K0],
10339
+ K2 extends keyof S[K0][K1] = keyof S[K0][K1],
10340
+ K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
10341
+ K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
10342
+ K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],
10343
+ >(path: [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5];
10344
+ path<T>(pathToSearch: string, obj: any): T | undefined;
10345
+ path<T>(pathToSearch: string): (obj: any) => T | undefined;
10346
+ path<T>(pathToSearch: RamdaPath): (obj: any) => T | undefined;
10347
+ path<T>(pathToSearch: RamdaPath, obj: any): T | undefined;
11372
10348
  ```
11373
10349
 
11374
10350
  </details>
@@ -11457,100 +10433,64 @@ test('null is not a valid path', () => {
11457
10433
  ```typescript
11458
10434
  import {path} from 'rambda'
11459
10435
 
11460
- interface Input {
11461
- a: number,
11462
- b: {
11463
- c: boolean,
11464
- },
11465
- }
11466
-
11467
- describe('R.path', () => {
11468
- it('without specified input type', () => {
11469
- const input = {a: 1, b: {c: true}}
11470
- const result = path<boolean>('a.b.c', input)
11471
- const curriedResult = path<boolean>('a.b.c')(input)
11472
- result // $ExpectType boolean | undefined
11473
- curriedResult // $ExpectType boolean | undefined
11474
- })
10436
+ const input = {a: {b: {c: true}}}
11475
10437
 
10438
+ describe('R.path with string as path', () => {
11476
10439
  it('without specified output type', () => {
11477
- const input = {a: 1, b: {c: true}}
11478
- const result = path('a.b.c', input)
11479
- result // $ExpectType unknown
11480
- })
11481
-
11482
- it('with string as path', () => {
11483
- const input: Input = {a: 1, b: {c: true}}
11484
- const resultA = path<boolean>('a.b.c', input)
11485
- const resultB = path<boolean>('a.b.c')(input)
11486
- resultA // $ExpectType boolean | undefined
11487
- resultB // $ExpectType boolean | undefined
10440
+ // $ExpectType unknown
10441
+ path('a.b.c', input)
10442
+ // $ExpectType unknown
10443
+ path('a.b.c')(input)
11488
10444
  })
11489
- it('with array as path', () => {
11490
- const input: Input = {a: 1, b: {c: true}}
11491
- const resultA = path<boolean>(['a', 'b', 'c'], input)
11492
- const resultB = path<boolean>(['a', 'b', 'c'])(input)
11493
- resultA // $ExpectType boolean | undefined
11494
- resultB // $ExpectType boolean | undefined
10445
+ it('with specified output type', () => {
10446
+ // $ExpectType boolean | undefined
10447
+ path<boolean>('a.b.c', input)
10448
+ // $ExpectType boolean | undefined
10449
+ path<boolean>('a.b.c')(input)
11495
10450
  })
11496
10451
  })
11497
10452
 
11498
- describe('path with specified input', () => {
11499
- it('with string as path', () => {
11500
- const input: Input = {a: 1, b: {c: true}}
11501
- // const wrongInput = { a: 1, b: true }
11502
- // const resultA = path<Input, boolean>('a.b.c', wrongInput)
11503
- const resultA = path<Input, boolean>('a.b.c', input)
11504
- const resultB = path<Input, boolean>('a.b.c')(input)
11505
- resultA // $ExpectType boolean | undefined
11506
- resultB // $ExpectType boolean | undefined
11507
- })
10453
+ describe('R.path with list as path', () => {
11508
10454
  it('with array as path', () => {
11509
- const input: Input = {a: 1, b: {c: true}}
11510
- const resultA = path<Input, boolean>(['a', 'b', 'c'], input)
11511
- const resultB = path<Input, boolean>(['a', 'b', 'c'])(input)
11512
- resultA // $ExpectType boolean | undefined
11513
- resultB // $ExpectType boolean | undefined
10455
+ // $ExpectType boolean
10456
+ path(['a', 'b', 'c'], input)
10457
+ // $ExpectType unknown
10458
+ path(['a', 'b', 'c'])(input)
10459
+ })
10460
+ test('shallow property', () => {
10461
+ // $ExpectType number
10462
+ path(['a'], {a: 1})
10463
+
10464
+ // $ExpectType unknown
10465
+ path(['b'], {a: 1})
10466
+ })
10467
+ test('deep property', () => {
10468
+ const testObject = {a: {b: {c: {d: {e: {f: 1}}}}}}
10469
+ const result = path(['a', 'b', 'c', 'd', 'e', 'f'], testObject)
10470
+ // $ExpectType number
10471
+ result
10472
+ const curriedResult = path(['a', 'b', 'c', 'd', 'e', 'f'])(testObject)
10473
+ // $ExpectType unknown
10474
+ curriedResult
10475
+ })
10476
+ test('issue #668 - path is not correct', () => {
10477
+ const object = {
10478
+ is: {
10479
+ a: 'path',
10480
+ },
10481
+ }
10482
+ const result = path(['is', 'not', 'a'], object)
10483
+ // $ExpectType unknown
10484
+ result
10485
+ const curriedResult = path(['is', 'not', 'a'])(object)
10486
+ // $ExpectType unknown
10487
+ curriedResult
11514
10488
  })
11515
10489
  })
11516
10490
  ```
11517
10491
 
11518
10492
  </details>
11519
10493
 
11520
- <details>
11521
-
11522
- <summary>Lodash is fastest. Rambda is 37.81% slower and Ramda is 77.81% slower</summary>
11523
-
11524
- ```text
11525
- const R = require('../../dist/rambda.js')
11526
-
11527
- const obj = { a : { b : 2 } }
11528
- const pathInput = [ 'a', 'b' ]
11529
-
11530
- const path = [
11531
- {
11532
- label : 'Rambda',
11533
- fn : () => {
11534
- R.path(pathInput, obj)
11535
- },
11536
- },
11537
- {
11538
- label : 'Ramda',
11539
- fn : () => {
11540
- Ramda.path(pathInput, obj)
11541
- },
11542
- },
11543
- {
11544
- label : 'Lodash',
11545
- fn : () => {
11546
- _.get(obj, pathInput)
11547
- },
11548
- },
11549
- ]
11550
- ```
11551
-
11552
- </details>
11553
-
11554
10494
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#path)
11555
10495
 
11556
10496
  ### pathEq
@@ -11979,7 +10919,7 @@ It returns a partial copy of an `input` containing only `propsToPick` properties
11979
10919
 
11980
10920
  `input` can be either an object or an array.
11981
10921
 
11982
- String anotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
10922
+ String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
11983
10923
 
11984
10924
  <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20obj%20%3D%20%7B%0A%20%20a%20%3A%201%2C%0A%20%20b%20%3A%20false%2C%0A%20%20foo%3A%20'cherry'%0A%7D%0Aconst%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20propsToPick%20%3D%20'a%2Cfoo'%0Aconst%20propsToPickList%20%3D%20%5B'a'%2C%20'foo'%5D%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.pick(propsToPick%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick(propsToPickList%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick('a%2Cbar'%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick('bar'%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick(%5B0%2C%203%2C%205%5D%2C%20list)%2C%0A%20%20R.pick('0%2C3%2C5'%2C%20list)%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%7D%2C%0A%20%20%7B%7D%2C%0A%20%20%7B0%3A%201%2C%203%3A%204%7D%2C%0A%20%20%7B0%3A%201%2C%203%3A%204%7D%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.pick</strong> example in Rambda REPL</a>
11985
10925
 
@@ -12106,7 +11046,7 @@ test('works with list as input and number as props - props to pick is a string',
12106
11046
  test('with symbol', () => {
12107
11047
  const symbolProp = Symbol('s')
12108
11048
  expect(pick([ symbolProp ], { [ symbolProp ] : 'a' })).toMatchInlineSnapshot(`
12109
- Object {
11049
+ {
12110
11050
  Symbol(s): "a",
12111
11051
  }
12112
11052
  `)
@@ -12173,50 +11113,13 @@ describe('R.pick with string as props input', () => {
12173
11113
 
12174
11114
  </details>
12175
11115
 
12176
- <details>
12177
-
12178
- <summary>Rambda is fastest. Ramda is 19.07% slower and Lodash is 80.2% slower</summary>
12179
-
12180
- ```text
12181
- const R = require('../../dist/rambda.js')
12182
-
12183
- const obj = {
12184
- a : 'foo',
12185
- b : 'bar',
12186
- c : 'baz',
12187
- }
12188
- const pickInput = [ 'a', 'c' ]
12189
- const pick = [
12190
- {
12191
- label : 'Rambda',
12192
- fn : () => {
12193
- R.pick(pickInput, obj)
12194
- },
12195
- },
12196
- {
12197
- label : 'Ramda',
12198
- fn : () => {
12199
- Ramda.pick(pickInput, obj)
12200
- },
12201
- },
12202
- {
12203
- label : 'Lodash',
12204
- fn : () => {
12205
- _.pick(obj, pickInput)
12206
- },
12207
- },
12208
- ]
12209
- ```
12210
-
12211
- </details>
12212
-
12213
11116
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pick)
12214
11117
 
12215
11118
  ### pickAll
12216
11119
 
12217
11120
  ```typescript
12218
11121
 
12219
- pickAll<T, U>(propsToPick: string[], input: T): U
11122
+ pickAll<T, K extends keyof T>(propsToPicks: K[], input: T): Pick<T, K>
12220
11123
  ```
12221
11124
 
12222
11125
  Same as `R.pick` but it won't skip the missing props, i.e. it will assign them to `undefined`.
@@ -12228,8 +11131,9 @@ Same as `R.pick` but it won't skip the missing props, i.e. it will assign them t
12228
11131
  <summary>All Typescript definitions</summary>
12229
11132
 
12230
11133
  ```typescript
12231
- pickAll<T, U>(propsToPick: string[], input: T): U;
12232
- pickAll<T, U>(propsToPick: string[]): (input: T) => U;
11134
+ pickAll<T, K extends keyof T>(propsToPicks: K[], input: T): Pick<T, K>;
11135
+ pickAll<T, U>(propsToPicks: string[], input: T): U;
11136
+ pickAll(propsToPicks: string[]): <T, U>(input: T) => U;
12233
11137
  pickAll<T, U>(propsToPick: string, input: T): U;
12234
11138
  pickAll<T, U>(propsToPick: string): (input: T) => U;
12235
11139
  ```
@@ -12334,19 +11238,15 @@ const input = {a: 'foo', b: 2, c: 3, d: 4}
12334
11238
  describe('R.pickAll with array as props input', () => {
12335
11239
  it('without passing type', () => {
12336
11240
  const result = pickAll(['a', 'c'], input)
12337
- result // $ExpectType unknown
11241
+ result.a // $ExpectType string
11242
+ result.c // $ExpectType number
12338
11243
  })
12339
11244
  it('without passing type + curry', () => {
12340
11245
  const result = pickAll(['a', 'c'])(input)
12341
11246
  result // $ExpectType unknown
12342
11247
  })
12343
- it('explicitly passing types', () => {
12344
- const result = pickAll<Input, Output>(['a', 'c'], input)
12345
- result.a // $ExpectType string | undefined
12346
- result.c // $ExpectType number | undefined
12347
- })
12348
- it('explicitly passing types + curry', () => {
12349
- const result = pickAll<Input, Output>(['a', 'c'])(input)
11248
+ it('explicitly passing types', () => {
11249
+ const result = pickAll<Input, Output>(['a', 'c'], input)
12350
11250
  result.a // $ExpectType string | undefined
12351
11251
  result.c // $ExpectType number | undefined
12352
11252
  })
@@ -12665,7 +11565,7 @@ describe('R.product', () => {
12665
11565
 
12666
11566
  ```typescript
12667
11567
 
12668
- prop<P extends keyof O, O>(propToFind: P, obj: O): O[P]
11568
+ prop<P extends keyof never, T>(propToFind: P, value: T): Prop<T, P>
12669
11569
  ```
12670
11570
 
12671
11571
  It returns the value of property `propToFind` in `obj`.
@@ -12679,10 +11579,17 @@ If there is no such property, it returns `undefined`.
12679
11579
  <summary>All Typescript definitions</summary>
12680
11580
 
12681
11581
  ```typescript
12682
- prop<P extends keyof O, O>(propToFind: P, obj: O): O[P];
12683
- prop<P extends keyof O, O>(propToFind: P): (obj: O) => O[P];
12684
- prop<P extends string | number>(propToFind: P): <T>(obj: Record<P, T>) => T;
12685
- prop<P extends string | number, T>(propToFind: P): (obj: Record<P, T>) => T;
11582
+ prop<P extends keyof never, T>(propToFind: P, value: T): Prop<T, P>;
11583
+ prop<P extends keyof never>(propToFind: P): {
11584
+ <T>(value: Record<P, T>): T;
11585
+ <T>(value: T): Prop<T, P>;
11586
+ };
11587
+ prop<P extends keyof T, T>(propToFind: P): {
11588
+ (value: T): Prop<T, P>;
11589
+ };
11590
+ prop<P extends keyof never, T>(propToFind: P): {
11591
+ (value: Record<P, T>): T;
11592
+ };
12686
11593
  ```
12687
11594
 
12688
11595
  </details>
@@ -12730,7 +11637,10 @@ import {pipe, prop} from 'rambda'
12730
11637
 
12731
11638
  describe('R.prop', () => {
12732
11639
  const obj = {a: 1, b: 'foo'}
12733
- interface Something {a?: number, b?: string}
11640
+ interface Something {
11641
+ a?: number,
11642
+ b?: string,
11643
+ }
12734
11644
 
12735
11645
  it('issue #553', () => {
12736
11646
  const result = prop('e', {e: 'test1', d: 'test2'})
@@ -12757,7 +11667,7 @@ describe('R.prop', () => {
12757
11667
  it('curried with implicit object type', () => {
12758
11668
  const result = pipe(value => value as Something, prop('b'))(obj)
12759
11669
 
12760
- result // $ExpectType string | undefined
11670
+ result // $ExpectType undefined
12761
11671
  })
12762
11672
  it('curried with explicit result type', () => {
12763
11673
  const result = prop<'b', string>('b')(obj)
@@ -12784,39 +11694,6 @@ describe('with number as prop', () => {
12784
11694
 
12785
11695
  </details>
12786
11696
 
12787
- <details>
12788
-
12789
- <summary>Rambda is faster than Ramda with 87.95%</summary>
12790
-
12791
- ```text
12792
- const R = require('../../dist/rambda.js')
12793
-
12794
- const obj = {
12795
- a : { c : 2 },
12796
- b : 1,
12797
- }
12798
- const propInput = 'b'
12799
-
12800
- const prop = [
12801
- {
12802
- label : 'Rambda',
12803
- fn : () => {
12804
- R.prop(propInput, obj)
12805
- R.prop(propInput)(obj)
12806
- },
12807
- },
12808
- {
12809
- label : 'Ramda',
12810
- fn : () => {
12811
- Ramda.prop(propInput, obj)
12812
- Ramda.prop(propInput)(obj)
12813
- },
12814
- },
12815
- ]
12816
- ```
12817
-
12818
- </details>
12819
-
12820
11697
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#prop)
12821
11698
 
12822
11699
  ### propEq
@@ -12952,50 +11829,6 @@ describe('R.propEq', () => {
12952
11829
 
12953
11830
  </details>
12954
11831
 
12955
- <details>
12956
-
12957
- <summary>Rambda is faster than Ramda with 91.92%</summary>
12958
-
12959
- ```text
12960
- const R = require('../../dist/rambda.js')
12961
-
12962
- const obj = {
12963
- a : { c : 2 },
12964
- b : 1,
12965
- }
12966
- const propInput = 'b'
12967
- const expected = { c : 2 }
12968
-
12969
- const propEq = [
12970
- {
12971
- label : 'Rambda',
12972
- fn : () => {
12973
- R.propEq('a')(expected)(obj)
12974
-
12975
- R.propEq('a', expected)(obj)
12976
-
12977
- R.propEq(
12978
- 'a', expected, obj
12979
- )
12980
- },
12981
- },
12982
- {
12983
- label : 'Ramda',
12984
- fn : () => {
12985
- Ramda.propEq('a')(expected)(obj)
12986
-
12987
- Ramda.propEq('a', expected)(obj)
12988
-
12989
- Ramda.propEq(
12990
- 'a', expected, obj
12991
- )
12992
- },
12993
- },
12994
- ]
12995
- ```
12996
-
12997
- </details>
12998
-
12999
11832
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#propEq)
13000
11833
 
13001
11834
  ### propIs
@@ -13511,39 +12344,6 @@ describe('R.range', () => {
13511
12344
 
13512
12345
  </details>
13513
12346
 
13514
- <details>
13515
-
13516
- <summary>Rambda is fastest. Ramda is 61.8% slower and Lodash is 57.44% slower</summary>
13517
-
13518
- ```text
13519
- const R = require('../../dist/rambda.js')
13520
-
13521
- const start = 12
13522
- const end = 22
13523
- const range = [
13524
- {
13525
- label : 'Rambda',
13526
- fn : () => {
13527
- R.range(start, end)
13528
- },
13529
- },
13530
- {
13531
- label : 'Ramda',
13532
- fn : () => {
13533
- Ramda.range(start, end)
13534
- },
13535
- },
13536
- {
13537
- label : 'Lodash',
13538
- fn : () => {
13539
- _.range(start, end)
13540
- },
13541
- },
13542
- ]
13543
- ```
13544
-
13545
- </details>
13546
-
13547
12347
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#range)
13548
12348
 
13549
12349
  ### reduce
@@ -13754,40 +12554,6 @@ describe('R.repeat', () => {
13754
12554
 
13755
12555
  </details>
13756
12556
 
13757
- <details>
13758
-
13759
- <summary>Lodash is fastest. Rambda is 48.57% slower and Ramda is 68.98% slower</summary>
13760
-
13761
- ```text
13762
- const R = require('../../dist/rambda.js')
13763
-
13764
- const num = 10
13765
- const str = 'foo'
13766
-
13767
- const repeat = [
13768
- {
13769
- label : 'Rambda',
13770
- fn : () => {
13771
- R.repeat(str, num)
13772
- },
13773
- },
13774
- {
13775
- label : 'Ramda',
13776
- fn : () => {
13777
- Ramda.repeat(str, num)
13778
- },
13779
- },
13780
- {
13781
- label : 'Lodash',
13782
- fn : () => {
13783
- _.repeat(str, num)
13784
- },
13785
- },
13786
- ]
13787
- ```
13788
-
13789
- </details>
13790
-
13791
12557
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#repeat)
13792
12558
 
13793
12559
  ### replace
@@ -13898,43 +12664,6 @@ describe('R.replace - curried', () => {
13898
12664
 
13899
12665
  </details>
13900
12666
 
13901
- <details>
13902
-
13903
- <summary>Lodash is fastest. Rambda is 33.45% slower and Ramda is 33.99% slower</summary>
13904
-
13905
- ```text
13906
- const R = require('../../dist/rambda.js')
13907
-
13908
- const replace = [
13909
- {
13910
- label : 'Rambda',
13911
- fn : () => {
13912
- R.replace(
13913
- /\s/g, '|', 'foo bar baz'
13914
- )
13915
- },
13916
- },
13917
- {
13918
- label : 'Ramda',
13919
- fn : () => {
13920
- Ramda.replace(
13921
- /\s/g, '|', 'foo bar baz'
13922
- )
13923
- },
13924
- },
13925
- {
13926
- label : 'Lodash',
13927
- fn : () => {
13928
- _.replace(
13929
- 'foo bar baz', /\s/g, '|'
13930
- )
13931
- },
13932
- },
13933
- ]
13934
- ```
13935
-
13936
- </details>
13937
-
13938
12667
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#replace)
13939
12668
 
13940
12669
  ### reverse
@@ -14129,37 +12858,6 @@ test('index lens', () => {
14129
12858
 
14130
12859
  </details>
14131
12860
 
14132
- <details>
14133
-
14134
- <summary>Rambda is faster than Ramda with 50.35%</summary>
14135
-
14136
- ```text
14137
- const R = require('../../dist/rambda.js')
14138
-
14139
- const testObj = { a : 1 }
14140
-
14141
- const last = [
14142
- {
14143
- label : 'Rambda',
14144
- fn : () => {
14145
- R.set(
14146
- R.lensProp('a'), 2, testObj
14147
- )
14148
- },
14149
- },
14150
- {
14151
- label : 'Ramda',
14152
- fn : () => {
14153
- Ramda.set(
14154
- Ramda.lensProp('a'), 2, testObj
14155
- )
14156
- },
14157
- },
14158
- ]
14159
- ```
14160
-
14161
- </details>
14162
-
14163
12861
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#set)
14164
12862
 
14165
12863
  ### slice
@@ -14352,36 +13050,6 @@ describe('R.sort', () => {
14352
13050
 
14353
13051
  </details>
14354
13052
 
14355
- <details>
14356
-
14357
- <summary>Rambda is faster than Ramda with 40.23%</summary>
14358
-
14359
- ```text
14360
- const R = require('../../dist/rambda.js')
14361
-
14362
- const list = [ 'foo', 'bar', 'baz' ]
14363
- const fn = (a, b) => a > b ? -1 : 1
14364
-
14365
- const replace = [
14366
- {
14367
- label : 'Rambda',
14368
- fn : () => {
14369
- R.sort(fn, list)
14370
- R.sort(fn)(list)
14371
- },
14372
- },
14373
- {
14374
- label : 'Ramda',
14375
- fn : () => {
14376
- Ramda.sort(fn, list)
14377
- Ramda.sort(fn)(list)
14378
- },
14379
- },
14380
- ]
14381
- ```
14382
-
14383
- </details>
14384
-
14385
13053
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sort)
14386
13054
 
14387
13055
  ### sortBy
@@ -14528,40 +13196,6 @@ describe('R.sortBy', () => {
14528
13196
 
14529
13197
  </details>
14530
13198
 
14531
- <details>
14532
-
14533
- <summary>Rambda is fastest. Ramda is 25.29% slower and Lodash is 56.88% slower</summary>
14534
-
14535
- ```text
14536
- const R = require('../../dist/rambda.js')
14537
-
14538
- const list = [ { a : 2 }, { a : 1 }, { a : 0 } ]
14539
- const fn = x => x.a
14540
-
14541
- const replace = [
14542
- {
14543
- label : 'Rambda',
14544
- fn : () => {
14545
- R.sortBy(fn, list)
14546
- },
14547
- },
14548
- {
14549
- label : 'Ramda',
14550
- fn : () => {
14551
- Ramda.sortBy(fn, list)
14552
- },
14553
- },
14554
- {
14555
- label : 'Lodash',
14556
- fn : () => {
14557
- _.sortBy(list, fn)
14558
- },
14559
- },
14560
- ]
14561
- ```
14562
-
14563
- </details>
14564
-
14565
13199
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sortBy)
14566
13200
 
14567
13201
  ### split
@@ -14648,40 +13282,6 @@ describe('R.split', () => {
14648
13282
 
14649
13283
  </details>
14650
13284
 
14651
- <details>
14652
-
14653
- <summary>Rambda is fastest. Ramda is 55.37% slower and Lodash is 17.64% slower</summary>
14654
-
14655
- ```text
14656
- const R = require('../../dist/rambda.js')
14657
-
14658
- const str = 'foo|bar|baz'
14659
- const sep = '|'
14660
-
14661
- const split = [
14662
- {
14663
- label : 'Rambda',
14664
- fn : () => {
14665
- R.split(sep, str)
14666
- },
14667
- },
14668
- {
14669
- label : 'Ramda',
14670
- fn : () => {
14671
- Ramda.split(sep, str)
14672
- },
14673
- },
14674
- {
14675
- label : 'Lodash',
14676
- fn : () => {
14677
- _.split(str, sep)
14678
- },
14679
- },
14680
- ]
14681
- ```
14682
-
14683
- </details>
14684
-
14685
13285
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#split)
14686
13286
 
14687
13287
  ### splitAt
@@ -14813,7 +13413,7 @@ test('with bad inputs', () => {
14813
13413
  <summary><strong>Typescript</strong> test</summary>
14814
13414
 
14815
13415
  ```typescript
14816
- import {splitAt} from 'ramda'
13416
+ import {splitAt} from 'rambda'
14817
13417
 
14818
13418
  const index = 1
14819
13419
  const str = 'foo'
@@ -14953,33 +13553,6 @@ describe('R.splitEvery', () => {
14953
13553
 
14954
13554
  </details>
14955
13555
 
14956
- <details>
14957
-
14958
- <summary>Rambda is faster than Ramda with 71.98%</summary>
14959
-
14960
- ```text
14961
- const R = require('../../dist/rambda.js')
14962
-
14963
- const list = [ 1, 2, 3, 4, 5, 6, 7 ]
14964
-
14965
- const splitEvery = [
14966
- {
14967
- label : 'Rambda',
14968
- fn : () => {
14969
- R.splitEvery(3, list)
14970
- },
14971
- },
14972
- {
14973
- label : 'Ramda',
14974
- fn : () => {
14975
- Ramda.splitEvery(3, list)
14976
- },
14977
- },
14978
- ]
14979
- ```
14980
-
14981
- </details>
14982
-
14983
13556
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#splitEvery)
14984
13557
 
14985
13558
  ### splitWhen
@@ -15201,7 +13774,7 @@ describe('brute force', () => {
15201
13774
  secondInput : possibleIterables,
15202
13775
  callback : errorsCounters => {
15203
13776
  expect(errorsCounters).toMatchInlineSnapshot(`
15204
- Object {
13777
+ {
15205
13778
  "ERRORS_MESSAGE_MISMATCH": 0,
15206
13779
  "ERRORS_TYPE_MISMATCH": 0,
15207
13780
  "RESULTS_MISMATCH": 0,
@@ -15658,40 +14231,6 @@ describe('R.take - string', () => {
15658
14231
 
15659
14232
  </details>
15660
14233
 
15661
- <details>
15662
-
15663
- <summary>Rambda is fastest. Ramda is 91.96% slower and Lodash is 4.72% slower</summary>
15664
-
15665
- ```text
15666
- const R = require('../../dist/rambda.js')
15667
-
15668
- const list = [ 1, 2, 3, 4 ]
15669
- const num = 2
15670
-
15671
- const take = [
15672
- {
15673
- label : 'Rambda',
15674
- fn : () => {
15675
- R.take(num, list)
15676
- },
15677
- },
15678
- {
15679
- label : 'Ramda',
15680
- fn : () => {
15681
- Ramda.take(num, list)
15682
- },
15683
- },
15684
- {
15685
- label : 'Lodash',
15686
- fn : () => {
15687
- _.take(list, num)
15688
- },
15689
- },
15690
- ]
15691
- ```
15692
-
15693
- </details>
15694
-
15695
14234
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#take)
15696
14235
 
15697
14236
  ### takeLast
@@ -15821,40 +14360,6 @@ describe('R.takeLast - string', () => {
15821
14360
 
15822
14361
  </details>
15823
14362
 
15824
- <details>
15825
-
15826
- <summary>Rambda is fastest. Ramda is 93.39% slower and Lodash is 19.22% slower</summary>
15827
-
15828
- ```text
15829
- const R = require('../../dist/rambda.js')
15830
-
15831
- const list = [ 1, 2, 3, 4 ]
15832
- const num = 2
15833
-
15834
- const takeLast = [
15835
- {
15836
- label : 'Rambda',
15837
- fn : () => {
15838
- R.takeLast(num, list)
15839
- },
15840
- },
15841
- {
15842
- label : 'Ramda',
15843
- fn : () => {
15844
- Ramda.takeLast(num, list)
15845
- },
15846
- },
15847
- {
15848
- label : 'Lodash',
15849
- fn : () => {
15850
- _.takeRight(list, num)
15851
- },
15852
- },
15853
- ]
15854
- ```
15855
-
15856
- </details>
15857
-
15858
14363
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#takeLast)
15859
14364
 
15860
14365
  ### takeLastWhile
@@ -15891,17 +14396,16 @@ export function takeLastWhile(predicate, input){
15891
14396
  return _input => takeLastWhile(predicate, _input)
15892
14397
  }
15893
14398
  if (input.length === 0) return input
15894
- let found = false
14399
+
15895
14400
  const toReturn = []
15896
14401
  let counter = input.length
15897
14402
 
15898
- while (!found || counter === 0){
15899
- counter--
15900
- if (predicate(input[ counter ]) === false){
15901
- found = true
15902
- } else if (!found){
15903
- toReturn.push(input[ counter ])
14403
+ while (counter){
14404
+ const item = input[ --counter ]
14405
+ if (!predicate(item)){
14406
+ break
15904
14407
  }
14408
+ toReturn.push(item)
15905
14409
  }
15906
14410
 
15907
14411
  return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')
@@ -15927,13 +14431,13 @@ test('happy', () => {
15927
14431
  })
15928
14432
 
15929
14433
  test('predicate is always true', () => {
15930
- const predicate = x => x > 0
14434
+ const predicate = () => true
15931
14435
  const result = takeLastWhile(predicate)(list)
15932
14436
  expect(result).toEqual(list)
15933
14437
  })
15934
14438
 
15935
14439
  test('predicate is always false', () => {
15936
- const predicate = x => x < 0
14440
+ const predicate = () => false
15937
14441
  const result = takeLastWhile(predicate, list)
15938
14442
  expect(result).toEqual([])
15939
14443
  })
@@ -15999,7 +14503,7 @@ tap<T>(fn: (x: T) => void, input: T): T
15999
14503
 
16000
14504
  It applies function `fn` to input `x` and returns `x`.
16001
14505
 
16002
- One use case is debuging in the middle of `R.compose`.
14506
+ One use case is debugging in the middle of `R.compose`.
16003
14507
 
16004
14508
  <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.compose(%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)(list)%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>
16005
14509
 
@@ -16103,7 +14607,7 @@ export function test(pattern, str){
16103
14607
  if (arguments.length === 1) return _str => test(pattern, _str)
16104
14608
 
16105
14609
  if (typeof pattern === 'string'){
16106
- throw new TypeError(`‘test requires a value of type RegExp as its first argument; received "${ pattern }"`)
14610
+ throw new TypeError(`R.test requires a value of type RegExp as its first argument; received "${ pattern }"`)
16107
14611
  }
16108
14612
 
16109
14613
  return str.search(pattern) !== -1
@@ -16126,7 +14630,7 @@ test('happy', () => {
16126
14630
  })
16127
14631
 
16128
14632
  test('throws if first argument is not regex', () => {
16129
- expect(() => testMethod('foo', 'bar')).toThrowErrorMatchingInlineSnapshot('"test requires a value of type RegExp as its first argument; received \\"foo\\""')
14633
+ expect(() => testMethod('foo', 'bar')).toThrowErrorMatchingInlineSnapshot('"R.test requires a value of type RegExp as its first argument; received "foo""')
16130
14634
  })
16131
14635
  ```
16132
14636
 
@@ -16146,41 +14650,14 @@ describe('R.test', () => {
16146
14650
  it('happy', () => {
16147
14651
  const result = test(regex, input)
16148
14652
 
16149
- result // $ExpectType boolean
16150
- })
16151
- it('curried', () => {
16152
- const result = test(regex)(input)
16153
-
16154
- result // $ExpectType boolean
16155
- })
16156
- })
16157
- ```
16158
-
16159
- </details>
16160
-
16161
- <details>
16162
-
16163
- <summary>Rambda is faster than Ramda with 82.34%</summary>
16164
-
16165
- ```text
16166
- const R = require('../../dist/rambda.js')
14653
+ result // $ExpectType boolean
14654
+ })
14655
+ it('curried', () => {
14656
+ const result = test(regex)(input)
16167
14657
 
16168
- const test = [
16169
- {
16170
- label : 'Rambda',
16171
- fn : () => {
16172
- R.test(/\s/g, 'x y z')
16173
- R.test(/\s/g)('x y z')
16174
- },
16175
- },
16176
- {
16177
- label : 'Ramda',
16178
- fn : () => {
16179
- Ramda.test(/\s/g, 'x y z')
16180
- Ramda.test(/\s/g)('x y z')
16181
- },
16182
- },
16183
- ]
14658
+ result // $ExpectType boolean
14659
+ })
14660
+ })
16184
14661
  ```
16185
14662
 
16186
14663
  </details>
@@ -16681,277 +15158,10 @@ It returns function that runs `fn` in `try/catch` block. If there was an error,
16681
15158
 
16682
15159
  ### type
16683
15160
 
16684
- ```typescript
16685
-
16686
- type(x: any): RambdaTypes
16687
- ```
16688
-
16689
15161
  It accepts any input and it returns its type.
16690
15162
 
16691
15163
  <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.type(()%20%3D%3E%20%7B%7D)%20%2F%2F%20%3D%3E%20'Function'%0AR.type(async%20()%20%3D%3E%20%7B%7D)%20%2F%2F%20%3D%3E%20'Async'%0AR.type(%5B%5D)%20%2F%2F%20%3D%3E%20'Array'%0AR.type(%7B%7D)%20%2F%2F%20%3D%3E%20'Object'%0AR.type('foo')%20%2F%2F%20%3D%3E%20'String'%0AR.type(1)%20%2F%2F%20%3D%3E%20'Number'%0AR.type(true)%20%2F%2F%20%3D%3E%20'Boolean'%0AR.type(null)%20%2F%2F%20%3D%3E%20'Null'%0AR.type(%2F%5BA-z%5D%2F)%20%2F%2F%20%3D%3E%20'RegExp'%0AR.type('foo'*1)%20%2F%2F%20%3D%3E%20'NaN'%0A%0Aconst%20delay%20%3D%20ms%20%3D%3E%20new%20Promise(resolve%20%3D%3E%20%7B%0A%20%20setTimeout(function%20()%20%7B%0A%20%20%20%20resolve()%0A%20%20%7D%2C%20ms)%0A%7D)%0AR.type(delay)%20%2F%2F%20%3D%3E%20'Promise'">Try this <strong>R.type</strong> example in Rambda REPL</a>
16692
15164
 
16693
- <details>
16694
-
16695
- <summary>All Typescript definitions</summary>
16696
-
16697
- ```typescript
16698
- type(x: any): RambdaTypes;
16699
- ```
16700
-
16701
- </details>
16702
-
16703
- <details>
16704
-
16705
- <summary><strong>R.type</strong> source</summary>
16706
-
16707
- ```javascript
16708
- export function type(input){
16709
- if (input === null){
16710
- return 'Null'
16711
- } else if (input === undefined){
16712
- return 'Undefined'
16713
- } else if (Number.isNaN(input)){
16714
- return 'NaN'
16715
- }
16716
- const typeResult = Object.prototype.toString.call(input).slice(8, -1)
16717
-
16718
- return typeResult === 'AsyncFunction' ? 'Promise' : typeResult
16719
- }
16720
- ```
16721
-
16722
- </details>
16723
-
16724
- <details>
16725
-
16726
- <summary><strong>Tests</strong></summary>
16727
-
16728
- ```javascript
16729
- import { type as typeRamda } from 'ramda'
16730
-
16731
- import { type } from './type.js'
16732
-
16733
- test('with buffer', () => {
16734
- expect(type(new Buffer.from('foo'))).toBe('Uint8Array')
16735
- })
16736
-
16737
- test('with array buffer', () => {
16738
- expect(type(new ArrayBuffer(8))).toBe('ArrayBuffer')
16739
- })
16740
-
16741
- test('with big int', () => {
16742
- expect(type(BigInt(9007199254740991))).toBe('BigInt')
16743
- })
16744
-
16745
- test('with generators', () => {
16746
- function* generator(){
16747
- yield 1
16748
- yield 2
16749
- yield 3
16750
- }
16751
-
16752
- const gen = generator()
16753
- expect(type(generator)).toBe('GeneratorFunction')
16754
- expect(type(gen)).toBe('Generator')
16755
- })
16756
-
16757
- test('with infinity', () => {
16758
- expect(type(Infinity)).toBe('Number')
16759
- })
16760
-
16761
- test('with weak map', () => {
16762
- expect(type(new WeakMap())).toBe('WeakMap')
16763
- })
16764
-
16765
- test('with map', () => {
16766
- expect(type(new Map())).toBe('Map')
16767
- })
16768
-
16769
- test('with symbol', () => {
16770
- expect(type(Symbol())).toBe('Symbol')
16771
- })
16772
-
16773
- test('with simple promise', () => {
16774
- expect(type(Promise.resolve(1))).toBe('Promise')
16775
- })
16776
-
16777
- test('with new Boolean', () => {
16778
- expect(type(new Boolean(true))).toBe('Boolean')
16779
- })
16780
-
16781
- test('with new String', () => {
16782
- expect(type(new String('I am a String object'))).toBe('String')
16783
- })
16784
-
16785
- test('with new Number', () => {
16786
- expect(type(new Number(1))).toBe('Number')
16787
- })
16788
-
16789
- test('with error', () => {
16790
- expect(type(Error('foo'))).toBe('Error')
16791
- expect(typeRamda(Error('foo'))).toBe('Error')
16792
- })
16793
-
16794
- test('with error - wrong @types/ramda test', () => {
16795
- // @types/ramda expect the result to be 'Error' but it is not
16796
- class ExtendedError extends Error{}
16797
- expect(type(ExtendedError)).toBe('Function')
16798
- expect(typeRamda(ExtendedError)).toBe('Function')
16799
- })
16800
-
16801
- test('with new promise', () => {
16802
- const delay = ms =>
16803
- new Promise(resolve => {
16804
- setTimeout(() => {
16805
- resolve(ms + 110)
16806
- }, ms)
16807
- })
16808
-
16809
- expect(type(delay(10))).toBe('Promise')
16810
- })
16811
-
16812
- test('async function', () => {
16813
- expect(type(async () => {})).toBe('Promise')
16814
- })
16815
-
16816
- test('async arrow', () => {
16817
- const asyncArrow = async () => {}
16818
- expect(type(asyncArrow)).toBe('Promise')
16819
- })
16820
-
16821
- test('function', () => {
16822
- const fn1 = () => {}
16823
- const fn2 = function (){}
16824
-
16825
- function fn3(){}
16826
-
16827
- ;[ () => {}, fn1, fn2, fn3 ].map(val => {
16828
- expect(type(val)).toBe('Function')
16829
- })
16830
- })
16831
-
16832
- test('object', () => {
16833
- expect(type({})).toBe('Object')
16834
- })
16835
-
16836
- test('number', () => {
16837
- expect(type(1)).toBe('Number')
16838
- })
16839
-
16840
- test('boolean', () => {
16841
- expect(type(false)).toBe('Boolean')
16842
- })
16843
-
16844
- test('string', () => {
16845
- expect(type('foo')).toBe('String')
16846
- })
16847
-
16848
- test('null', () => {
16849
- expect(type(null)).toBe('Null')
16850
- })
16851
-
16852
- test('array', () => {
16853
- expect(type([])).toBe('Array')
16854
- expect(type([ 1, 2, 3 ])).toBe('Array')
16855
- })
16856
-
16857
- test('regex', () => {
16858
- expect(type(/\s/g)).toBe('RegExp')
16859
- })
16860
-
16861
- test('undefined', () => {
16862
- expect(type(undefined)).toBe('Undefined')
16863
- })
16864
-
16865
- test('not a number', () => {
16866
- expect(type(Number('s'))).toBe('NaN')
16867
- })
16868
-
16869
- test('set', () => {
16870
- const exampleSet = new Set([ 1, 2, 3 ])
16871
- expect(type(exampleSet)).toBe('Set')
16872
- expect(typeRamda(exampleSet)).toBe('Set')
16873
- })
16874
-
16875
- test('function inside object 1', () => {
16876
- const obj = {
16877
- f(){
16878
- return 4
16879
- },
16880
- }
16881
-
16882
- expect(type(obj.f)).toBe('Function')
16883
- expect(typeRamda(obj.f)).toBe('Function')
16884
- })
16885
-
16886
- test('function inside object 2', () => {
16887
- const name = 'f'
16888
- const obj = {
16889
- [ name ](){
16890
- return 4
16891
- },
16892
- }
16893
- expect(type(obj.f)).toBe('Function')
16894
- expect(typeRamda(obj.f)).toBe('Function')
16895
- })
16896
- ```
16897
-
16898
- </details>
16899
-
16900
- <details>
16901
-
16902
- <summary><strong>Typescript</strong> test</summary>
16903
-
16904
- ```typescript
16905
- import {type} from 'rambda'
16906
-
16907
- describe('R.type', () => {
16908
- it('happy', () => {
16909
- const result = type(4)
16910
-
16911
- result // $ExpectType RambdaTypes
16912
- })
16913
- })
16914
- ```
16915
-
16916
- </details>
16917
-
16918
- <details>
16919
-
16920
- <summary>Rambda is faster than Ramda with 48.6%</summary>
16921
-
16922
- ```text
16923
- const R = require('../../dist/rambda.js')
16924
-
16925
- const { listOfVariousTypes } = require('./_utils')
16926
-
16927
- const limit = 1000
16928
-
16929
- function applyBenchmark(fn){
16930
- listOfVariousTypes.forEach(mode => {
16931
- Array(limit)
16932
- .fill(mode)
16933
- .forEach(x => fn(x))
16934
- })
16935
- }
16936
-
16937
- const test = [
16938
- {
16939
- label : 'Rambda',
16940
- fn : () => {
16941
- applyBenchmark(R.type)
16942
- },
16943
- },
16944
- {
16945
- label : 'Ramda',
16946
- fn : () => {
16947
- applyBenchmark(Ramda.type)
16948
- },
16949
- },
16950
- ]
16951
- ```
16952
-
16953
- </details>
16954
-
16955
15165
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#type)
16956
15166
 
16957
15167
  ### unapply
@@ -17335,59 +15545,15 @@ describe('R.uniq', () => {
17335
15545
 
17336
15546
  </details>
17337
15547
 
17338
- <details>
17339
-
17340
- <summary>Rambda is faster than Ramda with 90.24%</summary>
17341
-
17342
- ```text
17343
- const R = require('../../dist/rambda.js')
17344
-
17345
- const {
17346
- uniqListOfStrings,
17347
- uniqListOfBooleans,
17348
- uniqListOfNumbers,
17349
- uniqListOfLists,
17350
- uniqListOfObjects,
17351
- } = require('./_utils.js')
17352
-
17353
- const limit = 100
17354
-
17355
- const modes = [
17356
- uniqListOfStrings(limit),
17357
- uniqListOfBooleans(limit),
17358
- uniqListOfNumbers(limit),
17359
- uniqListOfLists(limit),
17360
- uniqListOfObjects(limit),
17361
- ]
17362
-
17363
- function applyBenchmark(fn, input){
17364
- fn(input)
17365
- }
17366
-
17367
- const tests = [
17368
- {
17369
- label : 'Rambda',
17370
- fn : R.uniq,
17371
- },
17372
- {
17373
- label : 'Ramda',
17374
- fn : Ramda.uniq,
17375
- },
17376
- ]
17377
-
17378
- tests,
17379
- modes,
17380
- applyBenchmark,
17381
- }
17382
- ```
17383
-
17384
- </details>
17385
-
17386
15548
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniq)
17387
15549
 
17388
15550
  ### uniqBy
17389
15551
 
17390
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.uniqBy(Math.abs%2C%20%5B%20-2%2C%201%2C%200%2C%20-1%2C%202%20%5D)%0A%0A%2F%2F%20%3D%3E%20%5B-2%2C%201%2C%200%5D">Try this <strong>R.uniqBy</strong> example in Rambda REPL</a>
15552
+ It applies uniqueness to input list based on function that defines what to be used for comparison between elements.
15553
+
15554
+ `R.equals` is used to determine equality.
15555
+
15556
+ <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>
17391
15557
 
17392
15558
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniqBy)
17393
15559
 
@@ -17510,57 +15676,6 @@ describe('R.uniqWith', () => {
17510
15676
 
17511
15677
  </details>
17512
15678
 
17513
- <details>
17514
-
17515
- <summary>Rambda is slower than Ramda with 18.09%</summary>
17516
-
17517
- ```text
17518
- const R = require('../../dist/rambda.js')
17519
-
17520
- const {
17521
- uniqListOfStrings,
17522
- uniqListOfBooleans,
17523
- uniqListOfNumbers,
17524
- uniqListOfLists,
17525
- uniqListOfObjects,
17526
- } = require('./_utils.js')
17527
-
17528
- const limit = 100
17529
-
17530
- const modes = [
17531
- [ uniqListOfStrings(limit), (x, y) => x.length === y.length ],
17532
- [ uniqListOfBooleans(limit), (x, y) => x === y ],
17533
- [ uniqListOfNumbers(limit), (x, y) => x > y ],
17534
- [ uniqListOfLists(limit), (x, y) => x.length === y.length ],
17535
- [
17536
- uniqListOfObjects(limit),
17537
- x => (x, y) => Object.keys(x).length === Object.keys(y).length,
17538
- ],
17539
- ]
17540
-
17541
- function applyBenchmark(fn, input){
17542
- return fn(input[ 1 ], input[ 0 ])
17543
- }
17544
-
17545
- const tests = [
17546
- {
17547
- label : 'Rambda',
17548
- fn : R.uniqWith,
17549
- },
17550
- {
17551
- label : 'Ramda',
17552
- fn : Ramda.uniqWith,
17553
- },
17554
- ]
17555
-
17556
- modes,
17557
- tests,
17558
- applyBenchmark,
17559
- }
17560
- ```
17561
-
17562
- </details>
17563
-
17564
15679
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniqWith)
17565
15680
 
17566
15681
  ### unless
@@ -17714,6 +15829,10 @@ describe('R.unless - curried', () => {
17714
15829
 
17715
15830
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unless)
17716
15831
 
15832
+ ### unnest
15833
+
15834
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unnest)
15835
+
17717
15836
  ### unwind
17718
15837
 
17719
15838
  <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20obj%20%3D%20%7B%0A%20%20a%3A%201%2C%0A%20%20b%3A%20%5B2%2C%203%5D%2C%0A%7D%0Aconst%20result%20%3D%20unwind('b'%2C%20Record%3Cstring%2C%20unknown%3E)%0Aconst%20expected%20%3D%20%5B%7Ba%3A1%2C%20b%3A2%7D%2C%20%7Ba%3A1%2C%20b%3A3%7D%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.unwind</strong> example in Rambda REPL</a>
@@ -17838,43 +15957,6 @@ describe('R.update', () => {
17838
15957
 
17839
15958
  </details>
17840
15959
 
17841
- <details>
17842
-
17843
- <summary>Rambda is faster than Ramda with 52.35%</summary>
17844
-
17845
- ```text
17846
- const R = require('../../dist/rambda.js')
17847
-
17848
- const list = [ 0, 1, 2 ]
17849
- const index = 1
17850
- const replacer = 7
17851
-
17852
- const update = [
17853
- {
17854
- label : 'Rambda',
17855
- fn : () => {
17856
- R.update(
17857
- replacer, index, list
17858
- )
17859
- R.update(replacer, index)(list)
17860
- R.update(replacer)(index)(list)
17861
- },
17862
- },
17863
- {
17864
- label : 'Ramda',
17865
- fn : () => {
17866
- Ramda.update(
17867
- replacer, index, list
17868
- )
17869
- Ramda.update(replacer, index)(list)
17870
- Ramda.update(replacer)(index)(list)
17871
- },
17872
- },
17873
- ]
17874
- ```
17875
-
17876
- </details>
17877
-
17878
15960
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#update)
17879
15961
 
17880
15962
  ### values
@@ -18057,33 +16139,6 @@ describe('R.view', () => {
18057
16139
 
18058
16140
  </details>
18059
16141
 
18060
- <details>
18061
-
18062
- <summary>Rambda is faster than Ramda with 76.15%</summary>
18063
-
18064
- ```text
18065
- const R = require('../../dist/rambda.js')
18066
-
18067
- const testObj = { a : 1 }
18068
-
18069
- const last = [
18070
- {
18071
- label : 'Rambda',
18072
- fn : () => {
18073
- R.view(R.lensProp('a'), testObj)
18074
- },
18075
- },
18076
- {
18077
- label : 'Ramda',
18078
- fn : () => {
18079
- Ramda.view(Ramda.lensProp('a'), testObj)
18080
- },
18081
- },
18082
- ]
18083
- ```
18084
-
18085
- </details>
18086
-
18087
16142
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#view)
18088
16143
 
18089
16144
  ### when
@@ -18995,8 +17050,28 @@ describe('R.zipWith', () => {
18995
17050
 
18996
17051
  ## ❯ CHANGELOG
18997
17052
 
17053
+ 7.5.0
17054
+
17055
+ - IMPORTANT: Remove `export` property in `package.json` in order to allow `Rambda` support for projects with `"type": "module"` in `package.json` - [Issue #667](https://github.com/selfrefactor/rambda/issues/657)
17056
+
17057
+ - Add `R.unnest` - [Rambdax issue 89](https://github.com/selfrefactor/rambdax/issues/89)
17058
+
17059
+ - `R.uniq` is not using `R.equals` as Ramda does - [Issue #88](https://github.com/selfrefactor/rambdax/issues/88)
17060
+
17061
+ - Fix `R.path(['non','existing','path'], obj)` TS definition as 7.4.0 release caused TS errors - [Issue #668](https://github.com/selfrefactor/rambda/issues/668)
17062
+
17063
+ 7.4.0
17064
+
17065
+ - Synchronize with `@types/ramda` - `R.prop`, `R.path`, `R.pickAll`
17066
+
17067
+ - Remove `esm` Rollup output due to tree-shaking issues.
17068
+
17069
+ - Upgrade all dev dependencies.
17070
+
18998
17071
  7.3.0
18999
17072
 
17073
+ - Important - changing import declaration in `package.json` in order to fix tree-shaking issue - [Issue #647](https://github.com/selfrefactor/rambda/issues/647)
17074
+
19000
17075
  - Add `R.modify`
19001
17076
 
19002
17077
  - Allow multiple inputs in Typescript versions of `R.anyPass` and `R.allPass` - [Issue #642](https://github.com/selfrefactor/rambda/issues/604)
@@ -19306,4 +17381,8 @@ Fix wrong versions in changelog
19306
17381
  </td>
19307
17382
  </tr>
19308
17383
  </tbody>
19309
- </table>
17384
+ </table>
17385
+
17386
+ ## Stargazers over time
17387
+
17388
+ [![Stargazers over time](https://starchart.cc/selfrefactor/rambda.svg)](https://starchart.cc/selfrefactor/rambda)