rambda 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -21
- package/README.md +793 -526
- package/dist/rambda.js +188 -75
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +60 -26
- package/index.d.ts +60 -26
- package/package.json +24 -25
- package/rambda.js +8 -0
- package/src/_internals/utils.js +21 -0
- package/src/addIndex.js +23 -0
- package/src/addIndexRight.js +9 -0
- package/src/ap.js +7 -0
- package/src/aperture.js +15 -0
- package/src/applyTo.js +7 -0
- package/src/ascend.js +23 -0
- package/src/descend.js +17 -0
- package/src/differenceWith.js +20 -0
package/README.md
CHANGED
|
@@ -33,13 +33,13 @@ You can test this example in <a href="https://rambda.now.sh?const%20result%20%3D
|
|
|
33
33
|
|
|
34
34
|
## ❯ Rambda's advantages
|
|
35
35
|
|
|
36
|
-
###
|
|
36
|
+
### TypeScript included
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
TypeScript definitions are included in the library, in comparison to **Ramda**, where you need to additionally install `@types/ramda`.
|
|
39
39
|
|
|
40
|
-
Still, you need to be aware that functional programming features in `
|
|
40
|
+
Still, you need to be aware that functional programming features in `TypeScript` are in development, which means that using **R.compose/R.pipe** can be problematic.
|
|
41
41
|
|
|
42
|
-
Important - Rambda version `7.1.0`(or higher) requires
|
|
42
|
+
Important - Rambda version `7.1.0`(or higher) requires TypeScript version `4.3.3`(or higher).
|
|
43
43
|
|
|
44
44
|
#### Immutable TS definitions
|
|
45
45
|
|
|
@@ -96,16 +96,10 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
96
96
|
|
|
97
97
|
<details>
|
|
98
98
|
<summary>
|
|
99
|
-
Click to see the full list of
|
|
99
|
+
Click to see the full list of 72 Ramda methods not implemented in Rambda
|
|
100
100
|
</summary>
|
|
101
101
|
|
|
102
102
|
- __
|
|
103
|
-
- addIndex
|
|
104
|
-
- addIndexRight
|
|
105
|
-
- ap
|
|
106
|
-
- aperture
|
|
107
|
-
- applyTo
|
|
108
|
-
- ascend
|
|
109
103
|
- binary
|
|
110
104
|
- call
|
|
111
105
|
- collectBy
|
|
@@ -113,8 +107,6 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
113
107
|
- composeWith
|
|
114
108
|
- construct
|
|
115
109
|
- constructN
|
|
116
|
-
- descend
|
|
117
|
-
- differenceWith
|
|
118
110
|
- dissocPath
|
|
119
111
|
- dropRepeatsBy
|
|
120
112
|
- empty
|
|
@@ -220,7 +212,7 @@ import {compose, add} from 'https://raw.githubusercontent.com/selfrefactor/rambd
|
|
|
220
212
|
|
|
221
213
|
- Error handling, when wrong inputs are provided, may not be the same. This difference will be better documented once all brute force tests are completed.
|
|
222
214
|
|
|
223
|
-
-
|
|
215
|
+
- TypeScript definitions between `rambda` and `@types/ramda` may vary.
|
|
224
216
|
|
|
225
217
|
> If you need more **Ramda** methods in **Rambda**, you may either submit a `PR` or check the extended version of **Rambda** - [Rambdax](https://github.com/selfrefactor/rambdax). In case of the former, you may want to consult with [Rambda contribution guidelines.](CONTRIBUTING.md)
|
|
226
218
|
|
|
@@ -341,6 +333,14 @@ It adds `a` and `b`.
|
|
|
341
333
|
|
|
342
334
|
[](#add)
|
|
343
335
|
|
|
336
|
+
### addIndex
|
|
337
|
+
|
|
338
|
+
[](#addIndex)
|
|
339
|
+
|
|
340
|
+
### addIndexRight
|
|
341
|
+
|
|
342
|
+
[](#addIndexRight)
|
|
343
|
+
|
|
344
344
|
### adjust
|
|
345
345
|
|
|
346
346
|
```typescript
|
|
@@ -350,11 +350,11 @@ adjust<T>(index: number, replaceFn: (x: T) => T, list: T[]): T[]
|
|
|
350
350
|
|
|
351
351
|
It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
|
|
352
352
|
|
|
353
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?
|
|
353
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.adjust(%0A%20%200%2C%0A%20%20a%20%3D%3E%20a%20%2B%201%2C%0A%20%20%5B0%2C%20100%5D%0A)%20%2F%2F%20%3D%3E%20%5B1%2C%20100%5D">Try this <strong>R.adjust</strong> example in Rambda REPL</a>
|
|
354
354
|
|
|
355
355
|
<details>
|
|
356
356
|
|
|
357
|
-
<summary>All
|
|
357
|
+
<summary>All TypeScript definitions</summary>
|
|
358
358
|
|
|
359
359
|
```typescript
|
|
360
360
|
adjust<T>(index: number, replaceFn: (x: T) => T, list: T[]): T[];
|
|
@@ -454,7 +454,7 @@ It returns `true`, if all members of array `list` returns `true`, when applied a
|
|
|
454
454
|
|
|
455
455
|
<details>
|
|
456
456
|
|
|
457
|
-
<summary>All
|
|
457
|
+
<summary>All TypeScript definitions</summary>
|
|
458
458
|
|
|
459
459
|
```typescript
|
|
460
460
|
all<T>(predicate: (x: T) => boolean, list: T[]): boolean;
|
|
@@ -507,7 +507,7 @@ test('when false', () => {
|
|
|
507
507
|
|
|
508
508
|
<details>
|
|
509
509
|
|
|
510
|
-
<summary><strong>
|
|
510
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
511
511
|
|
|
512
512
|
```typescript
|
|
513
513
|
import {all} from 'rambda'
|
|
@@ -550,7 +550,7 @@ It returns `true`, if all functions of `predicates` return `true`, when `input`
|
|
|
550
550
|
|
|
551
551
|
<details>
|
|
552
552
|
|
|
553
|
-
<summary>All
|
|
553
|
+
<summary>All TypeScript definitions</summary>
|
|
554
554
|
|
|
555
555
|
```typescript
|
|
556
556
|
allPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
|
|
@@ -630,7 +630,7 @@ test('works with multiple inputs', () => {
|
|
|
630
630
|
|
|
631
631
|
<details>
|
|
632
632
|
|
|
633
|
-
<summary><strong>
|
|
633
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
634
634
|
|
|
635
635
|
```typescript
|
|
636
636
|
import {allPass, filter} from 'rambda'
|
|
@@ -703,7 +703,7 @@ It returns `true`, if at least one member of `list` returns true, when passed to
|
|
|
703
703
|
|
|
704
704
|
<details>
|
|
705
705
|
|
|
706
|
-
<summary>All
|
|
706
|
+
<summary>All TypeScript definitions</summary>
|
|
707
707
|
|
|
708
708
|
```typescript
|
|
709
709
|
any<T>(predicate: (x: T) => boolean, list: T[]): boolean;
|
|
@@ -756,7 +756,7 @@ test('with curry', () => {
|
|
|
756
756
|
|
|
757
757
|
<details>
|
|
758
758
|
|
|
759
|
-
<summary><strong>
|
|
759
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
760
760
|
|
|
761
761
|
```typescript
|
|
762
762
|
import {any} from 'rambda'
|
|
@@ -800,7 +800,7 @@ It accepts list of `predicates` and returns a function. This function with its `
|
|
|
800
800
|
|
|
801
801
|
<details>
|
|
802
802
|
|
|
803
|
-
<summary>All
|
|
803
|
+
<summary>All TypeScript definitions</summary>
|
|
804
804
|
|
|
805
805
|
```typescript
|
|
806
806
|
anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
|
|
@@ -893,7 +893,7 @@ test('works with multiple inputs', () => {
|
|
|
893
893
|
|
|
894
894
|
<details>
|
|
895
895
|
|
|
896
|
-
<summary><strong>
|
|
896
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
897
897
|
|
|
898
898
|
```typescript
|
|
899
899
|
import {anyPass, filter} from 'rambda'
|
|
@@ -937,6 +937,140 @@ describe('anyPass', () => {
|
|
|
937
937
|
|
|
938
938
|
[](#anyPass)
|
|
939
939
|
|
|
940
|
+
### ap
|
|
941
|
+
|
|
942
|
+
```typescript
|
|
943
|
+
|
|
944
|
+
ap<T, U>(fns: Array<(a: T) => U>[], vs: T[]): U[]
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
<details>
|
|
948
|
+
|
|
949
|
+
<summary>All TypeScript definitions</summary>
|
|
950
|
+
|
|
951
|
+
```typescript
|
|
952
|
+
ap<T, U>(fns: Array<(a: T) => U>[], vs: T[]): U[];
|
|
953
|
+
ap<T, U>(fns: Array<(a: T) => U>): (vs: T[]) => U[];
|
|
954
|
+
ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
</details>
|
|
958
|
+
|
|
959
|
+
<details>
|
|
960
|
+
|
|
961
|
+
<summary><strong>R.ap</strong> source</summary>
|
|
962
|
+
|
|
963
|
+
```javascript
|
|
964
|
+
export function ap(functions, input){
|
|
965
|
+
if (arguments.length === 1){
|
|
966
|
+
return _inputs => ap(functions, _inputs)
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return functions.reduce((acc, fn) => [ ...acc, ...input.map(fn) ], [])
|
|
970
|
+
}
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
</details>
|
|
974
|
+
|
|
975
|
+
<details>
|
|
976
|
+
|
|
977
|
+
<summary><strong>Tests</strong></summary>
|
|
978
|
+
|
|
979
|
+
```javascript
|
|
980
|
+
import { ap } from './ap.js'
|
|
981
|
+
|
|
982
|
+
function mult2(x){
|
|
983
|
+
return x * 2
|
|
984
|
+
}
|
|
985
|
+
function plus3(x){
|
|
986
|
+
return x + 3
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
test('happy', () => {
|
|
990
|
+
expect(ap([ mult2, plus3 ], [ 1, 2, 3 ])).toEqual([ 2, 4, 6, 4, 5, 6 ])
|
|
991
|
+
})
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
</details>
|
|
995
|
+
|
|
996
|
+
[](#ap)
|
|
997
|
+
|
|
998
|
+
### aperture
|
|
999
|
+
|
|
1000
|
+
```typescript
|
|
1001
|
+
|
|
1002
|
+
aperture<N extends number, T>(n: N, list: T[]): Array<Tuple<T, N>> | []
|
|
1003
|
+
```
|
|
1004
|
+
|
|
1005
|
+
<details>
|
|
1006
|
+
|
|
1007
|
+
<summary>All TypeScript definitions</summary>
|
|
1008
|
+
|
|
1009
|
+
```typescript
|
|
1010
|
+
aperture<N extends number, T>(n: N, list: T[]): Array<Tuple<T, N>> | [];
|
|
1011
|
+
aperture<N extends number>(n: N): <T>(list: T[]) => Array<Tuple<T, N>> | [];
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
</details>
|
|
1015
|
+
|
|
1016
|
+
<details>
|
|
1017
|
+
|
|
1018
|
+
<summary><strong>R.aperture</strong> source</summary>
|
|
1019
|
+
|
|
1020
|
+
```javascript
|
|
1021
|
+
export function aperture(step, list){
|
|
1022
|
+
if (arguments.length === 1){
|
|
1023
|
+
return _list => aperture(step, _list)
|
|
1024
|
+
}
|
|
1025
|
+
if (step > list.length) return []
|
|
1026
|
+
let idx = 0
|
|
1027
|
+
const limit = list.length - (step - 1)
|
|
1028
|
+
const acc = new Array(limit)
|
|
1029
|
+
while (idx < limit){
|
|
1030
|
+
acc[ idx ] = list.slice(idx, idx + step)
|
|
1031
|
+
idx += 1
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
return acc
|
|
1035
|
+
}
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
</details>
|
|
1039
|
+
|
|
1040
|
+
<details>
|
|
1041
|
+
|
|
1042
|
+
<summary><strong>Tests</strong></summary>
|
|
1043
|
+
|
|
1044
|
+
```javascript
|
|
1045
|
+
import { aperture } from './aperture.js'
|
|
1046
|
+
|
|
1047
|
+
const list = [ 1, 2, 3, 4, 5, 6, 7 ]
|
|
1048
|
+
|
|
1049
|
+
test('happy', () => {
|
|
1050
|
+
expect(aperture(1, list)).toEqual([ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ] ])
|
|
1051
|
+
expect(aperture(2, list)).toEqual([
|
|
1052
|
+
[ 1, 2 ],
|
|
1053
|
+
[ 2, 3 ],
|
|
1054
|
+
[ 3, 4 ],
|
|
1055
|
+
[ 4, 5 ],
|
|
1056
|
+
[ 5, 6 ],
|
|
1057
|
+
[ 6, 7 ],
|
|
1058
|
+
])
|
|
1059
|
+
expect(aperture(3, list)).toEqual([
|
|
1060
|
+
[ 1, 2, 3 ],
|
|
1061
|
+
[ 2, 3, 4 ],
|
|
1062
|
+
[ 3, 4, 5 ],
|
|
1063
|
+
[ 4, 5, 6 ],
|
|
1064
|
+
[ 5, 6, 7 ],
|
|
1065
|
+
])
|
|
1066
|
+
expect(aperture(8, list)).toEqual([])
|
|
1067
|
+
})
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
</details>
|
|
1071
|
+
|
|
1072
|
+
[](#aperture)
|
|
1073
|
+
|
|
940
1074
|
### append
|
|
941
1075
|
|
|
942
1076
|
```typescript
|
|
@@ -950,7 +1084,7 @@ It adds element `x` at the end of `list`.
|
|
|
950
1084
|
|
|
951
1085
|
<details>
|
|
952
1086
|
|
|
953
|
-
<summary>All
|
|
1087
|
+
<summary>All TypeScript definitions</summary>
|
|
954
1088
|
|
|
955
1089
|
```typescript
|
|
956
1090
|
append<T>(x: T, list: T[]): T[];
|
|
@@ -1008,7 +1142,7 @@ test('with strings', () => {
|
|
|
1008
1142
|
|
|
1009
1143
|
<details>
|
|
1010
1144
|
|
|
1011
|
-
<summary><strong>
|
|
1145
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
1012
1146
|
|
|
1013
1147
|
```typescript
|
|
1014
1148
|
import {append} from 'rambda'
|
|
@@ -1048,7 +1182,7 @@ This is useful for creating a fixed-arity function from a variadic function. `fn
|
|
|
1048
1182
|
|
|
1049
1183
|
<details>
|
|
1050
1184
|
|
|
1051
|
-
<summary>All
|
|
1185
|
+
<summary>All TypeScript definitions</summary>
|
|
1052
1186
|
|
|
1053
1187
|
```typescript
|
|
1054
1188
|
apply<T = any>(fn: (...args: any[]) => T, args: any[]): T;
|
|
@@ -1092,7 +1226,7 @@ test('applies function to argument list', () => {
|
|
|
1092
1226
|
|
|
1093
1227
|
test('provides no way to specify context', () => {
|
|
1094
1228
|
const obj = {
|
|
1095
|
-
method
|
|
1229
|
+
method (){
|
|
1096
1230
|
return this === obj
|
|
1097
1231
|
},
|
|
1098
1232
|
}
|
|
@@ -1105,7 +1239,7 @@ test('provides no way to specify context', () => {
|
|
|
1105
1239
|
|
|
1106
1240
|
<details>
|
|
1107
1241
|
|
|
1108
|
-
<summary><strong>
|
|
1242
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
1109
1243
|
|
|
1110
1244
|
```typescript
|
|
1111
1245
|
import {apply, identity} from 'rambda'
|
|
@@ -1144,7 +1278,7 @@ applySpec<Spec extends Record<string, AnyFunction>>(
|
|
|
1144
1278
|
|
|
1145
1279
|
<details>
|
|
1146
1280
|
|
|
1147
|
-
<summary>All
|
|
1281
|
+
<summary>All TypeScript definitions</summary>
|
|
1148
1282
|
|
|
1149
1283
|
```typescript
|
|
1150
1284
|
applySpec<Spec extends Record<string, AnyFunction>>(
|
|
@@ -1539,7 +1673,7 @@ test('restructure json object', () => {
|
|
|
1539
1673
|
|
|
1540
1674
|
<details>
|
|
1541
1675
|
|
|
1542
|
-
<summary><strong>
|
|
1676
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
1543
1677
|
|
|
1544
1678
|
```typescript
|
|
1545
1679
|
import {multiply, applySpec, inc, dec, add} from 'rambda'
|
|
@@ -1571,6 +1705,14 @@ describe('applySpec', () => {
|
|
|
1571
1705
|
|
|
1572
1706
|
[](#applySpec)
|
|
1573
1707
|
|
|
1708
|
+
### applyTo
|
|
1709
|
+
|
|
1710
|
+
[](#applyTo)
|
|
1711
|
+
|
|
1712
|
+
### ascend
|
|
1713
|
+
|
|
1714
|
+
[](#ascend)
|
|
1715
|
+
|
|
1574
1716
|
### assoc
|
|
1575
1717
|
|
|
1576
1718
|
It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.
|
|
@@ -1592,7 +1734,7 @@ It makes a shallow clone of `obj` with setting or overriding with `newValue` the
|
|
|
1592
1734
|
|
|
1593
1735
|
<details>
|
|
1594
1736
|
|
|
1595
|
-
<summary>All
|
|
1737
|
+
<summary>All TypeScript definitions</summary>
|
|
1596
1738
|
|
|
1597
1739
|
```typescript
|
|
1598
1740
|
assocPath<Output>(path: Path, newValue: any, obj: object): Output;
|
|
@@ -1683,6 +1825,22 @@ test('string can be used as path input', () => {
|
|
|
1683
1825
|
expect(result).toEqual(expected)
|
|
1684
1826
|
})
|
|
1685
1827
|
|
|
1828
|
+
test('difference with ramda - doesn\'t overwrite primitive values with keys in the path', () => {
|
|
1829
|
+
const obj = { a : 'str' }
|
|
1830
|
+
const result = assocPath(
|
|
1831
|
+
[ 'a', 'b' ], 42, obj
|
|
1832
|
+
)
|
|
1833
|
+
|
|
1834
|
+
expect(result).toEqual({
|
|
1835
|
+
a : {
|
|
1836
|
+
0 : 's',
|
|
1837
|
+
1 : 't',
|
|
1838
|
+
2 : 'r',
|
|
1839
|
+
b : 42,
|
|
1840
|
+
},
|
|
1841
|
+
})
|
|
1842
|
+
})
|
|
1843
|
+
|
|
1686
1844
|
test('bug', () => {
|
|
1687
1845
|
/*
|
|
1688
1846
|
https://github.com/selfrefactor/rambda/issues/524
|
|
@@ -1831,7 +1989,7 @@ test('happy', () => {
|
|
|
1831
1989
|
|
|
1832
1990
|
<details>
|
|
1833
1991
|
|
|
1834
|
-
<summary><strong>
|
|
1992
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
1835
1993
|
|
|
1836
1994
|
```typescript
|
|
1837
1995
|
import {assocPath} from 'rambda'
|
|
@@ -1885,7 +2043,7 @@ Creates a function that is bound to a context.
|
|
|
1885
2043
|
|
|
1886
2044
|
<details>
|
|
1887
2045
|
|
|
1888
|
-
<summary>All
|
|
2046
|
+
<summary>All TypeScript definitions</summary>
|
|
1889
2047
|
|
|
1890
2048
|
```typescript
|
|
1891
2049
|
bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
|
|
@@ -2010,7 +2168,7 @@ test('preserves arity', () => {
|
|
|
2010
2168
|
|
|
2011
2169
|
<details>
|
|
2012
2170
|
|
|
2013
|
-
<summary><strong>
|
|
2171
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2014
2172
|
|
|
2015
2173
|
```typescript
|
|
2016
2174
|
import {bind} from 'rambda'
|
|
@@ -2049,7 +2207,7 @@ This function will return `true`, if both `firstCondition` and `secondCondition`
|
|
|
2049
2207
|
|
|
2050
2208
|
<details>
|
|
2051
2209
|
|
|
2052
|
-
<summary>All
|
|
2210
|
+
<summary>All TypeScript definitions</summary>
|
|
2053
2211
|
|
|
2054
2212
|
```typescript
|
|
2055
2213
|
both(pred1: Pred, pred2: Pred): Pred;
|
|
@@ -2127,7 +2285,7 @@ test('skip evaluation of the second expression', () => {
|
|
|
2127
2285
|
|
|
2128
2286
|
<details>
|
|
2129
2287
|
|
|
2130
|
-
<summary><strong>
|
|
2288
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2131
2289
|
|
|
2132
2290
|
```typescript
|
|
2133
2291
|
import {both} from 'rambda'
|
|
@@ -2193,7 +2351,7 @@ The method is also known as `flatMap`.
|
|
|
2193
2351
|
|
|
2194
2352
|
<details>
|
|
2195
2353
|
|
|
2196
|
-
<summary>All
|
|
2354
|
+
<summary>All TypeScript definitions</summary>
|
|
2197
2355
|
|
|
2198
2356
|
```typescript
|
|
2199
2357
|
chain<T, U>(fn: (n: T) => U[], list: T[]): U[];
|
|
@@ -2292,7 +2450,7 @@ test('@types/ramda broken test', () => {
|
|
|
2292
2450
|
|
|
2293
2451
|
<details>
|
|
2294
2452
|
|
|
2295
|
-
<summary><strong>
|
|
2453
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2296
2454
|
|
|
2297
2455
|
```typescript
|
|
2298
2456
|
import {chain} from 'rambda'
|
|
@@ -2404,7 +2562,7 @@ It counts elements in a list after each instance of the input list is passed thr
|
|
|
2404
2562
|
|
|
2405
2563
|
<details>
|
|
2406
2564
|
|
|
2407
|
-
<summary>All
|
|
2565
|
+
<summary>All TypeScript definitions</summary>
|
|
2408
2566
|
|
|
2409
2567
|
```typescript
|
|
2410
2568
|
countBy<T extends unknown>(transformFn: (x: T) => any, list: T[]): Record<string, number>;
|
|
@@ -2462,7 +2620,7 @@ test('happy', () => {
|
|
|
2462
2620
|
|
|
2463
2621
|
<details>
|
|
2464
2622
|
|
|
2465
|
-
<summary><strong>
|
|
2623
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2466
2624
|
|
|
2467
2625
|
```typescript
|
|
2468
2626
|
import {countBy} from 'rambda'
|
|
@@ -2523,7 +2681,7 @@ Else, it returns the first truthy `inputArguments` instance(from left to right).
|
|
|
2523
2681
|
|
|
2524
2682
|
<details>
|
|
2525
2683
|
|
|
2526
|
-
<summary>All
|
|
2684
|
+
<summary>All TypeScript definitions</summary>
|
|
2527
2685
|
|
|
2528
2686
|
```typescript
|
|
2529
2687
|
defaultTo<T>(defaultValue: T, input: T | null | undefined): T;
|
|
@@ -2590,7 +2748,7 @@ test('when inputArgument passes initial check', () => {
|
|
|
2590
2748
|
|
|
2591
2749
|
<details>
|
|
2592
2750
|
|
|
2593
|
-
<summary><strong>
|
|
2751
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2594
2752
|
|
|
2595
2753
|
```typescript
|
|
2596
2754
|
import {defaultTo} from 'rambda'
|
|
@@ -2611,6 +2769,10 @@ describe('R.defaultTo with Ramda spec', () => {
|
|
|
2611
2769
|
|
|
2612
2770
|
[](#defaultTo)
|
|
2613
2771
|
|
|
2772
|
+
### descend
|
|
2773
|
+
|
|
2774
|
+
[](#descend)
|
|
2775
|
+
|
|
2614
2776
|
### difference
|
|
2615
2777
|
|
|
2616
2778
|
```typescript
|
|
@@ -2626,7 +2788,7 @@ It returns the uniq set of all elements in the first list `a` not contained in t
|
|
|
2626
2788
|
|
|
2627
2789
|
<details>
|
|
2628
2790
|
|
|
2629
|
-
<summary>All
|
|
2791
|
+
<summary>All TypeScript definitions</summary>
|
|
2630
2792
|
|
|
2631
2793
|
```typescript
|
|
2632
2794
|
difference<T>(a: T[], b: T[]): T[];
|
|
@@ -2691,7 +2853,7 @@ test('should use R.equals', () => {
|
|
|
2691
2853
|
|
|
2692
2854
|
<details>
|
|
2693
2855
|
|
|
2694
|
-
<summary><strong>
|
|
2856
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2695
2857
|
|
|
2696
2858
|
```typescript
|
|
2697
2859
|
import {difference} from 'rambda'
|
|
@@ -2717,6 +2879,91 @@ describe('R.difference', () => {
|
|
|
2717
2879
|
|
|
2718
2880
|
[](#difference)
|
|
2719
2881
|
|
|
2882
|
+
### differenceWith
|
|
2883
|
+
|
|
2884
|
+
```typescript
|
|
2885
|
+
|
|
2886
|
+
differenceWith<T1, T2>(
|
|
2887
|
+
pred: (a: T1, b: T2) => boolean,
|
|
2888
|
+
list1: T1[],
|
|
2889
|
+
list2: T2[],
|
|
2890
|
+
): T1[]
|
|
2891
|
+
```
|
|
2892
|
+
|
|
2893
|
+
<details>
|
|
2894
|
+
|
|
2895
|
+
<summary>All TypeScript definitions</summary>
|
|
2896
|
+
|
|
2897
|
+
```typescript
|
|
2898
|
+
differenceWith<T1, T2>(
|
|
2899
|
+
pred: (a: T1, b: T2) => boolean,
|
|
2900
|
+
list1: T1[],
|
|
2901
|
+
list2: T2[],
|
|
2902
|
+
): T1[];
|
|
2903
|
+
differenceWith<T1, T2>(
|
|
2904
|
+
pred: (a: T1, b: T2) => boolean,
|
|
2905
|
+
): (list1: T1[], list2: T2[]) => T1[];
|
|
2906
|
+
differenceWith<T1, T2>(
|
|
2907
|
+
pred: (a: T1, b: T2) => boolean,
|
|
2908
|
+
list1: T1[],
|
|
2909
|
+
): (list2: T2[]) => T1[];
|
|
2910
|
+
```
|
|
2911
|
+
|
|
2912
|
+
</details>
|
|
2913
|
+
|
|
2914
|
+
<details>
|
|
2915
|
+
|
|
2916
|
+
<summary><strong>R.differenceWith</strong> source</summary>
|
|
2917
|
+
|
|
2918
|
+
```javascript
|
|
2919
|
+
import { curry } from './curry.js'
|
|
2920
|
+
import { _indexOf } from './equals.js'
|
|
2921
|
+
|
|
2922
|
+
export function differenceWithFn(
|
|
2923
|
+
fn, a, b
|
|
2924
|
+
){
|
|
2925
|
+
const willReturn = []
|
|
2926
|
+
const [ first, second ] = a.length > b.length ? [ a, b ] : [ b, a ]
|
|
2927
|
+
|
|
2928
|
+
first.forEach(item => {
|
|
2929
|
+
const hasItem = second.some(secondItem => fn(item, secondItem))
|
|
2930
|
+
if (!hasItem && _indexOf(item, willReturn) === -1){
|
|
2931
|
+
willReturn.push(item)
|
|
2932
|
+
}
|
|
2933
|
+
})
|
|
2934
|
+
|
|
2935
|
+
return willReturn
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
export const differenceWith = curry(differenceWithFn)
|
|
2939
|
+
```
|
|
2940
|
+
|
|
2941
|
+
</details>
|
|
2942
|
+
|
|
2943
|
+
<details>
|
|
2944
|
+
|
|
2945
|
+
<summary><strong>Tests</strong></summary>
|
|
2946
|
+
|
|
2947
|
+
```javascript
|
|
2948
|
+
import { differenceWith } from './differenceWith.js'
|
|
2949
|
+
|
|
2950
|
+
test('happy', () => {
|
|
2951
|
+
const foo = [ { a : 1 }, { a : 2 }, { a : 3 } ]
|
|
2952
|
+
const bar = [ { a : 3 }, { a : 4 } ]
|
|
2953
|
+
const fn = function (r, s){
|
|
2954
|
+
return r.a === s.a
|
|
2955
|
+
}
|
|
2956
|
+
const result = differenceWith(
|
|
2957
|
+
fn, foo, bar
|
|
2958
|
+
)
|
|
2959
|
+
expect(result).toEqual([ { a : 1 }, { a : 2 } ])
|
|
2960
|
+
})
|
|
2961
|
+
```
|
|
2962
|
+
|
|
2963
|
+
</details>
|
|
2964
|
+
|
|
2965
|
+
[](#differenceWith)
|
|
2966
|
+
|
|
2720
2967
|
### dissoc
|
|
2721
2968
|
|
|
2722
2969
|
It returns a new object that does not contain property `prop`.
|
|
@@ -2744,7 +2991,7 @@ It returns `howMany` items dropped from beginning of list or string `input`.
|
|
|
2744
2991
|
|
|
2745
2992
|
<details>
|
|
2746
2993
|
|
|
2747
|
-
<summary>All
|
|
2994
|
+
<summary>All TypeScript definitions</summary>
|
|
2748
2995
|
|
|
2749
2996
|
```typescript
|
|
2750
2997
|
drop<T>(howMany: number, input: T[]): T[];
|
|
@@ -2808,7 +3055,7 @@ test('should return copy', () => {
|
|
|
2808
3055
|
|
|
2809
3056
|
<details>
|
|
2810
3057
|
|
|
2811
|
-
<summary><strong>
|
|
3058
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2812
3059
|
|
|
2813
3060
|
```typescript
|
|
2814
3061
|
import {drop} from 'rambda'
|
|
@@ -2857,7 +3104,7 @@ It returns `howMany` items dropped from the end of list or string `input`.
|
|
|
2857
3104
|
|
|
2858
3105
|
<details>
|
|
2859
3106
|
|
|
2860
|
-
<summary>All
|
|
3107
|
+
<summary>All TypeScript definitions</summary>
|
|
2861
3108
|
|
|
2862
3109
|
```typescript
|
|
2863
3110
|
dropLast<T>(howMany: number, input: T[]): T[];
|
|
@@ -2925,7 +3172,7 @@ test('should return copy', () => {
|
|
|
2925
3172
|
|
|
2926
3173
|
<details>
|
|
2927
3174
|
|
|
2928
|
-
<summary><strong>
|
|
3175
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
2929
3176
|
|
|
2930
3177
|
```typescript
|
|
2931
3178
|
import {dropLast} from 'rambda'
|
|
@@ -2980,7 +3227,7 @@ It removes any successive duplicates according to `R.equals`.
|
|
|
2980
3227
|
|
|
2981
3228
|
<details>
|
|
2982
3229
|
|
|
2983
|
-
<summary>All
|
|
3230
|
+
<summary>All TypeScript definitions</summary>
|
|
2984
3231
|
|
|
2985
3232
|
```typescript
|
|
2986
3233
|
dropRepeats<T>(list: T[]): T[];
|
|
@@ -3070,7 +3317,7 @@ describe('brute force', () => {
|
|
|
3070
3317
|
|
|
3071
3318
|
<details>
|
|
3072
3319
|
|
|
3073
|
-
<summary><strong>
|
|
3320
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
3074
3321
|
|
|
3075
3322
|
```typescript
|
|
3076
3323
|
import {dropRepeats} from 'rambda'
|
|
@@ -3115,7 +3362,7 @@ This `predicate` function will return `true`, if any of the two input predicates
|
|
|
3115
3362
|
|
|
3116
3363
|
<details>
|
|
3117
3364
|
|
|
3118
|
-
<summary>All
|
|
3365
|
+
<summary>All TypeScript definitions</summary>
|
|
3119
3366
|
|
|
3120
3367
|
```typescript
|
|
3121
3368
|
either(firstPredicate: Pred, secondPredicate: Pred): Pred;
|
|
@@ -3200,7 +3447,7 @@ test('case 2', () => {
|
|
|
3200
3447
|
|
|
3201
3448
|
<details>
|
|
3202
3449
|
|
|
3203
|
-
<summary><strong>
|
|
3450
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
3204
3451
|
|
|
3205
3452
|
```typescript
|
|
3206
3453
|
import {either} from 'rambda'
|
|
@@ -3257,7 +3504,7 @@ describe('R.either', () => {
|
|
|
3257
3504
|
|
|
3258
3505
|
```typescript
|
|
3259
3506
|
|
|
3260
|
-
endsWith(
|
|
3507
|
+
endsWith<T extends string>(question: T, str: string): boolean
|
|
3261
3508
|
```
|
|
3262
3509
|
|
|
3263
3510
|
When iterable is a string, then it behaves as `String.prototype.endsWith`.
|
|
@@ -3267,13 +3514,13 @@ When iterable is a list, then it uses R.equals to determine if the target list e
|
|
|
3267
3514
|
|
|
3268
3515
|
<details>
|
|
3269
3516
|
|
|
3270
|
-
<summary>All
|
|
3517
|
+
<summary>All TypeScript definitions</summary>
|
|
3271
3518
|
|
|
3272
3519
|
```typescript
|
|
3273
|
-
endsWith(
|
|
3274
|
-
endsWith(
|
|
3275
|
-
endsWith<T>(
|
|
3276
|
-
endsWith<T>(
|
|
3520
|
+
endsWith<T extends string>(question: T, str: string): boolean;
|
|
3521
|
+
endsWith<T extends string>(question: T): (str: string) => boolean;
|
|
3522
|
+
endsWith<T>(question: T[], list: T[]): boolean;
|
|
3523
|
+
endsWith<T>(question: T[]): (list: T[]) => boolean;
|
|
3277
3524
|
```
|
|
3278
3525
|
|
|
3279
3526
|
</details>
|
|
@@ -3378,37 +3625,33 @@ describe('brute force', () => {
|
|
|
3378
3625
|
|
|
3379
3626
|
<details>
|
|
3380
3627
|
|
|
3381
|
-
<summary><strong>
|
|
3628
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
3382
3629
|
|
|
3383
3630
|
```typescript
|
|
3384
3631
|
import {endsWith} from 'rambda'
|
|
3385
3632
|
|
|
3386
|
-
describe('R.endsWith - array
|
|
3633
|
+
describe('R.endsWith - array', () => {
|
|
3387
3634
|
const target = [{a: 2}]
|
|
3388
|
-
const
|
|
3635
|
+
const input = [{a: 1}, {a: 2}]
|
|
3389
3636
|
it('happy', () => {
|
|
3390
|
-
const result = endsWith(target,
|
|
3391
|
-
|
|
3637
|
+
const result = endsWith(target, input)
|
|
3392
3638
|
result // $ExpectType boolean
|
|
3393
3639
|
})
|
|
3394
3640
|
it('curried', () => {
|
|
3395
|
-
const result = endsWith(target)(
|
|
3396
|
-
|
|
3641
|
+
const result = endsWith(target)(input)
|
|
3397
3642
|
result // $ExpectType boolean
|
|
3398
3643
|
})
|
|
3399
3644
|
})
|
|
3400
3645
|
|
|
3401
|
-
describe('R.endsWith - string
|
|
3646
|
+
describe('R.endsWith - string', () => {
|
|
3402
3647
|
const target = 'bar'
|
|
3403
|
-
const
|
|
3648
|
+
const input = 'foo bar'
|
|
3404
3649
|
it('happy', () => {
|
|
3405
|
-
const result = endsWith(target,
|
|
3406
|
-
|
|
3650
|
+
const result = endsWith(target, input)
|
|
3407
3651
|
result // $ExpectType boolean
|
|
3408
3652
|
})
|
|
3409
3653
|
it('curried', () => {
|
|
3410
|
-
const result = endsWith(target)(
|
|
3411
|
-
|
|
3654
|
+
const result = endsWith(target)(input)
|
|
3412
3655
|
result // $ExpectType boolean
|
|
3413
3656
|
})
|
|
3414
3657
|
})
|
|
@@ -3439,7 +3682,7 @@ It deeply compares `x` and `y` and returns `true` if they are equal.
|
|
|
3439
3682
|
|
|
3440
3683
|
<details>
|
|
3441
3684
|
|
|
3442
|
-
<summary>All
|
|
3685
|
+
<summary>All TypeScript definitions</summary>
|
|
3443
3686
|
|
|
3444
3687
|
```typescript
|
|
3445
3688
|
equals<T>(x: T, y: T): boolean;
|
|
@@ -3965,7 +4208,7 @@ describe('brute force', () => {
|
|
|
3965
4208
|
|
|
3966
4209
|
<details>
|
|
3967
4210
|
|
|
3968
|
-
<summary><strong>
|
|
4211
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
3969
4212
|
|
|
3970
4213
|
```typescript
|
|
3971
4214
|
import {equals} from 'rambda'
|
|
@@ -4006,7 +4249,7 @@ It takes object or array of functions as set of rules. These `rules` are applied
|
|
|
4006
4249
|
|
|
4007
4250
|
<details>
|
|
4008
4251
|
|
|
4009
|
-
<summary>All
|
|
4252
|
+
<summary>All TypeScript definitions</summary>
|
|
4010
4253
|
|
|
4011
4254
|
```typescript
|
|
4012
4255
|
evolve<T, U>(rules: ((x: T) => U)[], list: T[]): U[];
|
|
@@ -4214,7 +4457,7 @@ describe('brute force', () => {
|
|
|
4214
4457
|
|
|
4215
4458
|
<details>
|
|
4216
4459
|
|
|
4217
|
-
<summary><strong>
|
|
4460
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4218
4461
|
|
|
4219
4462
|
```typescript
|
|
4220
4463
|
import {evolve, add} from 'rambda'
|
|
@@ -4269,7 +4512,7 @@ F(): boolean
|
|
|
4269
4512
|
|
|
4270
4513
|
<details>
|
|
4271
4514
|
|
|
4272
|
-
<summary>All
|
|
4515
|
+
<summary>All TypeScript definitions</summary>
|
|
4273
4516
|
|
|
4274
4517
|
```typescript
|
|
4275
4518
|
F(): boolean;
|
|
@@ -4304,7 +4547,7 @@ It filters list or object `input` using a `predicate` function.
|
|
|
4304
4547
|
|
|
4305
4548
|
<details>
|
|
4306
4549
|
|
|
4307
|
-
<summary>All
|
|
4550
|
+
<summary>All TypeScript definitions</summary>
|
|
4308
4551
|
|
|
4309
4552
|
```typescript
|
|
4310
4553
|
filter<T>(predicate: Predicate<T>): (input: T[]) => T[];
|
|
@@ -4445,7 +4688,7 @@ test('bad inputs difference between Ramda and Rambda', () => {
|
|
|
4445
4688
|
|
|
4446
4689
|
<details>
|
|
4447
4690
|
|
|
4448
|
-
<summary><strong>
|
|
4691
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4449
4692
|
|
|
4450
4693
|
```typescript
|
|
4451
4694
|
import {filter} from 'rambda'
|
|
@@ -4513,7 +4756,7 @@ If there is no such element, it returns `undefined`.
|
|
|
4513
4756
|
|
|
4514
4757
|
<details>
|
|
4515
4758
|
|
|
4516
|
-
<summary>All
|
|
4759
|
+
<summary>All TypeScript definitions</summary>
|
|
4517
4760
|
|
|
4518
4761
|
```typescript
|
|
4519
4762
|
find<T>(predicate: (x: T) => boolean, list: T[]): T | undefined;
|
|
@@ -4557,12 +4800,12 @@ import { propEq } from './propEq.js'
|
|
|
4557
4800
|
const list = [ { a : 1 }, { a : 2 }, { a : 3 } ]
|
|
4558
4801
|
|
|
4559
4802
|
test('happy', () => {
|
|
4560
|
-
const fn = propEq('a'
|
|
4803
|
+
const fn = propEq(2, 'a')
|
|
4561
4804
|
expect(find(fn, list)).toEqual({ a : 2 })
|
|
4562
4805
|
})
|
|
4563
4806
|
|
|
4564
4807
|
test('with curry', () => {
|
|
4565
|
-
const fn = propEq('a'
|
|
4808
|
+
const fn = propEq(4, 'a')
|
|
4566
4809
|
expect(find(fn)(list)).toBeUndefined()
|
|
4567
4810
|
})
|
|
4568
4811
|
|
|
@@ -4575,7 +4818,7 @@ test('with empty list', () => {
|
|
|
4575
4818
|
|
|
4576
4819
|
<details>
|
|
4577
4820
|
|
|
4578
|
-
<summary><strong>
|
|
4821
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4579
4822
|
|
|
4580
4823
|
```typescript
|
|
4581
4824
|
import {find} from 'rambda'
|
|
@@ -4615,7 +4858,7 @@ If there is no such element, then `-1` is returned.
|
|
|
4615
4858
|
|
|
4616
4859
|
<details>
|
|
4617
4860
|
|
|
4618
|
-
<summary>All
|
|
4861
|
+
<summary>All TypeScript definitions</summary>
|
|
4619
4862
|
|
|
4620
4863
|
```typescript
|
|
4621
4864
|
findIndex<T>(predicate: (x: T) => boolean, list: T[]): number;
|
|
@@ -4658,11 +4901,9 @@ import { propEq } from './propEq.js'
|
|
|
4658
4901
|
const list = [ { a : 1 }, { a : 2 }, { a : 3 } ]
|
|
4659
4902
|
|
|
4660
4903
|
test('happy', () => {
|
|
4661
|
-
expect(findIndex(propEq('a'
|
|
4662
|
-
|
|
4663
|
-
expect(findIndex(propEq('a'
|
|
4664
|
-
|
|
4665
|
-
expect(findIndex(propEq('a', 4))(list)).toEqual(-1)
|
|
4904
|
+
expect(findIndex(propEq(2, 'a'), list)).toBe(1)
|
|
4905
|
+
expect(findIndex(propEq(1, 'a'))(list)).toBe(0)
|
|
4906
|
+
expect(findIndex(propEq(4, 'a'))(list)).toBe(-1)
|
|
4666
4907
|
})
|
|
4667
4908
|
```
|
|
4668
4909
|
|
|
@@ -4670,7 +4911,7 @@ test('happy', () => {
|
|
|
4670
4911
|
|
|
4671
4912
|
<details>
|
|
4672
4913
|
|
|
4673
|
-
<summary><strong>
|
|
4914
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4674
4915
|
|
|
4675
4916
|
```typescript
|
|
4676
4917
|
import {findIndex} from 'rambda'
|
|
@@ -4710,7 +4951,7 @@ If there is no such element, then `undefined` is returned.
|
|
|
4710
4951
|
|
|
4711
4952
|
<details>
|
|
4712
4953
|
|
|
4713
|
-
<summary>All
|
|
4954
|
+
<summary>All TypeScript definitions</summary>
|
|
4714
4955
|
|
|
4715
4956
|
```typescript
|
|
4716
4957
|
findLast<T>(fn: (x: T) => boolean, list: T[]): T | undefined;
|
|
@@ -4799,7 +5040,7 @@ test('ramda 4', () => {
|
|
|
4799
5040
|
|
|
4800
5041
|
<details>
|
|
4801
5042
|
|
|
4802
|
-
<summary><strong>
|
|
5043
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4803
5044
|
|
|
4804
5045
|
```typescript
|
|
4805
5046
|
import {findLast} from 'rambda'
|
|
@@ -4839,7 +5080,7 @@ If there is no such element, then `-1` is returned.
|
|
|
4839
5080
|
|
|
4840
5081
|
<details>
|
|
4841
5082
|
|
|
4842
|
-
<summary>All
|
|
5083
|
+
<summary>All TypeScript definitions</summary>
|
|
4843
5084
|
|
|
4844
5085
|
```typescript
|
|
4845
5086
|
findLastIndex<T>(predicate: (x: T) => boolean, list: T[]): number;
|
|
@@ -4913,7 +5154,7 @@ test('ramda 1', () => {
|
|
|
4913
5154
|
})
|
|
4914
5155
|
|
|
4915
5156
|
test('ramda 2', () => {
|
|
4916
|
-
expect(findLastIndex(even, [ 'zing' ])).
|
|
5157
|
+
expect(findLastIndex(even, [ 'zing' ])).toBe(-1)
|
|
4917
5158
|
})
|
|
4918
5159
|
|
|
4919
5160
|
test('ramda 3', () => {
|
|
@@ -4921,7 +5162,7 @@ test('ramda 3', () => {
|
|
|
4921
5162
|
})
|
|
4922
5163
|
|
|
4923
5164
|
test('ramda 4', () => {
|
|
4924
|
-
expect(findLastIndex(even, [])).
|
|
5165
|
+
expect(findLastIndex(even, [])).toBe(-1)
|
|
4925
5166
|
})
|
|
4926
5167
|
```
|
|
4927
5168
|
|
|
@@ -4929,7 +5170,7 @@ test('ramda 4', () => {
|
|
|
4929
5170
|
|
|
4930
5171
|
<details>
|
|
4931
5172
|
|
|
4932
|
-
<summary><strong>
|
|
5173
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
4933
5174
|
|
|
4934
5175
|
```typescript
|
|
4935
5176
|
import {findLastIndex} from 'rambda'
|
|
@@ -4967,7 +5208,7 @@ It deeply flattens an array.
|
|
|
4967
5208
|
|
|
4968
5209
|
<details>
|
|
4969
5210
|
|
|
4970
|
-
<summary>All
|
|
5211
|
+
<summary>All TypeScript definitions</summary>
|
|
4971
5212
|
|
|
4972
5213
|
```typescript
|
|
4973
5214
|
flatten<T>(list: any[]): T[];
|
|
@@ -5026,7 +5267,7 @@ test('readme example', () => {
|
|
|
5026
5267
|
|
|
5027
5268
|
<details>
|
|
5028
5269
|
|
|
5029
|
-
<summary><strong>
|
|
5270
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5030
5271
|
|
|
5031
5272
|
```typescript
|
|
5032
5273
|
import {flatten} from 'rambda'
|
|
@@ -5064,7 +5305,7 @@ It applies `iterable` function over all members of `list` and returns `list`.
|
|
|
5064
5305
|
|
|
5065
5306
|
<details>
|
|
5066
5307
|
|
|
5067
|
-
<summary>All
|
|
5308
|
+
<summary>All TypeScript definitions</summary>
|
|
5068
5309
|
|
|
5069
5310
|
```typescript
|
|
5070
5311
|
forEach<T>(fn: Iterator<T, void>, list: T[]): T[];
|
|
@@ -5188,7 +5429,7 @@ test('returns the input', () => {
|
|
|
5188
5429
|
|
|
5189
5430
|
<details>
|
|
5190
5431
|
|
|
5191
|
-
<summary><strong>
|
|
5432
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5192
5433
|
|
|
5193
5434
|
```typescript
|
|
5194
5435
|
import {forEach} from 'rambda'
|
|
@@ -5280,7 +5521,7 @@ It returns `true` if `obj` has property `prop`.
|
|
|
5280
5521
|
|
|
5281
5522
|
<details>
|
|
5282
5523
|
|
|
5283
|
-
<summary>All
|
|
5524
|
+
<summary>All TypeScript definitions</summary>
|
|
5284
5525
|
|
|
5285
5526
|
```typescript
|
|
5286
5527
|
has<T>(prop: string, obj: T): boolean;
|
|
@@ -5330,7 +5571,7 @@ test('with non-object', () => {
|
|
|
5330
5571
|
|
|
5331
5572
|
<details>
|
|
5332
5573
|
|
|
5333
|
-
<summary><strong>
|
|
5574
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5334
5575
|
|
|
5335
5576
|
```typescript
|
|
5336
5577
|
import {has} from 'rambda'
|
|
@@ -5365,7 +5606,7 @@ It will return true, if `input` object has truthy `path`(calculated with `R.path
|
|
|
5365
5606
|
|
|
5366
5607
|
<details>
|
|
5367
5608
|
|
|
5368
|
-
<summary>All
|
|
5609
|
+
<summary>All TypeScript definitions</summary>
|
|
5369
5610
|
|
|
5370
5611
|
```typescript
|
|
5371
5612
|
hasPath<T>(
|
|
@@ -5429,7 +5670,7 @@ test('when false', () => {
|
|
|
5429
5670
|
|
|
5430
5671
|
<details>
|
|
5431
5672
|
|
|
5432
|
-
<summary><strong>
|
|
5673
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5433
5674
|
|
|
5434
5675
|
```typescript
|
|
5435
5676
|
import {hasPath} from 'rambda'
|
|
@@ -5469,12 +5710,12 @@ It returns the first element of list or string `input`.
|
|
|
5469
5710
|
|
|
5470
5711
|
<details>
|
|
5471
5712
|
|
|
5472
|
-
<summary>All
|
|
5713
|
+
<summary>All TypeScript definitions</summary>
|
|
5473
5714
|
|
|
5474
5715
|
```typescript
|
|
5475
5716
|
head(input: string): string;
|
|
5476
5717
|
head(emptyList: []): undefined;
|
|
5477
|
-
head<T>(
|
|
5718
|
+
head<T extends readonly unknown[]>(array: T): FirstArrayElement<T>
|
|
5478
5719
|
```
|
|
5479
5720
|
|
|
5480
5721
|
</details>
|
|
@@ -5512,9 +5753,10 @@ test('head', () => {
|
|
|
5512
5753
|
|
|
5513
5754
|
<details>
|
|
5514
5755
|
|
|
5515
|
-
<summary><strong>
|
|
5756
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5516
5757
|
|
|
5517
5758
|
```typescript
|
|
5759
|
+
import {mixedList, mixedListConst} from '_internals/typescriptTestUtils'
|
|
5518
5760
|
import {head} from 'rambda'
|
|
5519
5761
|
|
|
5520
5762
|
describe('R.head', () => {
|
|
@@ -5522,12 +5764,18 @@ describe('R.head', () => {
|
|
|
5522
5764
|
const result = head('foo')
|
|
5523
5765
|
result // $ExpectType string
|
|
5524
5766
|
})
|
|
5525
|
-
|
|
5526
5767
|
it('array', () => {
|
|
5527
5768
|
const result = head([1, 2, 3])
|
|
5528
|
-
result // $ExpectType number
|
|
5769
|
+
result // $ExpectType number
|
|
5770
|
+
})
|
|
5771
|
+
it('mixed', () => {
|
|
5772
|
+
const result = head(mixedList)
|
|
5773
|
+
result // $ExpectType string | number
|
|
5774
|
+
})
|
|
5775
|
+
it('mixed const', () => {
|
|
5776
|
+
const result = head(mixedListConst)
|
|
5777
|
+
result // $ExpectType 1
|
|
5529
5778
|
})
|
|
5530
|
-
|
|
5531
5779
|
it('empty array - case 1', () => {
|
|
5532
5780
|
const result = head([])
|
|
5533
5781
|
result // $ExpectType undefined
|
|
@@ -5535,7 +5783,7 @@ describe('R.head', () => {
|
|
|
5535
5783
|
it('empty array - case 2', () => {
|
|
5536
5784
|
const list = ['foo', 'bar'].filter(x => x.startsWith('a'))
|
|
5537
5785
|
const result = head(list)
|
|
5538
|
-
result // $ExpectType string
|
|
5786
|
+
result // $ExpectType string
|
|
5539
5787
|
})
|
|
5540
5788
|
})
|
|
5541
5789
|
```
|
|
@@ -5567,7 +5815,7 @@ It just passes back the supplied `input` argument.
|
|
|
5567
5815
|
|
|
5568
5816
|
<details>
|
|
5569
5817
|
|
|
5570
|
-
<summary>All
|
|
5818
|
+
<summary>All TypeScript definitions</summary>
|
|
5571
5819
|
|
|
5572
5820
|
```typescript
|
|
5573
5821
|
identity<T>(input: T): T;
|
|
@@ -5605,7 +5853,7 @@ test('happy', () => {
|
|
|
5605
5853
|
|
|
5606
5854
|
<details>
|
|
5607
5855
|
|
|
5608
|
-
<summary><strong>
|
|
5856
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5609
5857
|
|
|
5610
5858
|
```typescript
|
|
5611
5859
|
import {identity} from 'rambda'
|
|
@@ -5641,7 +5889,7 @@ When `fn`` is called with `input` argument, it will return either `onTrue(input)
|
|
|
5641
5889
|
|
|
5642
5890
|
<details>
|
|
5643
5891
|
|
|
5644
|
-
<summary>All
|
|
5892
|
+
<summary>All TypeScript definitions</summary>
|
|
5645
5893
|
|
|
5646
5894
|
```typescript
|
|
5647
5895
|
ifElse<T, TFiltered extends T, TOnTrueResult, TOnFalseResult>(
|
|
@@ -5784,7 +6032,7 @@ test('simple arity of 2', () => {
|
|
|
5784
6032
|
|
|
5785
6033
|
<details>
|
|
5786
6034
|
|
|
5787
|
-
<summary><strong>
|
|
6035
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5788
6036
|
|
|
5789
6037
|
```typescript
|
|
5790
6038
|
import {ifElse} from 'rambda'
|
|
@@ -5846,7 +6094,7 @@ It increments a number.
|
|
|
5846
6094
|
|
|
5847
6095
|
```typescript
|
|
5848
6096
|
|
|
5849
|
-
includes(valueToFind:
|
|
6097
|
+
includes<T extends string>(valueToFind: T, input: string): boolean
|
|
5850
6098
|
```
|
|
5851
6099
|
|
|
5852
6100
|
If `input` is string, then this method work as native `String.includes`.
|
|
@@ -5857,11 +6105,11 @@ If `input` is array, then `R.equals` is used to define if `valueToFind` belongs
|
|
|
5857
6105
|
|
|
5858
6106
|
<details>
|
|
5859
6107
|
|
|
5860
|
-
<summary>All
|
|
6108
|
+
<summary>All TypeScript definitions</summary>
|
|
5861
6109
|
|
|
5862
6110
|
```typescript
|
|
5863
|
-
includes(valueToFind:
|
|
5864
|
-
includes(valueToFind:
|
|
6111
|
+
includes<T extends string>(valueToFind: T, input: string): boolean;
|
|
6112
|
+
includes<T extends string>(valueToFind: T): (input: string) => boolean;
|
|
5865
6113
|
includes<T>(valueToFind: T, input: T[]): boolean;
|
|
5866
6114
|
includes<T>(valueToFind: T): (input: T[]) => boolean;
|
|
5867
6115
|
```
|
|
@@ -5958,7 +6206,7 @@ test('throws on wrong input - match ramda behaviour', () => {
|
|
|
5958
6206
|
|
|
5959
6207
|
<details>
|
|
5960
6208
|
|
|
5961
|
-
<summary><strong>
|
|
6209
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
5962
6210
|
|
|
5963
6211
|
```typescript
|
|
5964
6212
|
import {includes} from 'rambda'
|
|
@@ -5969,10 +6217,13 @@ describe('R.includes', () => {
|
|
|
5969
6217
|
it('happy', () => {
|
|
5970
6218
|
const result = includes({a: {b: '1'}}, list)
|
|
5971
6219
|
result // $ExpectType boolean
|
|
6220
|
+
const result2 = includes('oo', ['f', 'oo'])
|
|
6221
|
+
result2 // $ExpectType boolean
|
|
5972
6222
|
})
|
|
5973
6223
|
it('with string', () => {
|
|
5974
|
-
const
|
|
5975
|
-
const
|
|
6224
|
+
const str = 'foo' as 'foo' | 'bar'
|
|
6225
|
+
const result = includes('oo', str)
|
|
6226
|
+
const curriedResult = includes('oo')(str)
|
|
5976
6227
|
|
|
5977
6228
|
result // $ExpectType boolean
|
|
5978
6229
|
curriedResult // $ExpectType boolean
|
|
@@ -6019,7 +6270,7 @@ It returns all but the last element of list or string `input`.
|
|
|
6019
6270
|
|
|
6020
6271
|
<details>
|
|
6021
6272
|
|
|
6022
|
-
<summary>All
|
|
6273
|
+
<summary>All TypeScript definitions</summary>
|
|
6023
6274
|
|
|
6024
6275
|
```typescript
|
|
6025
6276
|
init<T extends unknown[]>(input: T): T extends readonly [...infer U, any] ? U : [...T];
|
|
@@ -6075,7 +6326,7 @@ test('with string', () => {
|
|
|
6075
6326
|
|
|
6076
6327
|
<details>
|
|
6077
6328
|
|
|
6078
|
-
<summary><strong>
|
|
6329
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6079
6330
|
|
|
6080
6331
|
```typescript
|
|
6081
6332
|
import {init} from 'rambda'
|
|
@@ -6140,7 +6391,7 @@ It returns `true` if `x` is `empty`.
|
|
|
6140
6391
|
|
|
6141
6392
|
<details>
|
|
6142
6393
|
|
|
6143
|
-
<summary>All
|
|
6394
|
+
<summary>All TypeScript definitions</summary>
|
|
6144
6395
|
|
|
6145
6396
|
```typescript
|
|
6146
6397
|
isEmpty<T>(x: T): boolean;
|
|
@@ -6202,7 +6453,7 @@ test('happy', () => {
|
|
|
6202
6453
|
|
|
6203
6454
|
<details>
|
|
6204
6455
|
|
|
6205
|
-
<summary><strong>
|
|
6456
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6206
6457
|
|
|
6207
6458
|
```typescript
|
|
6208
6459
|
import {isEmpty} from 'rambda'
|
|
@@ -6232,7 +6483,7 @@ It returns `true` if `x` is either `null` or `undefined`.
|
|
|
6232
6483
|
|
|
6233
6484
|
<details>
|
|
6234
6485
|
|
|
6235
|
-
<summary>All
|
|
6486
|
+
<summary>All TypeScript definitions</summary>
|
|
6236
6487
|
|
|
6237
6488
|
```typescript
|
|
6238
6489
|
isNil(x: any): x is null | undefined;
|
|
@@ -6285,7 +6536,7 @@ It returns a string of all `list` instances joined with a `glue`.
|
|
|
6285
6536
|
|
|
6286
6537
|
<details>
|
|
6287
6538
|
|
|
6288
|
-
<summary>All
|
|
6539
|
+
<summary>All TypeScript definitions</summary>
|
|
6289
6540
|
|
|
6290
6541
|
```typescript
|
|
6291
6542
|
join<T>(glue: string, list: T[]): string;
|
|
@@ -6330,7 +6581,7 @@ test('curry', () => {
|
|
|
6330
6581
|
|
|
6331
6582
|
<details>
|
|
6332
6583
|
|
|
6333
|
-
<summary><strong>
|
|
6584
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6334
6585
|
|
|
6335
6586
|
```typescript
|
|
6336
6587
|
import {join} from 'rambda'
|
|
@@ -6360,7 +6611,7 @@ It applies list of function to a list of inputs.
|
|
|
6360
6611
|
|
|
6361
6612
|
<details>
|
|
6362
6613
|
|
|
6363
|
-
<summary>All
|
|
6614
|
+
<summary>All TypeScript definitions</summary>
|
|
6364
6615
|
|
|
6365
6616
|
```typescript
|
|
6366
6617
|
juxt<A extends any[], R1>(fns: [(...a: A) => R1]): (...a: A) => [R1];
|
|
@@ -6405,7 +6656,7 @@ test('happy', () => {
|
|
|
6405
6656
|
|
|
6406
6657
|
<details>
|
|
6407
6658
|
|
|
6408
|
-
<summary><strong>
|
|
6659
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6409
6660
|
|
|
6410
6661
|
```typescript
|
|
6411
6662
|
import {juxt} from 'rambda'
|
|
@@ -6436,7 +6687,7 @@ It applies `Object.keys` over `x` and returns its keys.
|
|
|
6436
6687
|
|
|
6437
6688
|
<details>
|
|
6438
6689
|
|
|
6439
|
-
<summary>All
|
|
6690
|
+
<summary>All TypeScript definitions</summary>
|
|
6440
6691
|
|
|
6441
6692
|
```typescript
|
|
6442
6693
|
keys<T extends object>(x: T): (keyof T)[];
|
|
@@ -6473,7 +6724,7 @@ test('happy', () => {
|
|
|
6473
6724
|
|
|
6474
6725
|
<details>
|
|
6475
6726
|
|
|
6476
|
-
<summary><strong>
|
|
6727
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6477
6728
|
|
|
6478
6729
|
```typescript
|
|
6479
6730
|
import {keys} from 'rambda'
|
|
@@ -6496,7 +6747,7 @@ describe('R.keys', () => {
|
|
|
6496
6747
|
|
|
6497
6748
|
```typescript
|
|
6498
6749
|
|
|
6499
|
-
last(
|
|
6750
|
+
last(input: string): string
|
|
6500
6751
|
```
|
|
6501
6752
|
|
|
6502
6753
|
It returns the last element of `input`, as the `input` can be either a string or an array.
|
|
@@ -6505,12 +6756,12 @@ It returns the last element of `input`, as the `input` can be either a string or
|
|
|
6505
6756
|
|
|
6506
6757
|
<details>
|
|
6507
6758
|
|
|
6508
|
-
<summary>All
|
|
6759
|
+
<summary>All TypeScript definitions</summary>
|
|
6509
6760
|
|
|
6510
6761
|
```typescript
|
|
6511
|
-
last(
|
|
6762
|
+
last(input: string): string;
|
|
6512
6763
|
last(emptyList: []): undefined;
|
|
6513
|
-
last<T extends
|
|
6764
|
+
last<T extends readonly unknown[]>(array: T): LastArrayElement<T>
|
|
6514
6765
|
```
|
|
6515
6766
|
|
|
6516
6767
|
</details>
|
|
@@ -6553,9 +6804,10 @@ test('with string', () => {
|
|
|
6553
6804
|
|
|
6554
6805
|
<details>
|
|
6555
6806
|
|
|
6556
|
-
<summary><strong>
|
|
6807
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6557
6808
|
|
|
6558
6809
|
```typescript
|
|
6810
|
+
import {mixedList, mixedListConst} from '_internals/typescriptTestUtils'
|
|
6559
6811
|
import {last} from 'rambda'
|
|
6560
6812
|
|
|
6561
6813
|
describe('R.last', () => {
|
|
@@ -6563,12 +6815,18 @@ describe('R.last', () => {
|
|
|
6563
6815
|
const result = last('foo')
|
|
6564
6816
|
result // $ExpectType string
|
|
6565
6817
|
})
|
|
6566
|
-
|
|
6567
6818
|
it('array', () => {
|
|
6568
6819
|
const result = last([1, 2, 3])
|
|
6569
|
-
result // $ExpectType number
|
|
6820
|
+
result // $ExpectType number
|
|
6821
|
+
})
|
|
6822
|
+
it('mixed', () => {
|
|
6823
|
+
const result = last(mixedList)
|
|
6824
|
+
result // $ExpectType string | number
|
|
6825
|
+
})
|
|
6826
|
+
it('mixed const', () => {
|
|
6827
|
+
const result = last(mixedListConst)
|
|
6828
|
+
result // $ExpectType "bar"
|
|
6570
6829
|
})
|
|
6571
|
-
|
|
6572
6830
|
it('empty array - case 1', () => {
|
|
6573
6831
|
const result = last([])
|
|
6574
6832
|
result // $ExpectType undefined
|
|
@@ -6576,7 +6834,7 @@ describe('R.last', () => {
|
|
|
6576
6834
|
it('empty array - case 2', () => {
|
|
6577
6835
|
const list = ['foo', 'bar'].filter(x => x.startsWith('a'))
|
|
6578
6836
|
const result = last(list)
|
|
6579
|
-
result // $ExpectType string
|
|
6837
|
+
result // $ExpectType string
|
|
6580
6838
|
})
|
|
6581
6839
|
})
|
|
6582
6840
|
```
|
|
@@ -6602,7 +6860,7 @@ If there is no such index, then `-1` is returned.
|
|
|
6602
6860
|
|
|
6603
6861
|
<details>
|
|
6604
6862
|
|
|
6605
|
-
<summary>All
|
|
6863
|
+
<summary>All TypeScript definitions</summary>
|
|
6606
6864
|
|
|
6607
6865
|
```typescript
|
|
6608
6866
|
lastIndexOf<T>(target: T, list: T[]): number;
|
|
@@ -6645,13 +6903,13 @@ test('with NaN', () => {
|
|
|
6645
6903
|
})
|
|
6646
6904
|
|
|
6647
6905
|
test('will throw with bad input', () => {
|
|
6648
|
-
expect(lastIndexOfRamda([], true)).
|
|
6906
|
+
expect(lastIndexOfRamda([], true)).toBe(-1)
|
|
6649
6907
|
expect(() => indexOf([], true)).toThrowErrorMatchingInlineSnapshot('"indexOf is not defined"')
|
|
6650
6908
|
})
|
|
6651
6909
|
|
|
6652
6910
|
test('without list of objects - no R.equals', () => {
|
|
6653
6911
|
expect(lastIndexOf(3, [ 1, 2, 3, 4 ])).toBe(2)
|
|
6654
|
-
expect(lastIndexOf(10)([ 1, 2, 3, 4 ])).
|
|
6912
|
+
expect(lastIndexOf(10)([ 1, 2, 3, 4 ])).toBe(-1)
|
|
6655
6913
|
})
|
|
6656
6914
|
|
|
6657
6915
|
test('list of objects uses R.equals', () => {
|
|
@@ -6699,7 +6957,7 @@ describe('brute force', () => {
|
|
|
6699
6957
|
|
|
6700
6958
|
<details>
|
|
6701
6959
|
|
|
6702
|
-
<summary><strong>
|
|
6960
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6703
6961
|
|
|
6704
6962
|
```typescript
|
|
6705
6963
|
import {lastIndexOf} from 'rambda'
|
|
@@ -6735,7 +6993,7 @@ It returns the `length` property of list or string `input`.
|
|
|
6735
6993
|
|
|
6736
6994
|
<details>
|
|
6737
6995
|
|
|
6738
|
-
<summary>All
|
|
6996
|
+
<summary>All TypeScript definitions</summary>
|
|
6739
6997
|
|
|
6740
6998
|
```typescript
|
|
6741
6999
|
length<T>(input: T[]): number;
|
|
@@ -6821,7 +7079,7 @@ The setter should not mutate the data structure.
|
|
|
6821
7079
|
|
|
6822
7080
|
<details>
|
|
6823
7081
|
|
|
6824
|
-
<summary>All
|
|
7082
|
+
<summary>All TypeScript definitions</summary>
|
|
6825
7083
|
|
|
6826
7084
|
```typescript
|
|
6827
7085
|
lens<T, U, V>(getter: (s: T) => U, setter: (a: U, s: T) => V): Lens;
|
|
@@ -6847,7 +7105,7 @@ export function lens(getter, setter){
|
|
|
6847
7105
|
|
|
6848
7106
|
<details>
|
|
6849
7107
|
|
|
6850
|
-
<summary><strong>
|
|
7108
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6851
7109
|
|
|
6852
7110
|
```typescript
|
|
6853
7111
|
import {lens, assoc} from 'rambda'
|
|
@@ -6884,7 +7142,7 @@ It returns a lens that focuses on specified `index`.
|
|
|
6884
7142
|
|
|
6885
7143
|
<details>
|
|
6886
7144
|
|
|
6887
|
-
<summary>All
|
|
7145
|
+
<summary>All TypeScript definitions</summary>
|
|
6888
7146
|
|
|
6889
7147
|
```typescript
|
|
6890
7148
|
lensIndex(index: number): Lens;
|
|
@@ -6975,7 +7233,7 @@ test('get (set(set s v1) v2) === v2', () => {
|
|
|
6975
7233
|
|
|
6976
7234
|
<details>
|
|
6977
7235
|
|
|
6978
|
-
<summary><strong>
|
|
7236
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
6979
7237
|
|
|
6980
7238
|
```typescript
|
|
6981
7239
|
import {view, lensIndex} from 'rambda'
|
|
@@ -7011,7 +7269,7 @@ It returns a lens that focuses on specified `path`.
|
|
|
7011
7269
|
|
|
7012
7270
|
<details>
|
|
7013
7271
|
|
|
7014
|
-
<summary>All
|
|
7272
|
+
<summary>All TypeScript definitions</summary>
|
|
7015
7273
|
|
|
7016
7274
|
```typescript
|
|
7017
7275
|
lensPath(path: RamdaPath): Lens;
|
|
@@ -7171,7 +7429,7 @@ test('get (set(set s v1) v2) === v2', () => {
|
|
|
7171
7429
|
|
|
7172
7430
|
<details>
|
|
7173
7431
|
|
|
7174
|
-
<summary><strong>
|
|
7432
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7175
7433
|
|
|
7176
7434
|
```typescript
|
|
7177
7435
|
import {lensPath, view} from 'rambda'
|
|
@@ -7225,7 +7483,7 @@ It returns a lens that focuses on specified property `prop`.
|
|
|
7225
7483
|
|
|
7226
7484
|
<details>
|
|
7227
7485
|
|
|
7228
|
-
<summary>All
|
|
7486
|
+
<summary>All TypeScript definitions</summary>
|
|
7229
7487
|
|
|
7230
7488
|
```typescript
|
|
7231
7489
|
lensProp(prop: string): {
|
|
@@ -7357,7 +7615,7 @@ test('get (set(set s v1) v2) === v2', () => {
|
|
|
7357
7615
|
|
|
7358
7616
|
<details>
|
|
7359
7617
|
|
|
7360
|
-
<summary><strong>
|
|
7618
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7361
7619
|
|
|
7362
7620
|
```typescript
|
|
7363
7621
|
import {lensProp, view} from 'rambda'
|
|
@@ -7399,7 +7657,7 @@ It works with both array and object.
|
|
|
7399
7657
|
|
|
7400
7658
|
<details>
|
|
7401
7659
|
|
|
7402
|
-
<summary>All
|
|
7660
|
+
<summary>All TypeScript definitions</summary>
|
|
7403
7661
|
|
|
7404
7662
|
```typescript
|
|
7405
7663
|
map<T, U>(fn: ObjectIterator<T, U>, iterable: Dictionary<T>): Dictionary<U>;
|
|
@@ -7540,7 +7798,7 @@ test('bad inputs difference between Ramda and Rambda', () => {
|
|
|
7540
7798
|
|
|
7541
7799
|
<details>
|
|
7542
7800
|
|
|
7543
|
-
<summary><strong>
|
|
7801
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7544
7802
|
|
|
7545
7803
|
```typescript
|
|
7546
7804
|
import {map} from 'rambda'
|
|
@@ -7641,7 +7899,7 @@ It works the same way as `R.map` does for objects. It is added as Ramda also has
|
|
|
7641
7899
|
|
|
7642
7900
|
<details>
|
|
7643
7901
|
|
|
7644
|
-
<summary>All
|
|
7902
|
+
<summary>All TypeScript definitions</summary>
|
|
7645
7903
|
|
|
7646
7904
|
```typescript
|
|
7647
7905
|
mapObjIndexed<T>(fn: ObjectIterator<T, T>, iterable: Dictionary<T>): Dictionary<T>;
|
|
@@ -7654,7 +7912,7 @@ mapObjIndexed<T, U>(fn: ObjectIterator<T, U>): (iterable: Dictionary<T>) => Dict
|
|
|
7654
7912
|
|
|
7655
7913
|
<details>
|
|
7656
7914
|
|
|
7657
|
-
<summary><strong>
|
|
7915
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7658
7916
|
|
|
7659
7917
|
```typescript
|
|
7660
7918
|
import {mapObjIndexed} from 'rambda'
|
|
@@ -7718,7 +7976,7 @@ Curried version of `String.prototype.match` which returns empty array, when ther
|
|
|
7718
7976
|
|
|
7719
7977
|
<details>
|
|
7720
7978
|
|
|
7721
|
-
<summary>All
|
|
7979
|
+
<summary>All TypeScript definitions</summary>
|
|
7722
7980
|
|
|
7723
7981
|
```typescript
|
|
7724
7982
|
match(regExpression: RegExp, str: string): string[];
|
|
@@ -7775,7 +8033,7 @@ test('throwing', () => {
|
|
|
7775
8033
|
|
|
7776
8034
|
<details>
|
|
7777
8035
|
|
|
7778
|
-
<summary><strong>
|
|
8036
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7779
8037
|
|
|
7780
8038
|
```typescript
|
|
7781
8039
|
import {match} from 'rambda'
|
|
@@ -7835,7 +8093,7 @@ It returns the mean value of `list` input.
|
|
|
7835
8093
|
|
|
7836
8094
|
<details>
|
|
7837
8095
|
|
|
7838
|
-
<summary>All
|
|
8096
|
+
<summary>All TypeScript definitions</summary>
|
|
7839
8097
|
|
|
7840
8098
|
```typescript
|
|
7841
8099
|
mean(list: number[]): number;
|
|
@@ -7877,7 +8135,7 @@ test('with NaN', () => {
|
|
|
7877
8135
|
|
|
7878
8136
|
<details>
|
|
7879
8137
|
|
|
7880
|
-
<summary><strong>
|
|
8138
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7881
8139
|
|
|
7882
8140
|
```typescript
|
|
7883
8141
|
import {mean} from 'rambda'
|
|
@@ -7908,7 +8166,7 @@ It returns the median value of `list` input.
|
|
|
7908
8166
|
|
|
7909
8167
|
<details>
|
|
7910
8168
|
|
|
7911
|
-
<summary>All
|
|
8169
|
+
<summary>All TypeScript definitions</summary>
|
|
7912
8170
|
|
|
7913
8171
|
```typescript
|
|
7914
8172
|
median(list: number[]): number;
|
|
@@ -7963,7 +8221,7 @@ test('with empty array', () => {
|
|
|
7963
8221
|
|
|
7964
8222
|
<details>
|
|
7965
8223
|
|
|
7966
|
-
<summary><strong>
|
|
8224
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
7967
8225
|
|
|
7968
8226
|
```typescript
|
|
7969
8227
|
import {median} from 'rambda'
|
|
@@ -8000,7 +8258,7 @@ It merges all objects of `list` array sequentially and returns the result.
|
|
|
8000
8258
|
|
|
8001
8259
|
<details>
|
|
8002
8260
|
|
|
8003
|
-
<summary>All
|
|
8261
|
+
<summary>All TypeScript definitions</summary>
|
|
8004
8262
|
|
|
8005
8263
|
```typescript
|
|
8006
8264
|
mergeAll<T>(list: object[]): T;
|
|
@@ -8053,13 +8311,36 @@ test('case 2', () => {
|
|
|
8053
8311
|
baz : 3,
|
|
8054
8312
|
})
|
|
8055
8313
|
})
|
|
8314
|
+
|
|
8315
|
+
describe('acts as if nil values are simply empty objects', () => {
|
|
8316
|
+
it('if the first object is nil', () => {
|
|
8317
|
+
expect(mergeAll([ null, { foo : 1 }, { foo : 2 }, { bar : 2 } ])).toEqual({
|
|
8318
|
+
foo : 2,
|
|
8319
|
+
bar : 2,
|
|
8320
|
+
})
|
|
8321
|
+
})
|
|
8322
|
+
|
|
8323
|
+
it('if the last object is nil', () => {
|
|
8324
|
+
expect(mergeAll([ { foo : 1 }, { foo : 2 }, { bar : 2 }, undefined ])).toEqual({
|
|
8325
|
+
foo : 2,
|
|
8326
|
+
bar : 2,
|
|
8327
|
+
})
|
|
8328
|
+
})
|
|
8329
|
+
|
|
8330
|
+
it('if an intermediate object is nil', () => {
|
|
8331
|
+
expect(mergeAll([ { foo : 1 }, { foo : 2 }, null, { bar : 2 } ])).toEqual({
|
|
8332
|
+
foo : 2,
|
|
8333
|
+
bar : 2,
|
|
8334
|
+
})
|
|
8335
|
+
})
|
|
8336
|
+
})
|
|
8056
8337
|
```
|
|
8057
8338
|
|
|
8058
8339
|
</details>
|
|
8059
8340
|
|
|
8060
8341
|
<details>
|
|
8061
8342
|
|
|
8062
|
-
<summary><strong>
|
|
8343
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8063
8344
|
|
|
8064
8345
|
```typescript
|
|
8065
8346
|
import {mergeAll} from 'rambda'
|
|
@@ -8100,7 +8381,7 @@ Creates a new object with the own properties of the first object merged with the
|
|
|
8100
8381
|
|
|
8101
8382
|
<details>
|
|
8102
8383
|
|
|
8103
|
-
<summary>All
|
|
8384
|
+
<summary>All TypeScript definitions</summary>
|
|
8104
8385
|
|
|
8105
8386
|
```typescript
|
|
8106
8387
|
mergeDeepRight<Output>(target: object, newProps: object): Output;
|
|
@@ -8280,7 +8561,7 @@ test('functions are not discarded', () => {
|
|
|
8280
8561
|
|
|
8281
8562
|
<details>
|
|
8282
8563
|
|
|
8283
|
-
<summary><strong>
|
|
8564
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8284
8565
|
|
|
8285
8566
|
```typescript
|
|
8286
8567
|
import {mergeDeepRight} from 'rambda'
|
|
@@ -8314,7 +8595,7 @@ Same as `R.merge`, but in opposite direction.
|
|
|
8314
8595
|
|
|
8315
8596
|
<details>
|
|
8316
8597
|
|
|
8317
|
-
<summary>All
|
|
8598
|
+
<summary>All TypeScript definitions</summary>
|
|
8318
8599
|
|
|
8319
8600
|
```typescript
|
|
8320
8601
|
mergeLeft<Output>(newProps: object, target: object): Output;
|
|
@@ -8378,7 +8659,7 @@ test('when undefined or null instead of object', () => {
|
|
|
8378
8659
|
|
|
8379
8660
|
<details>
|
|
8380
8661
|
|
|
8381
|
-
<summary><strong>
|
|
8662
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8382
8663
|
|
|
8383
8664
|
```typescript
|
|
8384
8665
|
import {mergeLeft} from 'rambda'
|
|
@@ -8423,7 +8704,7 @@ It takes two objects and a function, which will be used when there is an overlap
|
|
|
8423
8704
|
|
|
8424
8705
|
<details>
|
|
8425
8706
|
|
|
8426
|
-
<summary>All
|
|
8707
|
+
<summary>All TypeScript definitions</summary>
|
|
8427
8708
|
|
|
8428
8709
|
```typescript
|
|
8429
8710
|
mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>, b: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -8444,8 +8725,10 @@ mergeWith<Output>(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => Output;
|
|
|
8444
8725
|
import { curry } from './curry.js'
|
|
8445
8726
|
|
|
8446
8727
|
function mergeWithFn(
|
|
8447
|
-
mergeFn,
|
|
8728
|
+
mergeFn, aInput, bInput
|
|
8448
8729
|
){
|
|
8730
|
+
const a = aInput ?? {}
|
|
8731
|
+
const b = bInput ?? {}
|
|
8449
8732
|
const willReturn = {}
|
|
8450
8733
|
|
|
8451
8734
|
Object.keys(a).forEach(key => {
|
|
@@ -8501,13 +8784,46 @@ test('happy', () => {
|
|
|
8501
8784
|
}
|
|
8502
8785
|
expect(result).toEqual(expected)
|
|
8503
8786
|
})
|
|
8787
|
+
|
|
8788
|
+
// https://github.com/ramda/ramda/pull/3222/files#diff-d925d9188b478d2f1d4b26012c6dddac374f9e9d7a336604d654b9a113bfc857
|
|
8789
|
+
describe('acts as if nil values are simply empty objects', () => {
|
|
8790
|
+
it('if the first object is nil and the second empty', () => {
|
|
8791
|
+
expect(mergeWith(
|
|
8792
|
+
concat, undefined, {}
|
|
8793
|
+
)).toEqual({})
|
|
8794
|
+
})
|
|
8795
|
+
|
|
8796
|
+
it('if the first object is empty and the second nil', () => {
|
|
8797
|
+
expect(mergeWith(
|
|
8798
|
+
concat, {}, null
|
|
8799
|
+
)).toEqual({})
|
|
8800
|
+
})
|
|
8801
|
+
|
|
8802
|
+
it('if both objects are nil', () => {
|
|
8803
|
+
expect(mergeWith(
|
|
8804
|
+
concat, undefined, null
|
|
8805
|
+
)).toEqual({})
|
|
8806
|
+
})
|
|
8807
|
+
|
|
8808
|
+
it('if the first object is not empty and the second is nil', () => {
|
|
8809
|
+
expect(mergeWith(
|
|
8810
|
+
concat, { a : 'a' }, null
|
|
8811
|
+
)).toEqual({ a : 'a' })
|
|
8812
|
+
})
|
|
8813
|
+
|
|
8814
|
+
it('if the first object is nil and the second is not empty', () => {
|
|
8815
|
+
expect(mergeWith(
|
|
8816
|
+
concat, undefined, { a : 'a' }
|
|
8817
|
+
)).toEqual({ a : 'a' })
|
|
8818
|
+
})
|
|
8819
|
+
})
|
|
8504
8820
|
```
|
|
8505
8821
|
|
|
8506
8822
|
</details>
|
|
8507
8823
|
|
|
8508
8824
|
<details>
|
|
8509
8825
|
|
|
8510
|
-
<summary><strong>
|
|
8826
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8511
8827
|
|
|
8512
8828
|
```typescript
|
|
8513
8829
|
import {concat, mergeWith} from 'rambda'
|
|
@@ -8589,7 +8905,7 @@ modify<T extends object, K extends keyof T, P>(
|
|
|
8589
8905
|
|
|
8590
8906
|
<details>
|
|
8591
8907
|
|
|
8592
|
-
<summary>All
|
|
8908
|
+
<summary>All TypeScript definitions</summary>
|
|
8593
8909
|
|
|
8594
8910
|
```typescript
|
|
8595
8911
|
modify<T extends object, K extends keyof T, P>(
|
|
@@ -8738,7 +9054,7 @@ describe('brute force', () => {
|
|
|
8738
9054
|
|
|
8739
9055
|
<details>
|
|
8740
9056
|
|
|
8741
|
-
<summary><strong>
|
|
9057
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8742
9058
|
|
|
8743
9059
|
```typescript
|
|
8744
9060
|
import {modify, add} from 'rambda'
|
|
@@ -8777,7 +9093,7 @@ It changes a property of object on the base of provided path and transformer fun
|
|
|
8777
9093
|
|
|
8778
9094
|
<details>
|
|
8779
9095
|
|
|
8780
|
-
<summary>All
|
|
9096
|
+
<summary>All TypeScript definitions</summary>
|
|
8781
9097
|
|
|
8782
9098
|
```typescript
|
|
8783
9099
|
modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown, object: Record<string, unknown>): T;
|
|
@@ -8856,7 +9172,7 @@ test('with array', () => {
|
|
|
8856
9172
|
|
|
8857
9173
|
<details>
|
|
8858
9174
|
|
|
8859
|
-
<summary><strong>
|
|
9175
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8860
9176
|
|
|
8861
9177
|
```typescript
|
|
8862
9178
|
import {modifyPath} from 'rambda'
|
|
@@ -8925,7 +9241,7 @@ It returns `true`, if all members of array `list` returns `false`, when applied
|
|
|
8925
9241
|
|
|
8926
9242
|
<details>
|
|
8927
9243
|
|
|
8928
|
-
<summary>All
|
|
9244
|
+
<summary>All TypeScript definitions</summary>
|
|
8929
9245
|
|
|
8930
9246
|
```typescript
|
|
8931
9247
|
none<T>(predicate: (x: T) => boolean, list: T[]): boolean;
|
|
@@ -8974,7 +9290,7 @@ test('when false curried', () => {
|
|
|
8974
9290
|
|
|
8975
9291
|
<details>
|
|
8976
9292
|
|
|
8977
|
-
<summary><strong>
|
|
9293
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
8978
9294
|
|
|
8979
9295
|
```typescript
|
|
8980
9296
|
import {none} from 'rambda'
|
|
@@ -9004,70 +9320,6 @@ describe('R.none', () => {
|
|
|
9004
9320
|
|
|
9005
9321
|
[](#none)
|
|
9006
9322
|
|
|
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
|
-
|
|
9018
|
-
<details>
|
|
9019
|
-
|
|
9020
|
-
<summary>All Typescript definitions</summary>
|
|
9021
|
-
|
|
9022
|
-
```typescript
|
|
9023
|
-
nop(): void;
|
|
9024
|
-
```
|
|
9025
|
-
|
|
9026
|
-
</details>
|
|
9027
|
-
|
|
9028
|
-
<details>
|
|
9029
|
-
|
|
9030
|
-
<summary><strong>R.nop</strong> source</summary>
|
|
9031
|
-
|
|
9032
|
-
```javascript
|
|
9033
|
-
export function nop(){}
|
|
9034
|
-
```
|
|
9035
|
-
|
|
9036
|
-
</details>
|
|
9037
|
-
|
|
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
|
-
[](#nop)
|
|
9070
|
-
|
|
9071
9323
|
### not
|
|
9072
9324
|
|
|
9073
9325
|
```typescript
|
|
@@ -9081,7 +9333,7 @@ It returns a boolean negated version of `input`.
|
|
|
9081
9333
|
|
|
9082
9334
|
<details>
|
|
9083
9335
|
|
|
9084
|
-
<summary>All
|
|
9336
|
+
<summary>All TypeScript definitions</summary>
|
|
9085
9337
|
|
|
9086
9338
|
```typescript
|
|
9087
9339
|
not(input: any): boolean;
|
|
@@ -9120,7 +9372,7 @@ test('not', () => {
|
|
|
9120
9372
|
|
|
9121
9373
|
<details>
|
|
9122
9374
|
|
|
9123
|
-
<summary><strong>
|
|
9375
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9124
9376
|
|
|
9125
9377
|
```typescript
|
|
9126
9378
|
import {not} from 'rambda'
|
|
@@ -9151,7 +9403,7 @@ Curried version of `input[index]`.
|
|
|
9151
9403
|
|
|
9152
9404
|
<details>
|
|
9153
9405
|
|
|
9154
|
-
<summary>All
|
|
9406
|
+
<summary>All TypeScript definitions</summary>
|
|
9155
9407
|
|
|
9156
9408
|
```typescript
|
|
9157
9409
|
nth(index: number, input: string): string;
|
|
@@ -9214,7 +9466,7 @@ test('with negative index', () => {
|
|
|
9214
9466
|
|
|
9215
9467
|
<details>
|
|
9216
9468
|
|
|
9217
|
-
<summary><strong>
|
|
9469
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9218
9470
|
|
|
9219
9471
|
```typescript
|
|
9220
9472
|
import {nth} from 'rambda'
|
|
@@ -9272,7 +9524,7 @@ of<T>(x: T): T[]
|
|
|
9272
9524
|
|
|
9273
9525
|
<details>
|
|
9274
9526
|
|
|
9275
|
-
<summary>All
|
|
9527
|
+
<summary>All TypeScript definitions</summary>
|
|
9276
9528
|
|
|
9277
9529
|
```typescript
|
|
9278
9530
|
of<T>(x: T): T[];
|
|
@@ -9310,7 +9562,7 @@ test('happy', () => {
|
|
|
9310
9562
|
|
|
9311
9563
|
<details>
|
|
9312
9564
|
|
|
9313
|
-
<summary><strong>
|
|
9565
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9314
9566
|
|
|
9315
9567
|
```typescript
|
|
9316
9568
|
import {of} from 'rambda'
|
|
@@ -9348,7 +9600,7 @@ It returns a partial copy of an `obj` without `propsToOmit` properties.
|
|
|
9348
9600
|
|
|
9349
9601
|
<details>
|
|
9350
9602
|
|
|
9351
|
-
<summary>All
|
|
9603
|
+
<summary>All TypeScript definitions</summary>
|
|
9352
9604
|
|
|
9353
9605
|
```typescript
|
|
9354
9606
|
omit<T, K extends string>(propsToOmit: K[], obj: T): Omit<T, K>;
|
|
@@ -9438,7 +9690,7 @@ test('happy', () => {
|
|
|
9438
9690
|
|
|
9439
9691
|
<details>
|
|
9440
9692
|
|
|
9441
|
-
<summary><strong>
|
|
9693
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9442
9694
|
|
|
9443
9695
|
```typescript
|
|
9444
9696
|
import {omit} from 'rambda'
|
|
@@ -9549,7 +9801,7 @@ It returns a function, which invokes only once `fn` function.
|
|
|
9549
9801
|
|
|
9550
9802
|
<details>
|
|
9551
9803
|
|
|
9552
|
-
<summary>All
|
|
9804
|
+
<summary>All TypeScript definitions</summary>
|
|
9553
9805
|
|
|
9554
9806
|
```typescript
|
|
9555
9807
|
once<T extends AnyFunction>(func: T): T;
|
|
@@ -9627,7 +9879,7 @@ test('happy path', () => {
|
|
|
9627
9879
|
|
|
9628
9880
|
<details>
|
|
9629
9881
|
|
|
9630
|
-
<summary><strong>
|
|
9882
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9631
9883
|
|
|
9632
9884
|
```typescript
|
|
9633
9885
|
import {once} from 'rambda'
|
|
@@ -9669,7 +9921,7 @@ It returns a copied **Object** or **Array** with modified value received by appl
|
|
|
9669
9921
|
|
|
9670
9922
|
<details>
|
|
9671
9923
|
|
|
9672
|
-
<summary>All
|
|
9924
|
+
<summary>All TypeScript definitions</summary>
|
|
9673
9925
|
|
|
9674
9926
|
```typescript
|
|
9675
9927
|
over<T>(lens: Lens, fn: Arity1Fn, value: T): T;
|
|
@@ -9780,7 +10032,7 @@ The name comes from the fact that you partially inject the inputs.
|
|
|
9780
10032
|
|
|
9781
10033
|
<details>
|
|
9782
10034
|
|
|
9783
|
-
<summary>All
|
|
10035
|
+
<summary>All TypeScript definitions</summary>
|
|
9784
10036
|
|
|
9785
10037
|
```typescript
|
|
9786
10038
|
partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;
|
|
@@ -9887,7 +10139,7 @@ test('ramda spec', () => {
|
|
|
9887
10139
|
|
|
9888
10140
|
<details>
|
|
9889
10141
|
|
|
9890
|
-
<summary><strong>
|
|
10142
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
9891
10143
|
|
|
9892
10144
|
```typescript
|
|
9893
10145
|
import {partial} from 'rambda'
|
|
@@ -9933,7 +10185,7 @@ Initially the function knows only a part from the whole input object and then `R
|
|
|
9933
10185
|
|
|
9934
10186
|
<details>
|
|
9935
10187
|
|
|
9936
|
-
<summary>All
|
|
10188
|
+
<summary>All TypeScript definitions</summary>
|
|
9937
10189
|
|
|
9938
10190
|
```typescript
|
|
9939
10191
|
partialObject<Input, PartialInput, Output>(
|
|
@@ -10033,7 +10285,7 @@ test('async function throwing an error', async () => {
|
|
|
10033
10285
|
|
|
10034
10286
|
<details>
|
|
10035
10287
|
|
|
10036
|
-
<summary><strong>
|
|
10288
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10037
10289
|
|
|
10038
10290
|
```typescript
|
|
10039
10291
|
import {partialObject, delay} from 'rambda'
|
|
@@ -10093,7 +10345,7 @@ It will return array of two objects/arrays according to `predicate` function. Th
|
|
|
10093
10345
|
|
|
10094
10346
|
<details>
|
|
10095
10347
|
|
|
10096
|
-
<summary>All
|
|
10348
|
+
<summary>All TypeScript definitions</summary>
|
|
10097
10349
|
|
|
10098
10350
|
```typescript
|
|
10099
10351
|
partition<T>(
|
|
@@ -10243,7 +10495,7 @@ test('readme example', () => {
|
|
|
10243
10495
|
|
|
10244
10496
|
<details>
|
|
10245
10497
|
|
|
10246
|
-
<summary><strong>
|
|
10498
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10247
10499
|
|
|
10248
10500
|
```typescript
|
|
10249
10501
|
import {partition} from 'rambda'
|
|
@@ -10306,7 +10558,7 @@ It will return `undefined`, if such path is not found.
|
|
|
10306
10558
|
|
|
10307
10559
|
<details>
|
|
10308
10560
|
|
|
10309
|
-
<summary>All
|
|
10561
|
+
<summary>All TypeScript definitions</summary>
|
|
10310
10562
|
|
|
10311
10563
|
```typescript
|
|
10312
10564
|
path<S, K0 extends keyof S = keyof S>(path: [K0], obj: S): S[K0];
|
|
@@ -10356,12 +10608,7 @@ path<T>(pathToSearch: RamdaPath, obj: any): T | undefined;
|
|
|
10356
10608
|
```javascript
|
|
10357
10609
|
import { createPath } from './_internals/createPath.js'
|
|
10358
10610
|
|
|
10359
|
-
export function
|
|
10360
|
-
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
10361
|
-
|
|
10362
|
-
if (obj === null || obj === undefined){
|
|
10363
|
-
return undefined
|
|
10364
|
-
}
|
|
10611
|
+
export function pathFn(pathInput, obj){
|
|
10365
10612
|
let willReturn = obj
|
|
10366
10613
|
let counter = 0
|
|
10367
10614
|
|
|
@@ -10379,6 +10626,16 @@ export function path(pathInput, obj){
|
|
|
10379
10626
|
|
|
10380
10627
|
return willReturn
|
|
10381
10628
|
}
|
|
10629
|
+
|
|
10630
|
+
export function path(pathInput, obj){
|
|
10631
|
+
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
10632
|
+
|
|
10633
|
+
if (obj === null || obj === undefined){
|
|
10634
|
+
return undefined
|
|
10635
|
+
}
|
|
10636
|
+
|
|
10637
|
+
return pathFn(pathInput, obj)
|
|
10638
|
+
}
|
|
10382
10639
|
```
|
|
10383
10640
|
|
|
10384
10641
|
</details>
|
|
@@ -10428,7 +10685,7 @@ test('null is not a valid path', () => {
|
|
|
10428
10685
|
|
|
10429
10686
|
<details>
|
|
10430
10687
|
|
|
10431
|
-
<summary><strong>
|
|
10688
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10432
10689
|
|
|
10433
10690
|
```typescript
|
|
10434
10691
|
import {path} from 'rambda'
|
|
@@ -10508,7 +10765,7 @@ It returns `true` if `pathToSearch` of `input` object is equal to `target` value
|
|
|
10508
10765
|
|
|
10509
10766
|
<details>
|
|
10510
10767
|
|
|
10511
|
-
<summary>All
|
|
10768
|
+
<summary>All TypeScript definitions</summary>
|
|
10512
10769
|
|
|
10513
10770
|
```typescript
|
|
10514
10771
|
pathEq(pathToSearch: Path, target: any, input: any): boolean;
|
|
@@ -10578,7 +10835,7 @@ test('when wrong path', () => {
|
|
|
10578
10835
|
|
|
10579
10836
|
<details>
|
|
10580
10837
|
|
|
10581
|
-
<summary><strong>
|
|
10838
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10582
10839
|
|
|
10583
10840
|
```typescript
|
|
10584
10841
|
import {pathEq} from 'rambda'
|
|
@@ -10642,7 +10899,7 @@ It reads `obj` input and returns either `R.path(pathToSearch, Record<string, unk
|
|
|
10642
10899
|
|
|
10643
10900
|
<details>
|
|
10644
10901
|
|
|
10645
|
-
<summary>All
|
|
10902
|
+
<summary>All TypeScript definitions</summary>
|
|
10646
10903
|
|
|
10647
10904
|
```typescript
|
|
10648
10905
|
pathOr<T>(defaultValue: T, pathToSearch: Path, obj: any): T;
|
|
@@ -10726,7 +10983,7 @@ test('curry case (x,y)(z)', () => {
|
|
|
10726
10983
|
|
|
10727
10984
|
<details>
|
|
10728
10985
|
|
|
10729
|
-
<summary><strong>
|
|
10986
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10730
10987
|
|
|
10731
10988
|
```typescript
|
|
10732
10989
|
import {pathOr} from 'rambda'
|
|
@@ -10770,7 +11027,7 @@ Because it calls `R.path`, then `singlePath` can be either string or a list.
|
|
|
10770
11027
|
|
|
10771
11028
|
<details>
|
|
10772
11029
|
|
|
10773
|
-
<summary>All
|
|
11030
|
+
<summary>All TypeScript definitions</summary>
|
|
10774
11031
|
|
|
10775
11032
|
```typescript
|
|
10776
11033
|
paths<Input, T>(pathsToSearch: Path[], obj: Input): (T | undefined)[];
|
|
@@ -10868,7 +11125,7 @@ test('returns undefined for items not found', () => {
|
|
|
10868
11125
|
|
|
10869
11126
|
<details>
|
|
10870
11127
|
|
|
10871
|
-
<summary><strong>
|
|
11128
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
10872
11129
|
|
|
10873
11130
|
```typescript
|
|
10874
11131
|
import {paths} from 'rambda'
|
|
@@ -10925,7 +11182,7 @@ String annotation of `propsToPick` is one of the differences between `Rambda` an
|
|
|
10925
11182
|
|
|
10926
11183
|
<details>
|
|
10927
11184
|
|
|
10928
|
-
<summary>All
|
|
11185
|
+
<summary>All TypeScript definitions</summary>
|
|
10929
11186
|
|
|
10930
11187
|
```typescript
|
|
10931
11188
|
pick<T, K extends string | number | symbol>(propsToPick: K[], input: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
|
|
@@ -11057,7 +11314,7 @@ test('with symbol', () => {
|
|
|
11057
11314
|
|
|
11058
11315
|
<details>
|
|
11059
11316
|
|
|
11060
|
-
<summary><strong>
|
|
11317
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11061
11318
|
|
|
11062
11319
|
```typescript
|
|
11063
11320
|
import {pick} from 'rambda'
|
|
@@ -11128,7 +11385,7 @@ Same as `R.pick` but it won't skip the missing props, i.e. it will assign them t
|
|
|
11128
11385
|
|
|
11129
11386
|
<details>
|
|
11130
11387
|
|
|
11131
|
-
<summary>All
|
|
11388
|
+
<summary>All TypeScript definitions</summary>
|
|
11132
11389
|
|
|
11133
11390
|
```typescript
|
|
11134
11391
|
pickAll<T, K extends keyof T>(propsToPicks: K[], input: T): Pick<T, K>;
|
|
@@ -11218,7 +11475,7 @@ test('with array as condition', () => {
|
|
|
11218
11475
|
|
|
11219
11476
|
<details>
|
|
11220
11477
|
|
|
11221
|
-
<summary><strong>
|
|
11478
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11222
11479
|
|
|
11223
11480
|
```typescript
|
|
11224
11481
|
import {pickAll} from 'rambda'
|
|
@@ -11299,7 +11556,7 @@ It returns list of the values of `property` taken from the all objects inside `l
|
|
|
11299
11556
|
|
|
11300
11557
|
<details>
|
|
11301
11558
|
|
|
11302
|
-
<summary>All
|
|
11559
|
+
<summary>All TypeScript definitions</summary>
|
|
11303
11560
|
|
|
11304
11561
|
```typescript
|
|
11305
11562
|
pluck<K extends keyof T, T>(property: K, list: T[]): T[K][];
|
|
@@ -11359,7 +11616,7 @@ test('with number', () => {
|
|
|
11359
11616
|
|
|
11360
11617
|
<details>
|
|
11361
11618
|
|
|
11362
|
-
<summary><strong>
|
|
11619
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11363
11620
|
|
|
11364
11621
|
```typescript
|
|
11365
11622
|
import {pluck} from 'rambda'
|
|
@@ -11411,7 +11668,7 @@ It adds element `x` at the beginning of `list`.
|
|
|
11411
11668
|
|
|
11412
11669
|
<details>
|
|
11413
11670
|
|
|
11414
|
-
<summary>All
|
|
11671
|
+
<summary>All TypeScript definitions</summary>
|
|
11415
11672
|
|
|
11416
11673
|
```typescript
|
|
11417
11674
|
prepend<T>(x: T, input: T[]): T[];
|
|
@@ -11465,7 +11722,7 @@ test('with string instead of array', () => {
|
|
|
11465
11722
|
|
|
11466
11723
|
<details>
|
|
11467
11724
|
|
|
11468
|
-
<summary><strong>
|
|
11725
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11469
11726
|
|
|
11470
11727
|
```typescript
|
|
11471
11728
|
import {prepend} from 'rambda'
|
|
@@ -11501,7 +11758,7 @@ product(list: number[]): number
|
|
|
11501
11758
|
|
|
11502
11759
|
<details>
|
|
11503
11760
|
|
|
11504
|
-
<summary>All
|
|
11761
|
+
<summary>All TypeScript definitions</summary>
|
|
11505
11762
|
|
|
11506
11763
|
```typescript
|
|
11507
11764
|
product(list: number[]): number;
|
|
@@ -11543,7 +11800,7 @@ test('bad input', () => {
|
|
|
11543
11800
|
|
|
11544
11801
|
<details>
|
|
11545
11802
|
|
|
11546
|
-
<summary><strong>
|
|
11803
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11547
11804
|
|
|
11548
11805
|
```typescript
|
|
11549
11806
|
import {product} from 'rambda'
|
|
@@ -11576,7 +11833,7 @@ If there is no such property, it returns `undefined`.
|
|
|
11576
11833
|
|
|
11577
11834
|
<details>
|
|
11578
11835
|
|
|
11579
|
-
<summary>All
|
|
11836
|
+
<summary>All TypeScript definitions</summary>
|
|
11580
11837
|
|
|
11581
11838
|
```typescript
|
|
11582
11839
|
prop<P extends keyof never, T>(propToFind: P, value: T): Prop<T, P>;
|
|
@@ -11630,49 +11887,33 @@ test('prop', () => {
|
|
|
11630
11887
|
|
|
11631
11888
|
<details>
|
|
11632
11889
|
|
|
11633
|
-
<summary><strong>
|
|
11890
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11634
11891
|
|
|
11635
11892
|
```typescript
|
|
11636
|
-
import {
|
|
11893
|
+
import {prop} from 'rambda'
|
|
11637
11894
|
|
|
11638
11895
|
describe('R.prop', () => {
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11896
|
+
interface Foo {
|
|
11897
|
+
a: number,
|
|
11898
|
+
b: string,
|
|
11899
|
+
c?: number,
|
|
11643
11900
|
}
|
|
11901
|
+
const obj: Foo = {a: 1, b: 'foo'}
|
|
11644
11902
|
|
|
11645
11903
|
it('issue #553', () => {
|
|
11646
|
-
const result =
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
})
|
|
11657
|
-
it('curried', () => {
|
|
11658
|
-
const result = prop('b')(obj)
|
|
11659
|
-
|
|
11660
|
-
result // $ExpectType string
|
|
11661
|
-
})
|
|
11662
|
-
it('curried with explicit object type', () => {
|
|
11663
|
-
const result = prop<'a', Something>('a')(obj)
|
|
11664
|
-
|
|
11665
|
-
result // $ExpectType number | undefined
|
|
11666
|
-
})
|
|
11667
|
-
it('curried with implicit object type', () => {
|
|
11668
|
-
const result = pipe(value => value as Something, prop('b'))(obj)
|
|
11669
|
-
|
|
11670
|
-
result // $ExpectType undefined
|
|
11671
|
-
})
|
|
11672
|
-
it('curried with explicit result type', () => {
|
|
11673
|
-
const result = prop<'b', string>('b')(obj)
|
|
11904
|
+
const result = {
|
|
11905
|
+
a: prop('a', obj),
|
|
11906
|
+
b: prop('b', obj),
|
|
11907
|
+
c: prop('c', obj),
|
|
11908
|
+
}
|
|
11909
|
+
const curriedResult = {
|
|
11910
|
+
a: prop('a')(obj),
|
|
11911
|
+
b: prop('b')(obj),
|
|
11912
|
+
c: prop('c')(obj),
|
|
11913
|
+
}
|
|
11674
11914
|
|
|
11675
|
-
result // $ExpectType string
|
|
11915
|
+
result // $ExpectType { a: number; b: string; c: number | undefined; }
|
|
11916
|
+
curriedResult // $ExpectType { a: number; b: string; c: number | undefined; }
|
|
11676
11917
|
})
|
|
11677
11918
|
})
|
|
11678
11919
|
|
|
@@ -11700,7 +11941,7 @@ describe('with number as prop', () => {
|
|
|
11700
11941
|
|
|
11701
11942
|
```typescript
|
|
11702
11943
|
|
|
11703
|
-
propEq<K extends string | number>(
|
|
11944
|
+
propEq<K extends string | number>(valueToMatch: any, propToFind: K, obj: Record<K, any>): boolean
|
|
11704
11945
|
```
|
|
11705
11946
|
|
|
11706
11947
|
It returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch`.
|
|
@@ -11709,14 +11950,14 @@ It returns true if `obj` has property `propToFind` and its value is equal to `va
|
|
|
11709
11950
|
|
|
11710
11951
|
<details>
|
|
11711
11952
|
|
|
11712
|
-
<summary>All
|
|
11953
|
+
<summary>All TypeScript definitions</summary>
|
|
11713
11954
|
|
|
11714
11955
|
```typescript
|
|
11715
|
-
propEq<K extends string | number>(
|
|
11716
|
-
propEq<K extends string | number>(
|
|
11717
|
-
propEq
|
|
11718
|
-
(
|
|
11719
|
-
(
|
|
11956
|
+
propEq<K extends string | number>(valueToMatch: any, propToFind: K, obj: Record<K, any>): boolean;
|
|
11957
|
+
propEq<K extends string | number>(valueToMatch: any, propToFind: K): (obj: Record<K, any>) => boolean;
|
|
11958
|
+
propEq(valueToMatch: any): {
|
|
11959
|
+
<K extends string | number>(propToFind: K, obj: Record<K, any>): boolean;
|
|
11960
|
+
<K extends string | number>(propToFind: K): (obj: Record<K, any>) => boolean;
|
|
11720
11961
|
};
|
|
11721
11962
|
```
|
|
11722
11963
|
|
|
@@ -11732,7 +11973,7 @@ import { equals } from './equals.js'
|
|
|
11732
11973
|
import { prop } from './prop.js'
|
|
11733
11974
|
|
|
11734
11975
|
function propEqFn(
|
|
11735
|
-
|
|
11976
|
+
valueToMatch, propToFind, obj
|
|
11736
11977
|
){
|
|
11737
11978
|
if (!obj) return false
|
|
11738
11979
|
|
|
@@ -11749,14 +11990,16 @@ export const propEq = curry(propEqFn)
|
|
|
11749
11990
|
<summary><strong>Tests</strong></summary>
|
|
11750
11991
|
|
|
11751
11992
|
```javascript
|
|
11993
|
+
import { BAR, FOO } from './_internals/testUtils.js'
|
|
11752
11994
|
import { propEq } from './propEq.js'
|
|
11753
11995
|
|
|
11754
11996
|
test('happy', () => {
|
|
11755
|
-
|
|
11756
|
-
expect(propEq(
|
|
11757
|
-
expect(propEq(
|
|
11997
|
+
const obj = { [ FOO ] : BAR }
|
|
11998
|
+
expect(propEq(BAR, FOO)(obj)).toBeTrue()
|
|
11999
|
+
expect(propEq(1, FOO)(obj)).toBeFalse()
|
|
12000
|
+
expect(propEq(1)(FOO)(obj)).toBeFalse()
|
|
11758
12001
|
expect(propEq(
|
|
11759
|
-
|
|
12002
|
+
1, 1, null
|
|
11760
12003
|
)).toBeFalse()
|
|
11761
12004
|
})
|
|
11762
12005
|
|
|
@@ -11774,7 +12017,7 @@ test('returns false if called with a null or undefined object', () => {
|
|
|
11774
12017
|
|
|
11775
12018
|
<details>
|
|
11776
12019
|
|
|
11777
|
-
<summary><strong>
|
|
12020
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11778
12021
|
|
|
11779
12022
|
```typescript
|
|
11780
12023
|
import {propEq} from 'rambda'
|
|
@@ -11787,12 +12030,12 @@ const objWithNumberIndex = {[numberProperty]: value}
|
|
|
11787
12030
|
|
|
11788
12031
|
describe('R.propEq', () => {
|
|
11789
12032
|
it('happy', () => {
|
|
11790
|
-
const result = propEq(
|
|
12033
|
+
const result = propEq(value, property, obj)
|
|
11791
12034
|
result // $ExpectType boolean
|
|
11792
12035
|
})
|
|
11793
12036
|
|
|
11794
12037
|
it('number is property', () => {
|
|
11795
|
-
const result = propEq(
|
|
12038
|
+
const result = propEq(value, 1, objWithNumberIndex)
|
|
11796
12039
|
result // $ExpectType boolean
|
|
11797
12040
|
})
|
|
11798
12041
|
|
|
@@ -11804,10 +12047,7 @@ describe('R.propEq', () => {
|
|
|
11804
12047
|
const myObject: MyType = {}
|
|
11805
12048
|
const valueToFind = '1111'
|
|
11806
12049
|
// @ts-expect-error
|
|
11807
|
-
propEq('optional',
|
|
11808
|
-
|
|
11809
|
-
// @ts-expect-error
|
|
11810
|
-
propEq('optional', valueToFind, myObject)
|
|
12050
|
+
propEq(valueToFind, 'optional', myObject)
|
|
11811
12051
|
})
|
|
11812
12052
|
|
|
11813
12053
|
it('imported from @types/ramda', () => {
|
|
@@ -11818,11 +12058,11 @@ describe('R.propEq', () => {
|
|
|
11818
12058
|
foo: 'bar',
|
|
11819
12059
|
}
|
|
11820
12060
|
const value = ''
|
|
11821
|
-
const result = propEq('foo'
|
|
12061
|
+
const result = propEq(value, 'foo')(obj)
|
|
11822
12062
|
result // $ExpectType boolean
|
|
11823
12063
|
|
|
11824
12064
|
// @ts-expect-error
|
|
11825
|
-
propEq('bar'
|
|
12065
|
+
propEq(value, 'bar')(obj)
|
|
11826
12066
|
})
|
|
11827
12067
|
})
|
|
11828
12068
|
```
|
|
@@ -11844,7 +12084,7 @@ It returns `true` if `property` of `obj` is from `target` type.
|
|
|
11844
12084
|
|
|
11845
12085
|
<details>
|
|
11846
12086
|
|
|
11847
|
-
<summary>All
|
|
12087
|
+
<summary>All TypeScript definitions</summary>
|
|
11848
12088
|
|
|
11849
12089
|
```typescript
|
|
11850
12090
|
propIs<C extends AnyFunction, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>;
|
|
@@ -11913,7 +12153,7 @@ test('when false', () => {
|
|
|
11913
12153
|
|
|
11914
12154
|
<details>
|
|
11915
12155
|
|
|
11916
|
-
<summary><strong>
|
|
12156
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
11917
12157
|
|
|
11918
12158
|
```typescript
|
|
11919
12159
|
import {propIs} from 'rambda'
|
|
@@ -11951,7 +12191,7 @@ It returns either `defaultValue` or the value of `property` in `obj`.
|
|
|
11951
12191
|
|
|
11952
12192
|
<details>
|
|
11953
12193
|
|
|
11954
|
-
<summary>All
|
|
12194
|
+
<summary>All TypeScript definitions</summary>
|
|
11955
12195
|
|
|
11956
12196
|
```typescript
|
|
11957
12197
|
propOr<T, P extends string>(defaultValue: T, property: P, obj: Partial<Record<P, T>> | undefined): T;
|
|
@@ -12018,7 +12258,7 @@ test('propOr (currying)', () => {
|
|
|
12018
12258
|
|
|
12019
12259
|
<details>
|
|
12020
12260
|
|
|
12021
|
-
<summary><strong>
|
|
12261
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12022
12262
|
|
|
12023
12263
|
```typescript
|
|
12024
12264
|
import {propOr} from 'rambda'
|
|
@@ -12064,7 +12304,7 @@ It takes list with properties `propsToPick` and returns a list with property val
|
|
|
12064
12304
|
|
|
12065
12305
|
<details>
|
|
12066
12306
|
|
|
12067
|
-
<summary>All
|
|
12307
|
+
<summary>All TypeScript definitions</summary>
|
|
12068
12308
|
|
|
12069
12309
|
```typescript
|
|
12070
12310
|
props<P extends string, T>(propsToPick: P[], obj: Record<P, T>): T[];
|
|
@@ -12128,7 +12368,7 @@ test('wrong input', () => {
|
|
|
12128
12368
|
|
|
12129
12369
|
<details>
|
|
12130
12370
|
|
|
12131
|
-
<summary><strong>
|
|
12371
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12132
12372
|
|
|
12133
12373
|
```typescript
|
|
12134
12374
|
import {props} from 'rambda'
|
|
@@ -12166,7 +12406,7 @@ It returns `true` if the object property satisfies a given predicate.
|
|
|
12166
12406
|
|
|
12167
12407
|
<details>
|
|
12168
12408
|
|
|
12169
|
-
<summary>All
|
|
12409
|
+
<summary>All TypeScript definitions</summary>
|
|
12170
12410
|
|
|
12171
12411
|
```typescript
|
|
12172
12412
|
propSatisfies<T>(predicate: Predicate<T>, property: string, obj: Record<string, T>): boolean;
|
|
@@ -12218,7 +12458,7 @@ test('when false', () => {
|
|
|
12218
12458
|
|
|
12219
12459
|
<details>
|
|
12220
12460
|
|
|
12221
|
-
<summary><strong>
|
|
12461
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12222
12462
|
|
|
12223
12463
|
```typescript
|
|
12224
12464
|
import {propSatisfies} from 'rambda'
|
|
@@ -12256,7 +12496,7 @@ It returns list of numbers between `startInclusive` to `endExclusive` markers.
|
|
|
12256
12496
|
|
|
12257
12497
|
<details>
|
|
12258
12498
|
|
|
12259
|
-
<summary>All
|
|
12499
|
+
<summary>All TypeScript definitions</summary>
|
|
12260
12500
|
|
|
12261
12501
|
```typescript
|
|
12262
12502
|
range(startInclusive: number, endExclusive: number): number[];
|
|
@@ -12323,7 +12563,7 @@ test('curry', () => {
|
|
|
12323
12563
|
|
|
12324
12564
|
<details>
|
|
12325
12565
|
|
|
12326
|
-
<summary><strong>
|
|
12566
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12327
12567
|
|
|
12328
12568
|
```typescript
|
|
12329
12569
|
import {range} from 'rambda'
|
|
@@ -12365,7 +12605,7 @@ It has the opposite effect of `R.filter`.
|
|
|
12365
12605
|
|
|
12366
12606
|
<details>
|
|
12367
12607
|
|
|
12368
|
-
<summary>All
|
|
12608
|
+
<summary>All TypeScript definitions</summary>
|
|
12369
12609
|
|
|
12370
12610
|
```typescript
|
|
12371
12611
|
reject<T>(predicate: Predicate<T>, list: T[]): T[];
|
|
@@ -12423,7 +12663,7 @@ test('with object', () => {
|
|
|
12423
12663
|
|
|
12424
12664
|
<details>
|
|
12425
12665
|
|
|
12426
|
-
<summary><strong>
|
|
12666
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12427
12667
|
|
|
12428
12668
|
```typescript
|
|
12429
12669
|
import {reject} from 'rambda'
|
|
@@ -12484,7 +12724,7 @@ repeat<T>(x: T): (timesToRepeat: number) => T[]
|
|
|
12484
12724
|
|
|
12485
12725
|
<details>
|
|
12486
12726
|
|
|
12487
|
-
<summary>All
|
|
12727
|
+
<summary>All TypeScript definitions</summary>
|
|
12488
12728
|
|
|
12489
12729
|
```typescript
|
|
12490
12730
|
repeat<T>(x: T): (timesToRepeat: number) => T[];
|
|
@@ -12533,7 +12773,7 @@ test('repeat', () => {
|
|
|
12533
12773
|
|
|
12534
12774
|
<details>
|
|
12535
12775
|
|
|
12536
|
-
<summary><strong>
|
|
12776
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12537
12777
|
|
|
12538
12778
|
```typescript
|
|
12539
12779
|
import {repeat} from 'rambda'
|
|
@@ -12560,7 +12800,7 @@ describe('R.repeat', () => {
|
|
|
12560
12800
|
|
|
12561
12801
|
```typescript
|
|
12562
12802
|
|
|
12563
|
-
replace(strOrRegex: RegExp | string, replacer:
|
|
12803
|
+
replace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string
|
|
12564
12804
|
```
|
|
12565
12805
|
|
|
12566
12806
|
It replaces `strOrRegex` found in `str` with `replacer`.
|
|
@@ -12569,12 +12809,12 @@ It replaces `strOrRegex` found in `str` with `replacer`.
|
|
|
12569
12809
|
|
|
12570
12810
|
<details>
|
|
12571
12811
|
|
|
12572
|
-
<summary>All
|
|
12812
|
+
<summary>All TypeScript definitions</summary>
|
|
12573
12813
|
|
|
12574
12814
|
```typescript
|
|
12575
|
-
replace(strOrRegex: RegExp | string, replacer:
|
|
12576
|
-
replace(strOrRegex: RegExp | string, replacer:
|
|
12577
|
-
replace(strOrRegex: RegExp | string): (replacer:
|
|
12815
|
+
replace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string;
|
|
12816
|
+
replace(strOrRegex: RegExp | string, replacer: RegExpReplacer): (str: string) => string;
|
|
12817
|
+
replace(strOrRegex: RegExp | string): (replacer: RegExpReplacer) => (str: string) => string;
|
|
12578
12818
|
```
|
|
12579
12819
|
|
|
12580
12820
|
</details>
|
|
@@ -12606,20 +12846,24 @@ import { replace } from './replace.js'
|
|
|
12606
12846
|
|
|
12607
12847
|
test('happy', () => {
|
|
12608
12848
|
expect(replace(
|
|
12609
|
-
|
|
12610
|
-
)).toBe('
|
|
12849
|
+
/\s/g, '|', 'foo bar baz'
|
|
12850
|
+
)).toBe('foo|bar|baz')
|
|
12611
12851
|
})
|
|
12612
12852
|
|
|
12613
|
-
test('
|
|
12614
|
-
expect(replace(
|
|
12615
|
-
|
|
12616
|
-
|
|
12617
|
-
|
|
12618
|
-
|
|
12619
|
-
|
|
12853
|
+
test('with function as replacer input', () => {
|
|
12854
|
+
expect(replace(
|
|
12855
|
+
/\s/g,
|
|
12856
|
+
(
|
|
12857
|
+
match, offset, str
|
|
12858
|
+
) => {
|
|
12859
|
+
expect(match).toBe(' ')
|
|
12860
|
+
expect([ 3, 7 ].includes(offset)).toBeTrue()
|
|
12861
|
+
expect(str).toBe('foo bar baz')
|
|
12620
12862
|
|
|
12621
|
-
|
|
12622
|
-
|
|
12863
|
+
return '|'
|
|
12864
|
+
},
|
|
12865
|
+
'foo bar baz'
|
|
12866
|
+
)).toBe('foo|bar|baz')
|
|
12623
12867
|
})
|
|
12624
12868
|
```
|
|
12625
12869
|
|
|
@@ -12627,7 +12871,7 @@ test('3', () => {
|
|
|
12627
12871
|
|
|
12628
12872
|
<details>
|
|
12629
12873
|
|
|
12630
|
-
<summary><strong>
|
|
12874
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12631
12875
|
|
|
12632
12876
|
```typescript
|
|
12633
12877
|
import {replace} from 'rambda'
|
|
@@ -12644,6 +12888,16 @@ describe('R.replace', () => {
|
|
|
12644
12888
|
it('with string as search pattern', () => {
|
|
12645
12889
|
const result = replace('foo', replacer, str)
|
|
12646
12890
|
|
|
12891
|
+
result // $ExpectType string
|
|
12892
|
+
})
|
|
12893
|
+
it('with function as replacer', () => {
|
|
12894
|
+
const result = replace('f(o)o', (m: string, p1: string, offset: number) => {
|
|
12895
|
+
m // $ExpectType string
|
|
12896
|
+
p1 // $ExpectType string
|
|
12897
|
+
offset // $ExpectType number
|
|
12898
|
+
return p1
|
|
12899
|
+
}, str)
|
|
12900
|
+
|
|
12647
12901
|
result // $ExpectType string
|
|
12648
12902
|
})
|
|
12649
12903
|
})
|
|
@@ -12657,6 +12911,16 @@ describe('R.replace - curried', () => {
|
|
|
12657
12911
|
it('with string as search pattern', () => {
|
|
12658
12912
|
const result = replace('foo', replacer)(str)
|
|
12659
12913
|
|
|
12914
|
+
result // $ExpectType string
|
|
12915
|
+
})
|
|
12916
|
+
it('with function as replacer', () => {
|
|
12917
|
+
const result = replace('f(o)o')((m: string, p1: string, offset: number) => {
|
|
12918
|
+
m // $ExpectType string
|
|
12919
|
+
p1 // $ExpectType string
|
|
12920
|
+
offset // $ExpectType number
|
|
12921
|
+
return p1
|
|
12922
|
+
})(str)
|
|
12923
|
+
|
|
12660
12924
|
result // $ExpectType string
|
|
12661
12925
|
})
|
|
12662
12926
|
})
|
|
@@ -12679,7 +12943,7 @@ It returns a reversed copy of list or string `input`.
|
|
|
12679
12943
|
|
|
12680
12944
|
<details>
|
|
12681
12945
|
|
|
12682
|
-
<summary>All
|
|
12946
|
+
<summary>All TypeScript definitions</summary>
|
|
12683
12947
|
|
|
12684
12948
|
```typescript
|
|
12685
12949
|
reverse<T>(input: T[]): T[];
|
|
@@ -12693,10 +12957,9 @@ reverse(input: string): string;
|
|
|
12693
12957
|
<summary><strong>R.reverse</strong> source</summary>
|
|
12694
12958
|
|
|
12695
12959
|
```javascript
|
|
12696
|
-
export function reverse(listOrString){
|
|
12697
|
-
if (typeof listOrString === 'string'){
|
|
12698
|
-
return listOrString.split('').reverse()
|
|
12699
|
-
.join('')
|
|
12960
|
+
export function reverse(listOrString) {
|
|
12961
|
+
if (typeof listOrString === 'string') {
|
|
12962
|
+
return listOrString.split('').reverse().join('')
|
|
12700
12963
|
}
|
|
12701
12964
|
|
|
12702
12965
|
const clone = listOrString.slice()
|
|
@@ -12712,22 +12975,22 @@ export function reverse(listOrString){
|
|
|
12712
12975
|
<summary><strong>Tests</strong></summary>
|
|
12713
12976
|
|
|
12714
12977
|
```javascript
|
|
12715
|
-
import {
|
|
12978
|
+
import {reverse} from './reverse.js'
|
|
12716
12979
|
|
|
12717
12980
|
test('happy', () => {
|
|
12718
|
-
expect(reverse([
|
|
12981
|
+
expect(reverse([1, 2, 3])).toEqual([3, 2, 1])
|
|
12719
12982
|
})
|
|
12720
12983
|
|
|
12721
12984
|
test('with string', () => {
|
|
12722
12985
|
expect(reverse('baz')).toBe('zab')
|
|
12723
12986
|
})
|
|
12724
12987
|
|
|
12725
|
-
test(
|
|
12726
|
-
const arr = [
|
|
12988
|
+
test("it doesn't mutate", () => {
|
|
12989
|
+
const arr = [1, 2, 3]
|
|
12727
12990
|
|
|
12728
|
-
expect(reverse(arr)).toEqual([
|
|
12991
|
+
expect(reverse(arr)).toEqual([3, 2, 1])
|
|
12729
12992
|
|
|
12730
|
-
expect(arr).toEqual([
|
|
12993
|
+
expect(arr).toEqual([1, 2, 3])
|
|
12731
12994
|
})
|
|
12732
12995
|
```
|
|
12733
12996
|
|
|
@@ -12735,7 +12998,7 @@ test('it doesn\'t mutate', () => {
|
|
|
12735
12998
|
|
|
12736
12999
|
<details>
|
|
12737
13000
|
|
|
12738
|
-
<summary><strong>
|
|
13001
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12739
13002
|
|
|
12740
13003
|
```typescript
|
|
12741
13004
|
import {reverse} from 'rambda'
|
|
@@ -12767,7 +13030,7 @@ It returns a copied **Object** or **Array** with modified `lens` focus set to `r
|
|
|
12767
13030
|
|
|
12768
13031
|
<details>
|
|
12769
13032
|
|
|
12770
|
-
<summary>All
|
|
13033
|
+
<summary>All TypeScript definitions</summary>
|
|
12771
13034
|
|
|
12772
13035
|
```typescript
|
|
12773
13036
|
set<T, U>(lens: Lens, replacer: U, obj: T): T;
|
|
@@ -12782,16 +13045,12 @@ set(lens: Lens): <T, U>(replacer: U, obj: T) => T;
|
|
|
12782
13045
|
<summary><strong>R.set</strong> source</summary>
|
|
12783
13046
|
|
|
12784
13047
|
```javascript
|
|
12785
|
-
import {
|
|
12786
|
-
import {
|
|
12787
|
-
import {
|
|
13048
|
+
import {always} from './always.js'
|
|
13049
|
+
import {curry} from './curry.js'
|
|
13050
|
+
import {over} from './over.js'
|
|
12788
13051
|
|
|
12789
|
-
function setFn(
|
|
12790
|
-
lens, replacer, x
|
|
12791
|
-
){
|
|
12792
|
-
return over(
|
|
12793
|
-
lens, always(replacer), x
|
|
12794
|
-
)
|
|
13052
|
+
function setFn(lens, replacer, x) {
|
|
13053
|
+
return over(lens, always(replacer), x)
|
|
12795
13054
|
}
|
|
12796
13055
|
|
|
12797
13056
|
export const set = curry(setFn)
|
|
@@ -12804,43 +13063,39 @@ export const set = curry(setFn)
|
|
|
12804
13063
|
<summary><strong>Tests</strong></summary>
|
|
12805
13064
|
|
|
12806
13065
|
```javascript
|
|
12807
|
-
import {
|
|
12808
|
-
import {
|
|
12809
|
-
import {
|
|
12810
|
-
import {
|
|
12811
|
-
import {
|
|
12812
|
-
import {
|
|
13066
|
+
import {assoc} from './assoc.js'
|
|
13067
|
+
import {lens} from './lens.js'
|
|
13068
|
+
import {lensIndex} from './lensIndex.js'
|
|
13069
|
+
import {lensPath} from './lensPath.js'
|
|
13070
|
+
import {prop} from './prop.js'
|
|
13071
|
+
import {set} from './set.js'
|
|
12813
13072
|
|
|
12814
13073
|
const testObject = {
|
|
12815
|
-
foo
|
|
12816
|
-
baz
|
|
12817
|
-
a
|
|
12818
|
-
b
|
|
13074
|
+
foo: 'bar',
|
|
13075
|
+
baz: {
|
|
13076
|
+
a: 'x',
|
|
13077
|
+
b: 'y',
|
|
12819
13078
|
},
|
|
12820
13079
|
}
|
|
12821
13080
|
|
|
12822
13081
|
test('assoc lens', () => {
|
|
12823
13082
|
const assocLens = lens(prop('foo'), assoc('foo'))
|
|
12824
|
-
const result = set(
|
|
12825
|
-
assocLens, 'FOO', testObject
|
|
12826
|
-
)
|
|
13083
|
+
const result = set(assocLens, 'FOO', testObject)
|
|
12827
13084
|
const expected = {
|
|
12828
13085
|
...testObject,
|
|
12829
|
-
foo
|
|
13086
|
+
foo: 'FOO',
|
|
12830
13087
|
}
|
|
12831
13088
|
expect(result).toEqual(expected)
|
|
12832
13089
|
})
|
|
12833
13090
|
|
|
12834
13091
|
test('path lens', () => {
|
|
12835
13092
|
const pathLens = lensPath('baz.a')
|
|
12836
|
-
const result = set(
|
|
12837
|
-
pathLens, 'z', testObject
|
|
12838
|
-
)
|
|
13093
|
+
const result = set(pathLens, 'z', testObject)
|
|
12839
13094
|
const expected = {
|
|
12840
13095
|
...testObject,
|
|
12841
|
-
baz
|
|
12842
|
-
a
|
|
12843
|
-
b
|
|
13096
|
+
baz: {
|
|
13097
|
+
a: 'z',
|
|
13098
|
+
b: 'y',
|
|
12844
13099
|
},
|
|
12845
13100
|
}
|
|
12846
13101
|
expect(result).toEqual(expected)
|
|
@@ -12849,10 +13104,8 @@ test('path lens', () => {
|
|
|
12849
13104
|
test('index lens', () => {
|
|
12850
13105
|
const indexLens = lensIndex(0)
|
|
12851
13106
|
|
|
12852
|
-
const result = set(
|
|
12853
|
-
|
|
12854
|
-
)
|
|
12855
|
-
expect(result).toEqual([ 3, 2 ])
|
|
13107
|
+
const result = set(indexLens, 3, [1, 2])
|
|
13108
|
+
expect(result).toEqual([3, 2])
|
|
12856
13109
|
})
|
|
12857
13110
|
```
|
|
12858
13111
|
|
|
@@ -12871,7 +13124,7 @@ slice(from: number, to: number, input: string): string
|
|
|
12871
13124
|
|
|
12872
13125
|
<details>
|
|
12873
13126
|
|
|
12874
|
-
<summary>All
|
|
13127
|
+
<summary>All TypeScript definitions</summary>
|
|
12875
13128
|
|
|
12876
13129
|
```typescript
|
|
12877
13130
|
slice(from: number, to: number, input: string): string;
|
|
@@ -12936,7 +13189,7 @@ test('slice', () => {
|
|
|
12936
13189
|
|
|
12937
13190
|
<details>
|
|
12938
13191
|
|
|
12939
|
-
<summary><strong>
|
|
13192
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
12940
13193
|
|
|
12941
13194
|
```typescript
|
|
12942
13195
|
import {slice} from 'rambda'
|
|
@@ -12972,7 +13225,7 @@ It returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to r
|
|
|
12972
13225
|
|
|
12973
13226
|
<details>
|
|
12974
13227
|
|
|
12975
|
-
<summary>All
|
|
13228
|
+
<summary>All TypeScript definitions</summary>
|
|
12976
13229
|
|
|
12977
13230
|
```typescript
|
|
12978
13231
|
sort<T>(sortFn: (a: T, b: T) => number, list: T[]): T[];
|
|
@@ -13025,7 +13278,7 @@ test('it doesn\'t mutate', () => {
|
|
|
13025
13278
|
|
|
13026
13279
|
<details>
|
|
13027
13280
|
|
|
13028
|
-
<summary><strong>
|
|
13281
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13029
13282
|
|
|
13030
13283
|
```typescript
|
|
13031
13284
|
import {sort} from 'rambda'
|
|
@@ -13065,7 +13318,7 @@ It returns copy of `list` sorted by `sortFn` function, where `sortFn` function r
|
|
|
13065
13318
|
|
|
13066
13319
|
<details>
|
|
13067
13320
|
|
|
13068
|
-
<summary>All
|
|
13321
|
+
<summary>All TypeScript definitions</summary>
|
|
13069
13322
|
|
|
13070
13323
|
```typescript
|
|
13071
13324
|
sortBy<T>(sortFn: (a: T) => Ord, list: T[]): T[];
|
|
@@ -13142,7 +13395,7 @@ test('with compose', () => {
|
|
|
13142
13395
|
|
|
13143
13396
|
<details>
|
|
13144
13397
|
|
|
13145
|
-
<summary><strong>
|
|
13398
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13146
13399
|
|
|
13147
13400
|
```typescript
|
|
13148
13401
|
import {sortBy, pipe} from 'rambda'
|
|
@@ -13211,7 +13464,7 @@ Curried version of `String.prototype.split`
|
|
|
13211
13464
|
|
|
13212
13465
|
<details>
|
|
13213
13466
|
|
|
13214
|
-
<summary>All
|
|
13467
|
+
<summary>All TypeScript definitions</summary>
|
|
13215
13468
|
|
|
13216
13469
|
```typescript
|
|
13217
13470
|
split(separator: string | RegExp): (str: string) => string[];
|
|
@@ -13258,7 +13511,7 @@ test('curried', () => {
|
|
|
13258
13511
|
|
|
13259
13512
|
<details>
|
|
13260
13513
|
|
|
13261
|
-
<summary><strong>
|
|
13514
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13262
13515
|
|
|
13263
13516
|
```typescript
|
|
13264
13517
|
import {split} from 'rambda'
|
|
@@ -13297,7 +13550,7 @@ It splits string or array at a given index.
|
|
|
13297
13550
|
|
|
13298
13551
|
<details>
|
|
13299
13552
|
|
|
13300
|
-
<summary>All
|
|
13553
|
+
<summary>All TypeScript definitions</summary>
|
|
13301
13554
|
|
|
13302
13555
|
```typescript
|
|
13303
13556
|
splitAt<T>(index: number, input: T[]): [T[], T[]];
|
|
@@ -13410,7 +13663,7 @@ test('with bad inputs', () => {
|
|
|
13410
13663
|
|
|
13411
13664
|
<details>
|
|
13412
13665
|
|
|
13413
|
-
<summary><strong>
|
|
13666
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13414
13667
|
|
|
13415
13668
|
```typescript
|
|
13416
13669
|
import {splitAt} from 'rambda'
|
|
@@ -13463,7 +13716,7 @@ It splits `input` into slices of `sliceLength`.
|
|
|
13463
13716
|
|
|
13464
13717
|
<details>
|
|
13465
13718
|
|
|
13466
|
-
<summary>All
|
|
13719
|
+
<summary>All TypeScript definitions</summary>
|
|
13467
13720
|
|
|
13468
13721
|
```typescript
|
|
13469
13722
|
splitEvery<T>(sliceLength: number, input: T[]): (T[])[];
|
|
@@ -13530,7 +13783,7 @@ test('with bad input', () => {
|
|
|
13530
13783
|
|
|
13531
13784
|
<details>
|
|
13532
13785
|
|
|
13533
|
-
<summary><strong>
|
|
13786
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13534
13787
|
|
|
13535
13788
|
```typescript
|
|
13536
13789
|
import {splitEvery} from 'rambda'
|
|
@@ -13570,7 +13823,7 @@ The first array contains all members of `list` before `predicate` returns `true`
|
|
|
13570
13823
|
|
|
13571
13824
|
<details>
|
|
13572
13825
|
|
|
13573
|
-
<summary>All
|
|
13826
|
+
<summary>All TypeScript definitions</summary>
|
|
13574
13827
|
|
|
13575
13828
|
```typescript
|
|
13576
13829
|
splitWhen<T, U>(predicate: Predicate<T>, list: U[]): (U[])[];
|
|
@@ -13658,7 +13911,7 @@ test('with bad inputs', () => {
|
|
|
13658
13911
|
|
|
13659
13912
|
<details>
|
|
13660
13913
|
|
|
13661
|
-
<summary><strong>
|
|
13914
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13662
13915
|
|
|
13663
13916
|
```typescript
|
|
13664
13917
|
import {splitWhen} from 'rambda'
|
|
@@ -13688,7 +13941,7 @@ describe('R.splitWhen', () => {
|
|
|
13688
13941
|
|
|
13689
13942
|
```typescript
|
|
13690
13943
|
|
|
13691
|
-
startsWith(
|
|
13944
|
+
startsWith<T extends string>(question: T, input: string): boolean
|
|
13692
13945
|
```
|
|
13693
13946
|
|
|
13694
13947
|
When iterable is a string, then it behaves as `String.prototype.startsWith`.
|
|
@@ -13698,13 +13951,13 @@ When iterable is a list, then it uses R.equals to determine if the target list s
|
|
|
13698
13951
|
|
|
13699
13952
|
<details>
|
|
13700
13953
|
|
|
13701
|
-
<summary>All
|
|
13954
|
+
<summary>All TypeScript definitions</summary>
|
|
13702
13955
|
|
|
13703
13956
|
```typescript
|
|
13704
|
-
startsWith(
|
|
13705
|
-
startsWith(
|
|
13706
|
-
startsWith<T>(
|
|
13707
|
-
startsWith<T>(
|
|
13957
|
+
startsWith<T extends string>(question: T, input: string): boolean;
|
|
13958
|
+
startsWith<T extends string>(question: T): (input: string) => boolean;
|
|
13959
|
+
startsWith<T>(question: T[], input: T[]): boolean;
|
|
13960
|
+
startsWith<T>(question: T[]): (input: T[]) => boolean;
|
|
13708
13961
|
```
|
|
13709
13962
|
|
|
13710
13963
|
</details>
|
|
@@ -13717,17 +13970,17 @@ startsWith<T>(target: T[]): (list: T[]) => boolean;
|
|
|
13717
13970
|
import { isArray } from './_internals/isArray.js'
|
|
13718
13971
|
import { equals } from './equals.js'
|
|
13719
13972
|
|
|
13720
|
-
export function startsWith(
|
|
13973
|
+
export function startsWith(question, iterable){
|
|
13721
13974
|
if (arguments.length === 1)
|
|
13722
|
-
return _iterable => startsWith(
|
|
13975
|
+
return _iterable => startsWith(question, _iterable)
|
|
13723
13976
|
|
|
13724
13977
|
if (typeof iterable === 'string'){
|
|
13725
|
-
return iterable.startsWith(
|
|
13978
|
+
return iterable.startsWith(question)
|
|
13726
13979
|
}
|
|
13727
|
-
if (!isArray(
|
|
13980
|
+
if (!isArray(question)) return false
|
|
13728
13981
|
|
|
13729
13982
|
let correct = true
|
|
13730
|
-
const filtered =
|
|
13983
|
+
const filtered = question.filter((x, index) => {
|
|
13731
13984
|
if (!correct) return false
|
|
13732
13985
|
const result = equals(x, iterable[ index ])
|
|
13733
13986
|
if (!result) correct = false
|
|
@@ -13735,7 +13988,7 @@ export function startsWith(target, iterable){
|
|
|
13735
13988
|
return result
|
|
13736
13989
|
})
|
|
13737
13990
|
|
|
13738
|
-
return filtered.length ===
|
|
13991
|
+
return filtered.length === question.length
|
|
13739
13992
|
}
|
|
13740
13993
|
```
|
|
13741
13994
|
|
|
@@ -13792,37 +14045,33 @@ describe('brute force', () => {
|
|
|
13792
14045
|
|
|
13793
14046
|
<details>
|
|
13794
14047
|
|
|
13795
|
-
<summary><strong>
|
|
14048
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13796
14049
|
|
|
13797
14050
|
```typescript
|
|
13798
14051
|
import {startsWith} from 'rambda'
|
|
13799
14052
|
|
|
13800
|
-
describe('R.startsWith - array
|
|
13801
|
-
const
|
|
14053
|
+
describe('R.startsWith - array', () => {
|
|
14054
|
+
const question = [{a: 1}]
|
|
13802
14055
|
const iterable = [{a: 1}, {a: 2}]
|
|
13803
14056
|
it('happy', () => {
|
|
13804
|
-
const result = startsWith(
|
|
13805
|
-
|
|
14057
|
+
const result = startsWith(question, iterable)
|
|
13806
14058
|
result // $ExpectType boolean
|
|
13807
14059
|
})
|
|
13808
14060
|
it('curried', () => {
|
|
13809
|
-
const result = startsWith(
|
|
13810
|
-
|
|
14061
|
+
const result = startsWith(question)(iterable)
|
|
13811
14062
|
result // $ExpectType boolean
|
|
13812
14063
|
})
|
|
13813
14064
|
})
|
|
13814
14065
|
|
|
13815
|
-
describe('R.startsWith - string
|
|
13816
|
-
const
|
|
14066
|
+
describe('R.startsWith - string', () => {
|
|
14067
|
+
const question = 'foo'
|
|
13817
14068
|
const iterable = 'foo bar'
|
|
13818
14069
|
it('happy', () => {
|
|
13819
|
-
const result = startsWith(
|
|
13820
|
-
|
|
14070
|
+
const result = startsWith(question, iterable)
|
|
13821
14071
|
result // $ExpectType boolean
|
|
13822
14072
|
})
|
|
13823
14073
|
it('curried', () => {
|
|
13824
|
-
const result = startsWith(
|
|
13825
|
-
|
|
14074
|
+
const result = startsWith(question)(iterable)
|
|
13826
14075
|
result // $ExpectType boolean
|
|
13827
14076
|
})
|
|
13828
14077
|
})
|
|
@@ -13851,7 +14100,7 @@ sum(list: number[]): number
|
|
|
13851
14100
|
|
|
13852
14101
|
<details>
|
|
13853
14102
|
|
|
13854
|
-
<summary>All
|
|
14103
|
+
<summary>All TypeScript definitions</summary>
|
|
13855
14104
|
|
|
13856
14105
|
```typescript
|
|
13857
14106
|
sum(list: number[]): number;
|
|
@@ -13902,7 +14151,7 @@ It returns a merged list of `x` and `y` with all equal elements removed.
|
|
|
13902
14151
|
|
|
13903
14152
|
<details>
|
|
13904
14153
|
|
|
13905
|
-
<summary>All
|
|
14154
|
+
<summary>All TypeScript definitions</summary>
|
|
13906
14155
|
|
|
13907
14156
|
```typescript
|
|
13908
14157
|
symmetricDifference<T>(x: T[], y: T[]): T[];
|
|
@@ -13963,7 +14212,7 @@ test('symmetricDifference with objects', () => {
|
|
|
13963
14212
|
|
|
13964
14213
|
<details>
|
|
13965
14214
|
|
|
13966
|
-
<summary><strong>
|
|
14215
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
13967
14216
|
|
|
13968
14217
|
```typescript
|
|
13969
14218
|
import {symmetricDifference} from 'rambda'
|
|
@@ -14002,7 +14251,7 @@ T(): boolean
|
|
|
14002
14251
|
|
|
14003
14252
|
<details>
|
|
14004
14253
|
|
|
14005
|
-
<summary>All
|
|
14254
|
+
<summary>All TypeScript definitions</summary>
|
|
14006
14255
|
|
|
14007
14256
|
```typescript
|
|
14008
14257
|
T(): boolean;
|
|
@@ -14037,7 +14286,7 @@ It returns all but the first element of `input`.
|
|
|
14037
14286
|
|
|
14038
14287
|
<details>
|
|
14039
14288
|
|
|
14040
|
-
<summary>All
|
|
14289
|
+
<summary>All TypeScript definitions</summary>
|
|
14041
14290
|
|
|
14042
14291
|
```typescript
|
|
14043
14292
|
tail<T extends unknown[]>(input: T): T extends [any, ...infer U] ? U : [...T];
|
|
@@ -14084,7 +14333,7 @@ test('tail', () => {
|
|
|
14084
14333
|
|
|
14085
14334
|
<details>
|
|
14086
14335
|
|
|
14087
|
-
<summary><strong>
|
|
14336
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14088
14337
|
|
|
14089
14338
|
```typescript
|
|
14090
14339
|
import {tail} from 'rambda'
|
|
@@ -14125,7 +14374,7 @@ It returns the first `howMany` elements of `input`.
|
|
|
14125
14374
|
|
|
14126
14375
|
<details>
|
|
14127
14376
|
|
|
14128
|
-
<summary>All
|
|
14377
|
+
<summary>All TypeScript definitions</summary>
|
|
14129
14378
|
|
|
14130
14379
|
```typescript
|
|
14131
14380
|
take<T>(howMany: number, input: T[]): T[];
|
|
@@ -14193,7 +14442,7 @@ test('with zero index', () => {
|
|
|
14193
14442
|
|
|
14194
14443
|
<details>
|
|
14195
14444
|
|
|
14196
|
-
<summary><strong>
|
|
14445
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14197
14446
|
|
|
14198
14447
|
```typescript
|
|
14199
14448
|
import {take} from 'rambda'
|
|
@@ -14246,7 +14495,7 @@ It returns the last `howMany` elements of `input`.
|
|
|
14246
14495
|
|
|
14247
14496
|
<details>
|
|
14248
14497
|
|
|
14249
|
-
<summary>All
|
|
14498
|
+
<summary>All TypeScript definitions</summary>
|
|
14250
14499
|
|
|
14251
14500
|
```typescript
|
|
14252
14501
|
takeLast<T>(howMany: number, input: T[]): T[];
|
|
@@ -14322,7 +14571,7 @@ test('with negative index', () => {
|
|
|
14322
14571
|
|
|
14323
14572
|
<details>
|
|
14324
14573
|
|
|
14325
|
-
<summary><strong>
|
|
14574
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14326
14575
|
|
|
14327
14576
|
```typescript
|
|
14328
14577
|
import {takeLast} from 'rambda'
|
|
@@ -14373,7 +14622,7 @@ takeLastWhile(predicate: (x: string) => boolean, input: string): string
|
|
|
14373
14622
|
|
|
14374
14623
|
<details>
|
|
14375
14624
|
|
|
14376
|
-
<summary>All
|
|
14625
|
+
<summary>All TypeScript definitions</summary>
|
|
14377
14626
|
|
|
14378
14627
|
```typescript
|
|
14379
14628
|
takeLastWhile(predicate: (x: string) => boolean, input: string): string;
|
|
@@ -14452,7 +14701,7 @@ test('with string', () => {
|
|
|
14452
14701
|
|
|
14453
14702
|
<details>
|
|
14454
14703
|
|
|
14455
|
-
<summary><strong>
|
|
14704
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14456
14705
|
|
|
14457
14706
|
```typescript
|
|
14458
14707
|
import {takeLastWhile} from 'rambda'
|
|
@@ -14509,7 +14758,7 @@ One use case is debugging in the middle of `R.compose`.
|
|
|
14509
14758
|
|
|
14510
14759
|
<details>
|
|
14511
14760
|
|
|
14512
|
-
<summary>All
|
|
14761
|
+
<summary>All TypeScript definitions</summary>
|
|
14513
14762
|
|
|
14514
14763
|
```typescript
|
|
14515
14764
|
tap<T>(fn: (x: T) => void, input: T): T;
|
|
@@ -14555,7 +14804,7 @@ test('tap', () => {
|
|
|
14555
14804
|
|
|
14556
14805
|
<details>
|
|
14557
14806
|
|
|
14558
|
-
<summary><strong>
|
|
14807
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14559
14808
|
|
|
14560
14809
|
```typescript
|
|
14561
14810
|
import {tap, pipe} from 'rambda'
|
|
@@ -14589,7 +14838,7 @@ It determines whether `str` matches `regExpression`.
|
|
|
14589
14838
|
|
|
14590
14839
|
<details>
|
|
14591
14840
|
|
|
14592
|
-
<summary>All
|
|
14841
|
+
<summary>All TypeScript definitions</summary>
|
|
14593
14842
|
|
|
14594
14843
|
```typescript
|
|
14595
14844
|
test(regExpression: RegExp): (str: string) => boolean;
|
|
@@ -14638,7 +14887,7 @@ test('throws if first argument is not regex', () => {
|
|
|
14638
14887
|
|
|
14639
14888
|
<details>
|
|
14640
14889
|
|
|
14641
|
-
<summary><strong>
|
|
14890
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14642
14891
|
|
|
14643
14892
|
```typescript
|
|
14644
14893
|
import {test} from 'rambda'
|
|
@@ -14679,7 +14928,7 @@ The range array includes numbers between `0` and `howMany`(exclusive).
|
|
|
14679
14928
|
|
|
14680
14929
|
<details>
|
|
14681
14930
|
|
|
14682
|
-
<summary>All
|
|
14931
|
+
<summary>All TypeScript definitions</summary>
|
|
14683
14932
|
|
|
14684
14933
|
```typescript
|
|
14685
14934
|
times<T>(fn: (i: number) => T, howMany: number): T[];
|
|
@@ -14745,7 +14994,7 @@ test('curry', () => {
|
|
|
14745
14994
|
|
|
14746
14995
|
<details>
|
|
14747
14996
|
|
|
14748
|
-
<summary><strong>
|
|
14997
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14749
14998
|
|
|
14750
14999
|
```typescript
|
|
14751
15000
|
import {times, identity} from 'rambda'
|
|
@@ -14773,7 +15022,7 @@ toLower<S extends string>(str: S): Lowercase<S>
|
|
|
14773
15022
|
|
|
14774
15023
|
<details>
|
|
14775
15024
|
|
|
14776
|
-
<summary>All
|
|
15025
|
+
<summary>All TypeScript definitions</summary>
|
|
14777
15026
|
|
|
14778
15027
|
```typescript
|
|
14779
15028
|
toLower<S extends string>(str: S): Lowercase<S>;
|
|
@@ -14823,7 +15072,7 @@ It transforms an object to a list.
|
|
|
14823
15072
|
|
|
14824
15073
|
<details>
|
|
14825
15074
|
|
|
14826
|
-
<summary>All
|
|
15075
|
+
<summary>All TypeScript definitions</summary>
|
|
14827
15076
|
|
|
14828
15077
|
```typescript
|
|
14829
15078
|
toPairs<O extends object, K extends Extract<keyof O, string | number>>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;
|
|
@@ -14871,7 +15120,7 @@ test('happy', () => {
|
|
|
14871
15120
|
|
|
14872
15121
|
<details>
|
|
14873
15122
|
|
|
14874
|
-
<summary><strong>
|
|
15123
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
14875
15124
|
|
|
14876
15125
|
```typescript
|
|
14877
15126
|
import {toPairs} from 'rambda'
|
|
@@ -14906,7 +15155,7 @@ toString(x: unknown): string
|
|
|
14906
15155
|
|
|
14907
15156
|
<details>
|
|
14908
15157
|
|
|
14909
|
-
<summary>All
|
|
15158
|
+
<summary>All TypeScript definitions</summary>
|
|
14910
15159
|
|
|
14911
15160
|
```typescript
|
|
14912
15161
|
toString(x: unknown): string;
|
|
@@ -14953,7 +15202,7 @@ toUpper<S extends string>(str: S): Uppercase<S>
|
|
|
14953
15202
|
|
|
14954
15203
|
<details>
|
|
14955
15204
|
|
|
14956
|
-
<summary>All
|
|
15205
|
+
<summary>All TypeScript definitions</summary>
|
|
14957
15206
|
|
|
14958
15207
|
```typescript
|
|
14959
15208
|
toUpper<S extends string>(str: S): Uppercase<S>;
|
|
@@ -15001,7 +15250,7 @@ transpose<T>(list: (T[])[]): (T[])[]
|
|
|
15001
15250
|
|
|
15002
15251
|
<details>
|
|
15003
15252
|
|
|
15004
|
-
<summary>All
|
|
15253
|
+
<summary>All TypeScript definitions</summary>
|
|
15005
15254
|
|
|
15006
15255
|
```typescript
|
|
15007
15256
|
transpose<T>(list: (T[])[]): (T[])[];
|
|
@@ -15077,7 +15326,7 @@ test('array with falsy values', () => {
|
|
|
15077
15326
|
|
|
15078
15327
|
<details>
|
|
15079
15328
|
|
|
15080
|
-
<summary><strong>
|
|
15329
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15081
15330
|
|
|
15082
15331
|
```typescript
|
|
15083
15332
|
import {transpose} from 'rambda'
|
|
@@ -15112,7 +15361,7 @@ trim(str: string): string
|
|
|
15112
15361
|
|
|
15113
15362
|
<details>
|
|
15114
15363
|
|
|
15115
|
-
<summary>All
|
|
15364
|
+
<summary>All TypeScript definitions</summary>
|
|
15116
15365
|
|
|
15117
15366
|
```typescript
|
|
15118
15367
|
trim(str: string): string;
|
|
@@ -15179,7 +15428,7 @@ It calls a function `fn` with the list of values of the returned function.
|
|
|
15179
15428
|
|
|
15180
15429
|
<details>
|
|
15181
15430
|
|
|
15182
|
-
<summary>All
|
|
15431
|
+
<summary>All TypeScript definitions</summary>
|
|
15183
15432
|
|
|
15184
15433
|
```typescript
|
|
15185
15434
|
unapply<T = any>(fn: (args: any[]) => T): (...args: any[]) => T;
|
|
@@ -15302,7 +15551,7 @@ test('it works with converge', () => {
|
|
|
15302
15551
|
|
|
15303
15552
|
<details>
|
|
15304
15553
|
|
|
15305
|
-
<summary><strong>
|
|
15554
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15306
15555
|
|
|
15307
15556
|
```typescript
|
|
15308
15557
|
import {join, unapply, sum} from 'rambda'
|
|
@@ -15341,7 +15590,7 @@ It takes two lists and return a new list containing a merger of both list with r
|
|
|
15341
15590
|
|
|
15342
15591
|
<details>
|
|
15343
15592
|
|
|
15344
|
-
<summary>All
|
|
15593
|
+
<summary>All TypeScript definitions</summary>
|
|
15345
15594
|
|
|
15346
15595
|
```typescript
|
|
15347
15596
|
union<T>(x: T[], y: T[]): T[];
|
|
@@ -15395,7 +15644,7 @@ test('with list of objects', () => {
|
|
|
15395
15644
|
|
|
15396
15645
|
<details>
|
|
15397
15646
|
|
|
15398
|
-
<summary><strong>
|
|
15647
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15399
15648
|
|
|
15400
15649
|
```typescript
|
|
15401
15650
|
import {union} from 'rambda'
|
|
@@ -15462,7 +15711,7 @@ It returns a new array containing only one copy of each element of `list`.
|
|
|
15462
15711
|
|
|
15463
15712
|
<details>
|
|
15464
15713
|
|
|
15465
|
-
<summary>All
|
|
15714
|
+
<summary>All TypeScript definitions</summary>
|
|
15466
15715
|
|
|
15467
15716
|
```typescript
|
|
15468
15717
|
uniq<T>(list: T[]): T[];
|
|
@@ -15530,7 +15779,7 @@ test('can distinct between string and number', () => {
|
|
|
15530
15779
|
|
|
15531
15780
|
<details>
|
|
15532
15781
|
|
|
15533
|
-
<summary><strong>
|
|
15782
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15534
15783
|
|
|
15535
15784
|
```typescript
|
|
15536
15785
|
import {uniq} from 'rambda'
|
|
@@ -15572,7 +15821,7 @@ This predicate should return true, if two elements are equal.
|
|
|
15572
15821
|
|
|
15573
15822
|
<details>
|
|
15574
15823
|
|
|
15575
|
-
<summary>All
|
|
15824
|
+
<summary>All TypeScript definitions</summary>
|
|
15576
15825
|
|
|
15577
15826
|
```typescript
|
|
15578
15827
|
uniqWith<T, U>(predicate: (x: T, y: T) => boolean, list: T[]): T[];
|
|
@@ -15657,7 +15906,7 @@ test('with list of strings', () => {
|
|
|
15657
15906
|
|
|
15658
15907
|
<details>
|
|
15659
15908
|
|
|
15660
|
-
<summary><strong>
|
|
15909
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15661
15910
|
|
|
15662
15911
|
```typescript
|
|
15663
15912
|
import {uniqWith} from 'rambda'
|
|
@@ -15695,7 +15944,7 @@ In the other case, the final output will be the `input` itself.
|
|
|
15695
15944
|
|
|
15696
15945
|
<details>
|
|
15697
15946
|
|
|
15698
|
-
<summary>All
|
|
15947
|
+
<summary>All TypeScript definitions</summary>
|
|
15699
15948
|
|
|
15700
15949
|
```typescript
|
|
15701
15950
|
unless<T, U>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U, x: T): T | U;
|
|
@@ -15747,7 +15996,7 @@ test('curried', () => {
|
|
|
15747
15996
|
|
|
15748
15997
|
<details>
|
|
15749
15998
|
|
|
15750
|
-
<summary><strong>
|
|
15999
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15751
16000
|
|
|
15752
16001
|
```typescript
|
|
15753
16002
|
import {unless, inc} from 'rambda'
|
|
@@ -15835,7 +16084,7 @@ describe('R.unless - curried', () => {
|
|
|
15835
16084
|
|
|
15836
16085
|
### unwind
|
|
15837
16086
|
|
|
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%
|
|
16087
|
+
<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%20R.unwind('b'%2C%20obj)%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>
|
|
15839
16088
|
|
|
15840
16089
|
[](#unwind)
|
|
15841
16090
|
|
|
@@ -15852,7 +16101,7 @@ It returns a copy of `list` with updated element at `index` with `newValue`.
|
|
|
15852
16101
|
|
|
15853
16102
|
<details>
|
|
15854
16103
|
|
|
15855
|
-
<summary>All
|
|
16104
|
+
<summary>All TypeScript definitions</summary>
|
|
15856
16105
|
|
|
15857
16106
|
```typescript
|
|
15858
16107
|
update<T>(index: number, newValue: T, list: T[]): T[];
|
|
@@ -15942,7 +16191,7 @@ test('with negative index', () => {
|
|
|
15942
16191
|
|
|
15943
16192
|
<details>
|
|
15944
16193
|
|
|
15945
|
-
<summary><strong>
|
|
16194
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
15946
16195
|
|
|
15947
16196
|
```typescript
|
|
15948
16197
|
import {update} from 'rambda'
|
|
@@ -15972,7 +16221,7 @@ With correct input, this is nothing more than `Object.values(Record<string, unkn
|
|
|
15972
16221
|
|
|
15973
16222
|
<details>
|
|
15974
16223
|
|
|
15975
|
-
<summary>All
|
|
16224
|
+
<summary>All TypeScript definitions</summary>
|
|
15976
16225
|
|
|
15977
16226
|
```typescript
|
|
15978
16227
|
values<T extends object, K extends keyof T>(obj: T): T[K][];
|
|
@@ -16028,7 +16277,7 @@ test('with bad input', () => {
|
|
|
16028
16277
|
|
|
16029
16278
|
<details>
|
|
16030
16279
|
|
|
16031
|
-
<summary><strong>
|
|
16280
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16032
16281
|
|
|
16033
16282
|
```typescript
|
|
16034
16283
|
import {values} from 'rambda'
|
|
@@ -16062,7 +16311,7 @@ It returns the value of `lens` focus over `target` object.
|
|
|
16062
16311
|
|
|
16063
16312
|
<details>
|
|
16064
16313
|
|
|
16065
|
-
<summary>All
|
|
16314
|
+
<summary>All TypeScript definitions</summary>
|
|
16066
16315
|
|
|
16067
16316
|
```typescript
|
|
16068
16317
|
view<T, U>(lens: Lens): (target: T) => U;
|
|
@@ -16112,7 +16361,7 @@ test('happy', () => {
|
|
|
16112
16361
|
|
|
16113
16362
|
<details>
|
|
16114
16363
|
|
|
16115
|
-
<summary><strong>
|
|
16364
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16116
16365
|
|
|
16117
16366
|
```typescript
|
|
16118
16367
|
import {lens, view, assoc} from 'rambda'
|
|
@@ -16150,7 +16399,7 @@ when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T |
|
|
|
16150
16399
|
|
|
16151
16400
|
<details>
|
|
16152
16401
|
|
|
16153
|
-
<summary>All
|
|
16402
|
+
<summary>All TypeScript definitions</summary>
|
|
16154
16403
|
|
|
16155
16404
|
```typescript
|
|
16156
16405
|
when<T, U>(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T | U;
|
|
@@ -16201,7 +16450,7 @@ test('happy', () => {
|
|
|
16201
16450
|
|
|
16202
16451
|
<details>
|
|
16203
16452
|
|
|
16204
|
-
<summary><strong>
|
|
16453
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16205
16454
|
|
|
16206
16455
|
```typescript
|
|
16207
16456
|
import {when} from 'rambda'
|
|
@@ -16246,7 +16495,7 @@ It returns `true` if all each property in `conditions` returns `true` when appli
|
|
|
16246
16495
|
|
|
16247
16496
|
<details>
|
|
16248
16497
|
|
|
16249
|
-
<summary>All
|
|
16498
|
+
<summary>All TypeScript definitions</summary>
|
|
16250
16499
|
|
|
16251
16500
|
```typescript
|
|
16252
16501
|
where<T, U>(conditions: T, input: U): boolean;
|
|
@@ -16328,7 +16577,7 @@ test('when false | early exit', () => {
|
|
|
16328
16577
|
|
|
16329
16578
|
<details>
|
|
16330
16579
|
|
|
16331
|
-
<summary><strong>
|
|
16580
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16332
16581
|
|
|
16333
16582
|
```typescript
|
|
16334
16583
|
import {where, equals} from 'rambda'
|
|
@@ -16380,7 +16629,7 @@ It will return `true` if all of `input` object fully or partially include `rule`
|
|
|
16380
16629
|
|
|
16381
16630
|
<details>
|
|
16382
16631
|
|
|
16383
|
-
<summary>All
|
|
16632
|
+
<summary>All TypeScript definitions</summary>
|
|
16384
16633
|
|
|
16385
16634
|
```typescript
|
|
16386
16635
|
whereEq<T, U>(condition: T, input: U): boolean;
|
|
@@ -16466,7 +16715,7 @@ test('with wrong input', () => {
|
|
|
16466
16715
|
|
|
16467
16716
|
<details>
|
|
16468
16717
|
|
|
16469
|
-
<summary><strong>
|
|
16718
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16470
16719
|
|
|
16471
16720
|
```typescript
|
|
16472
16721
|
import {whereEq} from 'rambda'
|
|
@@ -16500,7 +16749,7 @@ It will return a new array, based on all members of `source` list that are not p
|
|
|
16500
16749
|
|
|
16501
16750
|
<details>
|
|
16502
16751
|
|
|
16503
|
-
<summary>All
|
|
16752
|
+
<summary>All TypeScript definitions</summary>
|
|
16504
16753
|
|
|
16505
16754
|
```typescript
|
|
16506
16755
|
without<T>(matchAgainst: T[], source: T[]): T[];
|
|
@@ -16560,7 +16809,7 @@ test('with list of objects', () => {
|
|
|
16560
16809
|
})
|
|
16561
16810
|
|
|
16562
16811
|
test('ramda accepts string as target input while rambda throws', () => {
|
|
16563
|
-
expect(withoutRamda('0:1', [ '0', '0:1' ])).toEqual([])
|
|
16812
|
+
expect(withoutRamda('0:1', [ '0', '0:1' ])).toEqual([ '0:1' ])
|
|
16564
16813
|
expect(() =>
|
|
16565
16814
|
without('0:1', [ '0', '0:1' ])).toThrowErrorMatchingInlineSnapshot('"Cannot read property \'indexOf\' of 0:1"')
|
|
16566
16815
|
expect(without([ '0:1' ], [ '0', '0:1' ])).toEqual([ '0' ])
|
|
@@ -16575,7 +16824,7 @@ test('ramda test', () => {
|
|
|
16575
16824
|
|
|
16576
16825
|
<details>
|
|
16577
16826
|
|
|
16578
|
-
<summary><strong>
|
|
16827
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16579
16828
|
|
|
16580
16829
|
```typescript
|
|
16581
16830
|
import {without} from 'rambda'
|
|
@@ -16614,7 +16863,7 @@ Logical XOR
|
|
|
16614
16863
|
|
|
16615
16864
|
<details>
|
|
16616
16865
|
|
|
16617
|
-
<summary>All
|
|
16866
|
+
<summary>All TypeScript definitions</summary>
|
|
16618
16867
|
|
|
16619
16868
|
```typescript
|
|
16620
16869
|
xor(x: boolean, y: boolean): boolean;
|
|
@@ -16693,7 +16942,7 @@ test('when one argument is truthy and the other is falsy, it should return true'
|
|
|
16693
16942
|
|
|
16694
16943
|
<details>
|
|
16695
16944
|
|
|
16696
|
-
<summary><strong>
|
|
16945
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16697
16946
|
|
|
16698
16947
|
```typescript
|
|
16699
16948
|
import {xor} from 'rambda'
|
|
@@ -16727,7 +16976,7 @@ The returned list will be truncated to match the length of the shortest supplied
|
|
|
16727
16976
|
|
|
16728
16977
|
<details>
|
|
16729
16978
|
|
|
16730
|
-
<summary>All
|
|
16979
|
+
<summary>All TypeScript definitions</summary>
|
|
16731
16980
|
|
|
16732
16981
|
```typescript
|
|
16733
16982
|
zip<K, V>(x: K[], y: V[]): KeyValuePair<K, V>[];
|
|
@@ -16803,7 +17052,7 @@ test('should truncate result to length of shorted input list', () => {
|
|
|
16803
17052
|
|
|
16804
17053
|
<details>
|
|
16805
17054
|
|
|
16806
|
-
<summary><strong>
|
|
17055
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16807
17056
|
|
|
16808
17057
|
```typescript
|
|
16809
17058
|
import {zip} from 'rambda'
|
|
@@ -16836,7 +17085,7 @@ It will return a new object with keys of `keys` array and values of `values` arr
|
|
|
16836
17085
|
|
|
16837
17086
|
<details>
|
|
16838
17087
|
|
|
16839
|
-
<summary>All
|
|
17088
|
+
<summary>All TypeScript definitions</summary>
|
|
16840
17089
|
|
|
16841
17090
|
```typescript
|
|
16842
17091
|
zipObj<T, K extends string>(keys: K[], values: T[]): { [P in K]: T };
|
|
@@ -16915,7 +17164,7 @@ test('ignore extra keys', () => {
|
|
|
16915
17164
|
|
|
16916
17165
|
<details>
|
|
16917
17166
|
|
|
16918
|
-
<summary><strong>
|
|
17167
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
16919
17168
|
|
|
16920
17169
|
```typescript
|
|
16921
17170
|
import {zipObj} from 'rambda'
|
|
@@ -16950,7 +17199,7 @@ zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TRe
|
|
|
16950
17199
|
|
|
16951
17200
|
<details>
|
|
16952
17201
|
|
|
16953
|
-
<summary>All
|
|
17202
|
+
<summary>All TypeScript definitions</summary>
|
|
16954
17203
|
|
|
16955
17204
|
```typescript
|
|
16956
17205
|
zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[];
|
|
@@ -17010,7 +17259,7 @@ test('when second list is longer', () => {
|
|
|
17010
17259
|
|
|
17011
17260
|
<details>
|
|
17012
17261
|
|
|
17013
|
-
<summary><strong>
|
|
17262
|
+
<summary><strong>TypeScript</strong> test</summary>
|
|
17014
17263
|
|
|
17015
17264
|
```typescript
|
|
17016
17265
|
import {zipWith} from 'rambda'
|
|
@@ -17050,6 +17299,24 @@ describe('R.zipWith', () => {
|
|
|
17050
17299
|
|
|
17051
17300
|
## ❯ CHANGELOG
|
|
17052
17301
|
|
|
17302
|
+
8.2.0
|
|
17303
|
+
|
|
17304
|
+
Add the following methods:
|
|
17305
|
+
|
|
17306
|
+
- addIndex
|
|
17307
|
+
- addIndexRight
|
|
17308
|
+
- ap
|
|
17309
|
+
- aperture
|
|
17310
|
+
- applyTo
|
|
17311
|
+
- ascend
|
|
17312
|
+
- descend
|
|
17313
|
+
|
|
17314
|
+
8.1.0
|
|
17315
|
+
|
|
17316
|
+
- Fix input order of TS definitions for `R.propEq` method - [Issue #688](https://github.com/selfrefactor/rambda/issues/688). The issue was due to 8.0.0 was shipped with TS definitions of `7.5.0` release.
|
|
17317
|
+
|
|
17318
|
+
- Add `R.differenceWith` method - [Issue #91](https://github.com/selfrefactor/rambdax/issues/91)
|
|
17319
|
+
|
|
17053
17320
|
8.0.0
|
|
17054
17321
|
|
|
17055
17322
|
- handle falsy values in merge methods - https://github.com/ramda/ramda/pull/3222
|
|
@@ -17064,7 +17331,7 @@ describe('R.zipWith', () => {
|
|
|
17064
17331
|
|
|
17065
17332
|
- `R.nop` is removed - it will be moved to `Rambdax` as `R.noop`
|
|
17066
17333
|
|
|
17067
|
-
- `R.includes` is no longer using string literal in
|
|
17334
|
+
- `R.includes` is no longer using string literal in TypeScript definitions
|
|
17068
17335
|
|
|
17069
17336
|
> Reason for breaking change - synchronize with Ramda `0.29.0` release:
|
|
17070
17337
|
|
|
@@ -17094,7 +17361,7 @@ describe('R.zipWith', () => {
|
|
|
17094
17361
|
|
|
17095
17362
|
- Add `R.modify`
|
|
17096
17363
|
|
|
17097
|
-
- Allow multiple inputs in
|
|
17364
|
+
- Allow multiple inputs in TypeScript versions of `R.anyPass` and `R.allPass` - [Issue #642](https://github.com/selfrefactor/rambda/issues/604)
|
|
17098
17365
|
|
|
17099
17366
|
- Using wrong clone of object in `R.mergeDeepRight` - [Issue #650](https://github.com/selfrefactor/rambda/issues/650)
|
|
17100
17367
|
|
|
@@ -17104,7 +17371,7 @@ describe('R.zipWith', () => {
|
|
|
17104
17371
|
|
|
17105
17372
|
7.2.1
|
|
17106
17373
|
|
|
17107
|
-
- Remove bad typings of `R.propIs` which caused the library to cannot be build with
|
|
17374
|
+
- Remove bad typings of `R.propIs` which caused the library to cannot be build with TypeScript.
|
|
17108
17375
|
|
|
17109
17376
|
- Drop support for `Wallaby` as per [https://github.com/wallabyjs/public/issues/3037](https://github.com/wallabyjs/public/issues/3037)
|
|
17110
17377
|
|
|
@@ -17138,7 +17405,7 @@ describe('R.zipWith', () => {
|
|
|
17138
17405
|
|
|
17139
17406
|
- Replace `Async` with `Promise` as return type of `R.type`.
|
|
17140
17407
|
|
|
17141
|
-
- Add new types as
|
|
17408
|
+
- Add new types as TypeScript output for `R.type` - "Map", "WeakMap", "Generator", "GeneratorFunction", "BigInt", "ArrayBuffer"
|
|
17142
17409
|
|
|
17143
17410
|
- Add `R.juxt` method
|
|
17144
17411
|
|
|
@@ -17166,7 +17433,7 @@ Rambda doesn't work with `pnpm` due to wrong export configuration - [Issue #619]
|
|
|
17166
17433
|
|
|
17167
17434
|
7.0.0
|
|
17168
17435
|
|
|
17169
|
-
- Breaking change - sync `R.compose`/`R.pipe` with `@types/ramda`. That is significant change so as safeguard, it will lead a major bump. Important - this lead to raising required
|
|
17436
|
+
- Breaking change - sync `R.compose`/`R.pipe` with `@types/ramda`. That is significant change so as safeguard, it will lead a major bump. Important - this lead to raising required TypeScript version to `4.2.2`. In other words, to use `Rambda` you'll need TypeScript version `4.2.2` or newer.
|
|
17170
17437
|
|
|
17171
17438
|
Related commit in `@types/ramda` - https://github.com/DefinitelyTyped/DefinitelyTyped/commit/286eff4f76d41eb8f091e7437eabd8a60d97fc1f#diff-4f74803fa83a81e47cb17a7d8a4e46a7e451f4d9e5ce2f1bd7a70a72d91f4bc1
|
|
17172
17439
|
|
|
@@ -17249,7 +17516,7 @@ Fixing `R.uniq` was done by improving `R.indexOf` which has performance implicat
|
|
|
17249
17516
|
|
|
17250
17517
|
6.8.3
|
|
17251
17518
|
|
|
17252
|
-
- Fix
|
|
17519
|
+
- Fix TypeScript build process with `rambda/immutable` - [Issue #572](https://github.com/selfrefactor/rambda/issues/572)
|
|
17253
17520
|
|
|
17254
17521
|
- Add `R.objOf` method
|
|
17255
17522
|
|
|
@@ -17269,7 +17536,7 @@ Fixing `R.uniq` was done by improving `R.indexOf` which has performance implicat
|
|
|
17269
17536
|
|
|
17270
17537
|
6.7.0
|
|
17271
17538
|
|
|
17272
|
-
- Remove `ts-toolbelt` types from
|
|
17539
|
+
- Remove `ts-toolbelt` types from TypeScript definitions. Most affected are the following methods, which lose one of its curried definitions:
|
|
17273
17540
|
|
|
17274
17541
|
1. R.maxBy
|
|
17275
17542
|
2. R.minBy
|
|
@@ -17393,7 +17660,7 @@ Fix wrong versions in changelog
|
|
|
17393
17660
|
</td>
|
|
17394
17661
|
<td width="20%" align="center">
|
|
17395
17662
|
<h4>Useful Javascript libraries</h4>
|
|
17396
|
-
<a href="https://github.com/selfrefactor/useful-javascript-libraries">Large collection of JavaScript,
|
|
17663
|
+
<a href="https://github.com/selfrefactor/useful-javascript-libraries">Large collection of JavaScript,TypeScript and Angular related repos links</a>
|
|
17397
17664
|
</td>
|
|
17398
17665
|
<td width="20%" align="center">
|
|
17399
17666
|
<h4>Run-fn</h4>
|