rambda 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -91,7 +91,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
91
91
 
92
92
  <details>
93
93
  <summary>
94
- Click to see the full list of 85 Ramda methods not implemented in Rambda
94
+ Click to see the full list of 90 Ramda methods not implemented in Rambda
95
95
  </summary>
96
96
 
97
97
  - __
@@ -102,13 +102,12 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
102
102
  - ascend
103
103
  - binary
104
104
  - call
105
+ - collectBy
105
106
  - comparator
106
- - composeK
107
- - composeP
108
107
  - composeWith
109
108
  - construct
110
109
  - constructN
111
- - contains
110
+ - count
112
111
  - countBy
113
112
  - descend
114
113
  - differenceWith
@@ -141,18 +140,21 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
141
140
  - mergeRight
142
141
  - mergeWith
143
142
  - mergeWithKey
143
+ - modify
144
+ - modifyPath
144
145
  - nAry
146
+ - partialObject
145
147
  - nthArg
146
148
  - o
149
+ - on
147
150
  - otherwise
148
151
  - pair
149
152
  - partialRight
150
153
  - pathSatisfies
151
154
  - pickBy
152
- - pipeK
153
- - pipeP
154
155
  - pipeWith
155
156
  - project
157
+ - promap
156
158
  - propSatisfies
157
159
  - reduceBy
158
160
  - reduceRight
@@ -162,6 +164,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
162
164
  - scan
163
165
  - sequence
164
166
  - sortWith
167
+ - splitWhenever
165
168
  - symmetricDifferenceWith
166
169
  - andThen
167
170
  - toPairsIn
@@ -174,8 +177,10 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
174
177
  - uniqBy
175
178
  - unnest
176
179
  - until
180
+ - unwind
177
181
  - useWith
178
182
  - valuesIn
183
+ - whereAny
179
184
  - xprod
180
185
  - thunkify
181
186
  - default
@@ -986,103 +991,8 @@ describe('R.always', () => {
986
991
 
987
992
  ### and
988
993
 
989
- ```typescript
990
-
991
- and<T, U>(x: T, y: U): T | U
992
- ```
993
-
994
994
  Logical AND
995
995
 
996
- <details>
997
-
998
- <summary>All Typescript definitions</summary>
999
-
1000
- ```typescript
1001
- and<T, U>(x: T, y: U): T | U;
1002
- and<T>(x: T): <U>(y: U) => T | U;
1003
- ```
1004
-
1005
- </details>
1006
-
1007
- <details>
1008
-
1009
- <summary><strong>R.and</strong> source</summary>
1010
-
1011
- ```javascript
1012
- export function and(a, b) {
1013
- if (arguments.length === 1) return _b => and(a, _b)
1014
-
1015
- return a && b
1016
- }
1017
- ```
1018
-
1019
- </details>
1020
-
1021
- <details>
1022
-
1023
- <summary><strong>Tests</strong></summary>
1024
-
1025
- ```javascript
1026
- import {and} from './and'
1027
-
1028
- test('happy', () => {
1029
- expect(and(1, 'foo')).toBe('foo')
1030
- expect(and(true, true)).toBeTrue()
1031
- expect(and(true)(true)).toBeTrue()
1032
- expect(and(true, false)).toBeFalse()
1033
- expect(and(false, true)).toBeFalse()
1034
- expect(and(false, false)).toBeFalse()
1035
- })
1036
- ```
1037
-
1038
- </details>
1039
-
1040
- <details>
1041
-
1042
- <summary><strong>Typescript</strong> test</summary>
1043
-
1044
- ```typescript
1045
- import {and} from 'rambda'
1046
-
1047
- describe('R.and', () => {
1048
- it('happy', () => {
1049
- const result = and(true, false)
1050
- result // $ExpectType boolean
1051
- })
1052
- it('curried', () => {
1053
- const result = and('foo')(1)
1054
- result // $ExpectType string | 1
1055
- })
1056
- })
1057
- ```
1058
-
1059
- </details>
1060
-
1061
- <details>
1062
-
1063
- <summary>Rambda is faster than Ramda with 89.09%</summary>
1064
-
1065
- ```text
1066
- const R = require('../../dist/rambda.js')
1067
-
1068
- const and = [
1069
- {
1070
- label: 'Rambda',
1071
- fn: () => {
1072
- R.and(true, true)
1073
- },
1074
- },
1075
- {
1076
- label: 'Ramda',
1077
- fn: () => {
1078
- Ramda.and(true, true)
1079
- },
1080
- },
1081
- ]
1082
- ```
1083
-
1084
- </details>
1085
-
1086
996
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#and)
1087
997
 
1088
998
  ### any
@@ -1945,8 +1855,8 @@ describe('applySpec', () => {
1945
1855
  })
1946
1856
  it('ramda 1', () => {
1947
1857
  interface Output {
1948
- sum: number,
1949
- multiplied: number,
1858
+ sum: number
1859
+ multiplied: number
1950
1860
  }
1951
1861
  const result = applySpec<Output>({
1952
1862
  sum: add,
@@ -2417,8 +2327,8 @@ test('happy', () => {
2417
2327
  import {assocPath} from 'rambda'
2418
2328
 
2419
2329
  interface Output {
2420
- a: number,
2421
- foo: {bar: number},
2330
+ a: number
2331
+ foo: {bar: number}
2422
2332
  }
2423
2333
 
2424
2334
  describe('R.assocPath - user must explicitly set type of output', () => {
@@ -2754,607 +2664,33 @@ describe('R.both', () => {
2754
2664
 
2755
2665
  ```typescript
2756
2666
 
2757
- chain<T, U>(fn: (n: T) => U[], list: T[]): U[]
2758
- ```
2759
-
2760
- The method is also known as `flatMap`.
2761
-
2762
- <details>
2763
-
2764
- <summary>All Typescript definitions</summary>
2765
-
2766
- ```typescript
2767
- chain<T, U>(fn: (n: T) => U[], list: T[]): U[];
2768
- chain<T, U>(fn: (n: T) => U[]): (list: T[]) => U[];
2769
- ```
2770
-
2771
- </details>
2772
-
2773
- <details>
2774
-
2775
- <summary><strong>R.chain</strong> source</summary>
2776
-
2777
- ```javascript
2778
- export function chain(fn, list) {
2779
- if (arguments.length === 1) {
2780
- return _list => chain(fn, _list)
2781
- }
2782
-
2783
- return [].concat(...list.map(fn))
2784
- }
2785
- ```
2786
-
2787
- </details>
2788
-
2789
- <details>
2790
-
2791
- <summary><strong>Tests</strong></summary>
2792
-
2793
- ```javascript
2794
- import {chain} from './chain'
2795
- import {chain as chainRamda} from 'ramda'
2796
-
2797
- const duplicate = n => [n, n]
2798
-
2799
- test('happy', () => {
2800
- const fn = x => [x * 2]
2801
- const list = [1, 2, 3]
2802
-
2803
- const result = chain(fn, list)
2804
-
2805
- expect(result).toEqual([2, 4, 6])
2806
- })
2807
-
2808
- test('maps then flattens one level', () => {
2809
- expect(chain(duplicate, [1, 2, 3])).toEqual([1, 1, 2, 2, 3, 3])
2810
- })
2811
-
2812
- test('maps then flattens one level - curry', () => {
2813
- expect(chain(duplicate)([1, 2, 3])).toEqual([1, 1, 2, 2, 3, 3])
2814
- })
2815
-
2816
- test('flattens only one level', () => {
2817
- const nest = n => [[n]]
2818
- expect(chain(nest, [1, 2, 3])).toEqual([[1], [2], [3]])
2819
- })
2820
-
2821
- test('can compose', () => {
2822
- function dec(x) {
2823
- return [x - 1]
2824
- }
2825
- function times2(x) {
2826
- return [x * 2]
2827
- }
2828
-
2829
- var mdouble = chain(times2)
2830
- var mdec = chain(dec)
2831
- expect(mdec(mdouble([10, 20, 30]))).toEqual([19, 39, 59])
2832
- })
2833
-
2834
- test('@types/ramda broken test', () => {
2835
- const score = {
2836
- maths: 90,
2837
- physics: 80,
2838
- }
2839
-
2840
- const calculateTotal = score => {
2841
- const {maths, physics} = score
2842
- return maths + physics
2843
- }
2844
-
2845
- const assocTotalToScore = (total, score) => ({...score, total})
2846
-
2847
- const calculateAndAssocTotalToScore = chainRamda(
2848
- assocTotalToScore,
2849
- calculateTotal
2850
- )
2851
- expect(() => calculateAndAssocTotalToScore(score)).toThrow()
2852
- })
2853
- ```
2854
-
2855
- </details>
2856
-
2857
- <details>
2858
-
2859
- <summary><strong>Typescript</strong> test</summary>
2860
-
2861
- ```typescript
2862
- import {chain} from 'rambda'
2863
-
2864
- const list = [1, 2, 3]
2865
- const fn = (x: number) => [`${x}`, `${x}`]
2866
-
2867
- describe('R.chain', () => {
2868
- it('without passing type', () => {
2869
- const result = chain(fn, list)
2870
- result // $ExpectType string[]
2871
-
2872
- const curriedResult = chain(fn)(list)
2873
- curriedResult // $ExpectType string[]
2874
- })
2875
- })
2876
- ```
2877
-
2878
- </details>
2879
-
2880
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#chain)
2881
-
2882
- ### clamp
2883
-
2884
- ```typescript
2885
-
2886
- clamp(min: number, max: number, input: number): number
2887
- ```
2888
-
2889
- Restrict a number `input` to be within `min` and `max` limits.
2890
-
2891
- If `input` is bigger than `max`, then the result is `max`.
2892
-
2893
- If `input` is smaller than `min`, then the result is `min`.
2894
-
2895
- <details>
2896
-
2897
- <summary>All Typescript definitions</summary>
2898
-
2899
- ```typescript
2900
- clamp(min: number, max: number, input: number): number;
2901
- clamp(min: number, max: number): (input: number) => number;
2902
- ```
2903
-
2904
- </details>
2905
-
2906
- <details>
2907
-
2908
- <summary><strong>R.clamp</strong> source</summary>
2909
-
2910
- ```javascript
2911
- import {curry} from './curry'
2912
-
2913
- function clampFn(min, max, input) {
2914
- if (min > max) {
2915
- throw new Error(
2916
- 'min must not be greater than max in clamp(min, max, value)'
2917
- )
2918
- }
2919
- if (input >= min && input <= max) return input
2920
-
2921
- if (input > max) return max
2922
- if (input < min) return min
2923
- }
2924
-
2925
- export const clamp = curry(clampFn)
2926
- ```
2927
-
2928
- </details>
2929
-
2930
- <details>
2931
-
2932
- <summary><strong>Tests</strong></summary>
2933
-
2934
- ```javascript
2935
- import {clamp} from './clamp'
2936
-
2937
- test('when min is greater than max', () => {
2938
- expect(() => clamp(-5, -10, 5)).toThrowWithMessage(
2939
- Error,
2940
- 'min must not be greater than max in clamp(min, max, value)'
2941
- )
2942
- })
2943
-
2944
- test('rambda specs', () => {
2945
- expect(clamp(1, 10, 0)).toEqual(1)
2946
- expect(clamp(3, 12, 1)).toEqual(3)
2947
- expect(clamp(-15, 3, -100)).toEqual(-15)
2948
- expect(clamp(1, 10, 20)).toEqual(10)
2949
- expect(clamp(3, 12, 23)).toEqual(12)
2950
- expect(clamp(-15, 3, 16)).toEqual(3)
2951
- expect(clamp(1, 10, 4)).toEqual(4)
2952
- expect(clamp(3, 12, 6)).toEqual(6)
2953
- expect(clamp(-15, 3, 0)).toEqual(0)
2954
- })
2955
- ```
2956
-
2957
- </details>
2958
-
2959
- <details>
2960
-
2961
- <summary><strong>Typescript</strong> test</summary>
2962
-
2963
- ```typescript
2964
- import {clamp} from 'rambda'
2965
-
2966
- describe('R.clamp', () => {
2967
- it('happy', () => {
2968
- const result = clamp(1, 10, 20)
2969
- result // $ExpectType number
2970
- })
2971
- })
2972
- ```
2973
-
2974
- </details>
2975
-
2976
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clamp)
2977
-
2978
- ### clone
2979
-
2980
- ```typescript
2981
-
2982
- clone<T>(input: T): T
2983
- ```
2984
-
2985
- It creates a deep copy of the `input`, which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.
2986
-
2987
- <details>
2988
-
2989
- <summary>All Typescript definitions</summary>
2990
-
2991
- ```typescript
2992
- clone<T>(input: T): T;
2993
- clone<T>(input: T[]): T[];
2994
- ```
2995
-
2996
- </details>
2997
-
2998
- <details>
2999
-
3000
- <summary><strong>R.clone</strong> source</summary>
3001
-
3002
- ```javascript
3003
- import {_isArray} from './_internals/_isArray'
3004
-
3005
- export function clone(input) {
3006
- const out = _isArray(input) ? Array(input.length) : {}
3007
- if (input && input.getTime) return new Date(input.getTime())
3008
-
3009
- for (const key in input) {
3010
- const v = input[key]
3011
- out[key] =
3012
- typeof v === 'object' && v !== null
3013
- ? v.getTime
3014
- ? new Date(v.getTime())
3015
- : clone(v)
3016
- : v
3017
- }
3018
-
3019
- return out
3020
- }
3021
- ```
3022
-
3023
- </details>
3024
-
3025
- <details>
3026
-
3027
- <summary><strong>Tests</strong></summary>
3028
-
3029
- ```javascript
3030
- import assert from 'assert'
3031
-
3032
- import {clone} from './clone'
3033
- import {equals} from './equals'
3034
-
3035
- test('with array', () => {
3036
- const arr = [
3037
- {
3038
- b: 2,
3039
- c: 'foo',
3040
- d: [1, 2, 3],
3041
- },
3042
- 1,
3043
- new Date(),
3044
- null,
3045
- ]
3046
- expect(clone(arr)).toEqual(arr)
3047
- })
3048
-
3049
- test('with object', () => {
3050
- const obj = {
3051
- a: 1,
3052
- b: 2,
3053
- c: 3,
3054
- d: [1, 2, 3],
3055
- e: new Date(),
3056
- }
3057
- expect(clone(obj)).toEqual(obj)
3058
- })
3059
-
3060
- test('with date', () => {
3061
- const date = new Date(2014, 10, 14, 23, 59, 59, 999)
3062
-
3063
- const cloned = clone(date)
3064
- assert.notStrictEqual(date, cloned)
3065
- expect(cloned).toEqual(new Date(2014, 10, 14, 23, 59, 59, 999))
3066
-
3067
- expect(cloned.getDay()).toEqual(5)
3068
- })
3069
-
3070
- test('with R.equals', () => {
3071
- const objects = [{a: 1}, {b: 2}]
3072
-
3073
- const objectsClone = clone(objects)
3074
-
3075
- const result = [
3076
- equals(objects, objectsClone),
3077
- equals(objects[0], objectsClone[0]),
3078
- ]
3079
- expect(result).toEqual([true, true])
3080
- })
3081
- ```
3082
-
3083
- </details>
3084
-
3085
- <details>
3086
-
3087
- <summary><strong>Typescript</strong> test</summary>
3088
-
3089
- ```typescript
3090
- import {clone} from 'rambda'
3091
-
3092
- describe('R.clone', () => {
3093
- it('happy', () => {
3094
- const obj = {a: 1, b: 2}
3095
- const result = clone(obj)
3096
- result // $ExpectType { a: number; b: number; }
3097
- })
3098
- })
3099
- ```
3100
-
3101
- </details>
3102
-
3103
- <details>
3104
-
3105
- <summary>Rambda is fastest. Ramda is 91.86% slower and Lodash is 86.48% slower</summary>
3106
-
3107
- ```text
3108
- const R = require('../../dist/rambda.js')
3109
-
3110
- const input = {
3111
- a: 1,
3112
- b: 2,
3113
- }
3114
-
3115
- const clone = [
3116
- {
3117
- label: 'Rambda',
3118
- fn: () => {
3119
- R.clone(input)
3120
- },
3121
- },
3122
- {
3123
- label: 'Ramda',
3124
- fn: () => {
3125
- Ramda.clone(input)
3126
- },
3127
- },
3128
- {
3129
- label: 'Lodash.cloneDeep',
3130
- fn: () => {
3131
- _.cloneDeep(input)
3132
- },
3133
- },
3134
- ]
3135
- ```
3136
-
3137
- </details>
3138
-
3139
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clone)
3140
-
3141
- ### complement
3142
-
3143
- ```typescript
3144
-
3145
- complement<T extends any[]>(predicate: (...args: T) => unknown): (...args: T) => boolean
3146
- ```
3147
-
3148
- It returns `inverted` version of `origin` function that accept `input` as argument.
3149
-
3150
- The return value of `inverted` is the negative boolean value of `origin(input)`.
3151
-
3152
- <details>
3153
-
3154
- <summary>All Typescript definitions</summary>
3155
-
3156
- ```typescript
3157
- complement<T extends any[]>(predicate: (...args: T) => unknown): (...args: T) => boolean;
3158
- ```
3159
-
3160
- </details>
3161
-
3162
- <details>
3163
-
3164
- <summary><strong>R.complement</strong> source</summary>
3165
-
3166
- ```javascript
3167
- export function complement(fn) {
3168
- return (...input) => !fn(...input)
3169
- }
3170
- ```
3171
-
3172
- </details>
3173
-
3174
- <details>
3175
-
3176
- <summary><strong>Tests</strong></summary>
3177
-
3178
- ```javascript
3179
- import {complement} from './complement'
3180
-
3181
- test('happy', () => {
3182
- const fn = complement(x => x.length === 0)
3183
-
3184
- expect(fn([1, 2, 3])).toBeTrue()
3185
- })
3186
-
3187
- test('with multiple parameters', () => {
3188
- const between = function (a, b, c) {
3189
- return a < b && b < c
3190
- }
3191
- const f = complement(between)
3192
- expect(f(4, 5, 11)).toEqual(false)
3193
- expect(f(12, 2, 6)).toEqual(true)
3194
- })
3195
- ```
3196
-
3197
- </details>
3198
-
3199
- <details>
3200
-
3201
- <summary><strong>Typescript</strong> test</summary>
3202
-
3203
- ```typescript
3204
- import {complement, isNil} from 'rambda'
3205
-
3206
- describe('R.complement', () => {
3207
- it('happy', () => {
3208
- const fn = complement(isNil)
3209
- const result = fn(null)
3210
- result // $ExpectType boolean
3211
- })
3212
- })
3213
- ```
3214
-
3215
- </details>
3216
-
3217
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#complement)
3218
-
3219
- ### compose
3220
-
3221
- It performs right-to-left function composition.
3222
-
3223
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#compose)
3224
-
3225
- ### concat
3226
-
3227
- ```typescript
3228
-
3229
- concat<T>(x: T[], y: T[]): T[]
3230
- ```
3231
-
3232
- It returns a new string or array, which is the result of merging `x` and `y`.
3233
-
3234
- <details>
3235
-
3236
- <summary>All Typescript definitions</summary>
3237
-
3238
- ```typescript
3239
- concat<T>(x: T[], y: T[]): T[];
3240
- concat<T>(x: T[]): (y: T[]) => T[];
3241
- concat(x: string, y: string): string;
3242
- concat(x: string): (y: string) => string;
3243
- ```
3244
-
3245
- </details>
3246
-
3247
- <details>
3248
-
3249
- <summary><strong>R.concat</strong> source</summary>
3250
-
3251
- ```javascript
3252
- export function concat(x, y) {
3253
- if (arguments.length === 1) return _y => concat(x, _y)
3254
-
3255
- return typeof x === 'string' ? `${x}${y}` : [...x, ...y]
3256
- }
3257
- ```
3258
-
3259
- </details>
3260
-
3261
- <details>
3262
-
3263
- <summary><strong>Tests</strong></summary>
3264
-
3265
- ```javascript
3266
- import {concat} from './concat'
3267
-
3268
- test('happy', () => {
3269
- const arr1 = ['a', 'b', 'c']
3270
- const arr2 = ['d', 'e', 'f']
3271
-
3272
- const a = concat(arr1, arr2)
3273
- const b = concat(arr1)(arr2)
3274
- const expectedResult = ['a', 'b', 'c', 'd', 'e', 'f']
3275
-
3276
- expect(a).toEqual(expectedResult)
3277
- expect(b).toEqual(expectedResult)
3278
- })
3279
-
3280
- test('with strings', () => {
3281
- expect(concat('ABC', 'DEF')).toEqual('ABCDEF')
3282
- })
3283
- ```
3284
-
3285
- </details>
3286
-
3287
- <details>
3288
-
3289
- <summary><strong>Typescript</strong> test</summary>
3290
-
3291
- ```typescript
3292
- import {concat} from 'rambda'
3293
-
3294
- const list1 = [1, 2, 3]
3295
- const list2 = [4, 5, 6]
3296
-
3297
- describe('R.concat', () => {
3298
- it('happy', () => {
3299
- const result = concat(list1, list2)
3300
-
3301
- result // $ExpectType number[]
3302
- })
3303
- it('curried', () => {
3304
- const result = concat(list1)(list2)
3305
-
3306
- result // $ExpectType number[]
3307
- })
3308
- })
3309
- ```
3310
-
3311
- </details>
3312
-
3313
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#concat)
3314
-
3315
- ### cond
3316
-
3317
- ```typescript
3318
-
3319
- cond<T extends any[], R>(conditions: Array<CondPair<T, R>>): (...args: T) => R
3320
- ```
3321
-
3322
- It takes list with `conditions` and returns a new function `fn` that expects `input` as argument.
3323
-
3324
- This function will start evaluating the `conditions` in order to find the first winner(order of conditions matter).
3325
-
3326
- The winner is this condition, which left side returns `true` when `input` is its argument. Then the evaluation of the right side of the winner will be the final result.
2667
+ chain<T, U>(fn: (n: T) => U[], list: T[]): U[]
2668
+ ```
3327
2669
 
3328
- If no winner is found, then `fn` returns `undefined`.
2670
+ The method is also known as `flatMap`.
3329
2671
 
3330
2672
  <details>
3331
2673
 
3332
2674
  <summary>All Typescript definitions</summary>
3333
2675
 
3334
2676
  ```typescript
3335
- cond<T extends any[], R>(conditions: Array<CondPair<T, R>>): (...args: T) => R;
2677
+ chain<T, U>(fn: (n: T) => U[], list: T[]): U[];
2678
+ chain<T, U>(fn: (n: T) => U[]): (list: T[]) => U[];
3336
2679
  ```
3337
2680
 
3338
2681
  </details>
3339
2682
 
3340
2683
  <details>
3341
2684
 
3342
- <summary><strong>R.cond</strong> source</summary>
2685
+ <summary><strong>R.chain</strong> source</summary>
3343
2686
 
3344
2687
  ```javascript
3345
- export function cond(conditions) {
3346
- return input => {
3347
- let done = false
3348
- let toReturn
3349
- conditions.forEach(([predicate, resultClosure]) => {
3350
- if (!done && predicate(input)) {
3351
- done = true
3352
- toReturn = resultClosure(input)
3353
- }
3354
- })
3355
-
3356
- return toReturn
2688
+ export function chain(fn, list) {
2689
+ if (arguments.length === 1) {
2690
+ return _list => chain(fn, _list)
3357
2691
  }
2692
+
2693
+ return [].concat(...list.map(fn))
3358
2694
  }
3359
2695
  ```
3360
2696
 
@@ -3365,46 +2701,64 @@ export function cond(conditions) {
3365
2701
  <summary><strong>Tests</strong></summary>
3366
2702
 
3367
2703
  ```javascript
3368
- import {always} from './always'
3369
- import {cond} from './cond'
3370
- import {equals} from './equals'
3371
- import {T} from './T'
2704
+ import {chain} from './chain'
2705
+ import {chain as chainRamda} from 'ramda'
2706
+
2707
+ const duplicate = n => [n, n]
2708
+
2709
+ test('happy', () => {
2710
+ const fn = x => [x * 2]
2711
+ const list = [1, 2, 3]
2712
+
2713
+ const result = chain(fn, list)
3372
2714
 
3373
- test('returns a function', () => {
3374
- expect(typeof cond([])).toEqual('function')
2715
+ expect(result).toEqual([2, 4, 6])
3375
2716
  })
3376
2717
 
3377
- test('returns a conditional function', () => {
3378
- const fn = cond([
3379
- [equals(0), always('water freezes at 0°C')],
3380
- [equals(100), always('water boils at 100°C')],
3381
- [
3382
- T,
3383
- function (temp) {
3384
- return 'nothing special happens at ' + temp + '°C'
3385
- },
3386
- ],
3387
- ])
3388
- expect(fn(0)).toEqual('water freezes at 0°C')
3389
- expect(fn(50)).toEqual('nothing special happens at 50°C')
3390
- expect(fn(100)).toEqual('water boils at 100°C')
2718
+ test('maps then flattens one level', () => {
2719
+ expect(chain(duplicate, [1, 2, 3])).toEqual([1, 1, 2, 2, 3, 3])
3391
2720
  })
3392
2721
 
3393
- test('no winner', () => {
3394
- const fn = cond([
3395
- [equals('foo'), always(1)],
3396
- [equals('bar'), always(2)],
3397
- ])
3398
- expect(fn('quux')).toEqual(undefined)
2722
+ test('maps then flattens one level - curry', () => {
2723
+ expect(chain(duplicate)([1, 2, 3])).toEqual([1, 1, 2, 2, 3, 3])
3399
2724
  })
3400
2725
 
3401
- test('predicates are tested in order', () => {
3402
- const fn = cond([
3403
- [T, always('foo')],
3404
- [T, always('bar')],
3405
- [T, always('baz')],
3406
- ])
3407
- expect(fn()).toEqual('foo')
2726
+ test('flattens only one level', () => {
2727
+ const nest = n => [[n]]
2728
+ expect(chain(nest, [1, 2, 3])).toEqual([[1], [2], [3]])
2729
+ })
2730
+
2731
+ test('can compose', () => {
2732
+ function dec(x) {
2733
+ return [x - 1]
2734
+ }
2735
+ function times2(x) {
2736
+ return [x * 2]
2737
+ }
2738
+
2739
+ var mdouble = chain(times2)
2740
+ var mdec = chain(dec)
2741
+ expect(mdec(mdouble([10, 20, 30]))).toEqual([19, 39, 59])
2742
+ })
2743
+
2744
+ test('@types/ramda broken test', () => {
2745
+ const score = {
2746
+ maths: 90,
2747
+ physics: 80,
2748
+ }
2749
+
2750
+ const calculateTotal = score => {
2751
+ const {maths, physics} = score
2752
+ return maths + physics
2753
+ }
2754
+
2755
+ const assocTotalToScore = (total, score) => ({...score, total})
2756
+
2757
+ const calculateAndAssocTotalToScore = chainRamda(
2758
+ assocTotalToScore,
2759
+ calculateTotal
2760
+ )
2761
+ expect(() => calculateAndAssocTotalToScore(score)).toThrow()
3408
2762
  })
3409
2763
  ```
3410
2764
 
@@ -3415,30 +2769,72 @@ test('predicates are tested in order', () => {
3415
2769
  <summary><strong>Typescript</strong> test</summary>
3416
2770
 
3417
2771
  ```typescript
3418
- import {cond, always, equals} from 'rambda'
2772
+ import {chain} from 'rambda'
3419
2773
 
3420
- describe('R.cond', () => {
3421
- it('happy', () => {
3422
- const fn = cond<number[], string>([
3423
- [equals(0), always('water freezes at 0°C')],
3424
- [equals(100), always('water boils at 100°C')],
3425
- [
3426
- () => true,
3427
- function(temp) {
3428
- temp // $ExpectType number
3429
- return 'nothing special happens at ' + temp + '°C'
3430
- },
3431
- ],
3432
- ])
2774
+ const list = [1, 2, 3]
2775
+ const fn = (x: number) => [`${x}`, `${x}`]
3433
2776
 
3434
- const result = fn(0)
3435
- result // $ExpectType string
2777
+ describe('R.chain', () => {
2778
+ it('without passing type', () => {
2779
+ const result = chain(fn, list)
2780
+ result // $ExpectType string[]
2781
+
2782
+ const curriedResult = chain(fn)(list)
2783
+ curriedResult // $ExpectType string[]
3436
2784
  })
3437
2785
  })
3438
2786
  ```
3439
2787
 
3440
2788
  </details>
3441
2789
 
2790
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#chain)
2791
+
2792
+ ### clamp
2793
+
2794
+ Restrict a number `input` to be within `min` and `max` limits.
2795
+
2796
+ If `input` is bigger than `max`, then the result is `max`.
2797
+
2798
+ If `input` is smaller than `min`, then the result is `min`.
2799
+
2800
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clamp)
2801
+
2802
+ ### clone
2803
+
2804
+ It creates a deep copy of the `input`, which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.
2805
+
2806
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clone)
2807
+
2808
+ ### complement
2809
+
2810
+ It returns `inverted` version of `origin` function that accept `input` as argument.
2811
+
2812
+ The return value of `inverted` is the negative boolean value of `origin(input)`.
2813
+
2814
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#complement)
2815
+
2816
+ ### compose
2817
+
2818
+ It performs right-to-left function composition.
2819
+
2820
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#compose)
2821
+
2822
+ ### concat
2823
+
2824
+ It returns a new string or array, which is the result of merging `x` and `y`.
2825
+
2826
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#concat)
2827
+
2828
+ ### cond
2829
+
2830
+ It takes list with `conditions` and returns a new function `fn` that expects `input` as argument.
2831
+
2832
+ This function will start evaluating the `conditions` in order to find the first winner(order of conditions matter).
2833
+
2834
+ The winner is this condition, which left side returns `true` when `input` is its argument. Then the evaluation of the right side of the winner will be the final result.
2835
+
2836
+ If no winner is found, then `fn` returns `undefined`.
2837
+
3442
2838
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#cond)
3443
2839
 
3444
2840
  ### converge
@@ -5452,7 +4848,7 @@ export function filter(predicate, iterable) {
5452
4848
  throw new Error('Incorrect iterable input')
5453
4849
  }
5454
4850
 
5455
- if (_isArray(iterable)) return filterArray(predicate, iterable)
4851
+ if (_isArray(iterable)) return filterArray(predicate, iterable, false)
5456
4852
 
5457
4853
  return filterObject(predicate, iterable)
5458
4854
  }
@@ -8159,7 +7555,7 @@ export function lens(getter, setter) {
8159
7555
  import {lens, assoc} from 'rambda'
8160
7556
 
8161
7557
  interface Input {
8162
- foo: string,
7558
+ foo: string
8163
7559
  }
8164
7560
 
8165
7561
  describe('R.lens', () => {
@@ -8279,7 +7675,7 @@ test('get (set(set s v1) v2) === v2', () => {
8279
7675
  import {view, lensIndex} from 'rambda'
8280
7676
 
8281
7677
  interface Input {
8282
- a: number,
7678
+ a: number
8283
7679
  }
8284
7680
  const testList: Input[] = [{a: 1}, {a: 2}, {a: 3}]
8285
7681
 
@@ -8453,11 +7849,11 @@ test('get (set(set s v1) v2) === v2', () => {
8453
7849
  import {lensPath, view} from 'rambda'
8454
7850
 
8455
7851
  interface Input {
8456
- foo: number[],
7852
+ foo: number[]
8457
7853
  bar: {
8458
- a: string,
8459
- b: string,
8460
- },
7854
+ a: string
7855
+ b: string
7856
+ }
8461
7857
  }
8462
7858
 
8463
7859
  const testObject: Input = {
@@ -8627,7 +8023,7 @@ test('get (set(set s v1) v2) === v2', () => {
8627
8023
  import {lensProp, view} from 'rambda'
8628
8024
 
8629
8025
  interface Input {
8630
- foo: string,
8026
+ foo: string
8631
8027
  }
8632
8028
 
8633
8029
  const testObject: Input = {
@@ -9057,167 +8453,13 @@ const match = [
9057
8453
 
9058
8454
  ### max
9059
8455
 
9060
- ```typescript
9061
-
9062
- max<T extends Ord>(x: T, y: T): T
9063
- ```
9064
-
9065
8456
  It returns the greater value between `x` and `y`.
9066
8457
 
9067
- <details>
9068
-
9069
- <summary>All Typescript definitions</summary>
9070
-
9071
- ```typescript
9072
- max<T extends Ord>(x: T, y: T): T;
9073
- max<T extends Ord>(x: T): (y: T) => T;
9074
- ```
9075
-
9076
- </details>
9077
-
9078
- <details>
9079
-
9080
- <summary><strong>R.max</strong> source</summary>
9081
-
9082
- ```javascript
9083
- export function max(x, y) {
9084
- if (arguments.length === 1) return _y => max(x, _y)
9085
-
9086
- return y > x ? y : x
9087
- }
9088
- ```
9089
-
9090
- </details>
9091
-
9092
- <details>
9093
-
9094
- <summary><strong>Tests</strong></summary>
9095
-
9096
- ```javascript
9097
- import {max} from './max'
9098
-
9099
- test('with number', () => {
9100
- expect(max(2, 1)).toBe(2)
9101
- })
9102
-
9103
- test('with string', () => {
9104
- expect(max('foo')('bar')).toBe('foo')
9105
- expect(max('bar')('baz')).toBe('baz')
9106
- })
9107
- ```
9108
-
9109
- </details>
9110
-
9111
- <details>
9112
-
9113
- <summary><strong>Typescript</strong> test</summary>
9114
-
9115
- ```typescript
9116
- import {max} from 'rambda'
9117
-
9118
- const first = 1
9119
- const second = 2
9120
-
9121
- describe('R.max', () => {
9122
- it('happy', () => {
9123
- const result = max(first, second)
9124
- result // $ExpectType 1 | 2
9125
- })
9126
- it('curried', () => {
9127
- const result = max(first, second)
9128
- result // $ExpectType 1 | 2
9129
- })
9130
- it('curried - cann pass type', () => {
9131
- const result = max<number>(first, second)
9132
- result // $ExpectType number
9133
- })
9134
- it('can pass type', () => {
9135
- const result = max<number>(first, second)
9136
- result // $ExpectType number
9137
- })
9138
- })
9139
- ```
9140
-
9141
- </details>
9142
-
9143
- [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#max)
9144
-
9145
- ### maxBy
9146
-
9147
- ```typescript
9148
-
9149
- maxBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T
9150
- ```
9151
-
9152
- It returns the greater value between `x` and `y` according to `compareFn` function.
9153
-
9154
- <details>
9155
-
9156
- <summary>All Typescript definitions</summary>
9157
-
9158
- ```typescript
9159
- maxBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T;
9160
- maxBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
9161
- maxBy<T>(compareFn: (input: T) => Ord): (x: T) => (y: T) => T;
9162
- ```
9163
-
9164
- </details>
9165
-
9166
- <details>
9167
-
9168
- <summary><strong>R.maxBy</strong> source</summary>
9169
-
9170
- ```javascript
9171
- import {curry} from './curry'
9172
-
9173
- export function maxByFn(compareFn, x, y) {
9174
- return compareFn(y) > compareFn(x) ? y : x
9175
- }
9176
-
9177
- export const maxBy = curry(maxByFn)
9178
- ```
9179
-
9180
- </details>
9181
-
9182
- <details>
9183
-
9184
- <summary><strong>Tests</strong></summary>
9185
-
9186
- ```javascript
9187
- import {maxBy} from './maxBy'
9188
-
9189
- test('happy', () => {
9190
- expect(maxBy(Math.abs, -5, 2)).toEqual(-5)
9191
- })
9192
-
9193
- test('curried', () => {
9194
- expect(maxBy(Math.abs)(2, -5)).toEqual(-5)
9195
- expect(maxBy(Math.abs)(2)(-5)).toEqual(-5)
9196
- })
9197
- ```
9198
-
9199
- </details>
9200
-
9201
- <details>
9202
-
9203
- <summary><strong>Typescript</strong> test</summary>
9204
-
9205
- ```typescript
9206
- import {maxBy} from 'rambda'
9207
-
9208
- const compareFn = (x: number) => x % 2 === 0 ? 1 : -1
9209
- const first = 1
9210
- const second = 2
9211
-
9212
- describe('R.maxBy', () => {
9213
- it('happy', () => {
9214
- const result = maxBy(compareFn, first, second)
9215
- result // $ExpectType 1 | 2
9216
- })
9217
- })
9218
- ```
8458
+ [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#max)
9219
8459
 
9220
- </details>
8460
+ ### maxBy
8461
+
8462
+ It returns the greater value between `x` and `y` according to `compareFn` function.
9221
8463
 
9222
8464
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#maxBy)
9223
8465
 
@@ -9461,8 +8703,8 @@ test('when undefined or null instead of object', () => {
9461
8703
  import {merge} from 'rambda'
9462
8704
 
9463
8705
  interface Output {
9464
- foo: number,
9465
- bar: number,
8706
+ foo: number
8707
+ bar: number
9466
8708
  }
9467
8709
 
9468
8710
  describe('R.merge', () => {
@@ -9593,8 +8835,8 @@ import {mergeAll} from 'rambda'
9593
8835
  describe('R.mergeAll', () => {
9594
8836
  it('with passing type', () => {
9595
8837
  interface Output {
9596
- foo: number,
9597
- bar: number,
8838
+ foo: number
8839
+ bar: number
9598
8840
  }
9599
8841
  const result = mergeAll<Output>([{foo: 1}, {bar: 2}])
9600
8842
  result.foo // $ExpectType number
@@ -9784,8 +9026,8 @@ import {mergeDeepRight} from 'rambda'
9784
9026
 
9785
9027
  interface Output {
9786
9028
  foo: {
9787
- bar: number,
9788
- },
9029
+ bar: number
9030
+ }
9789
9031
  }
9790
9032
 
9791
9033
  describe('R.mergeDeepRight', () => {
@@ -9879,8 +9121,8 @@ test('when undefined or null instead of object', () => {
9879
9121
  import {mergeLeft} from 'rambda'
9880
9122
 
9881
9123
  interface Output {
9882
- foo: number,
9883
- bar: number,
9124
+ foo: number
9125
+ bar: number
9884
9126
  }
9885
9127
 
9886
9128
  describe('R.mergeLeft', () => {
@@ -9899,164 +9141,14 @@ describe('R.mergeLeft', () => {
9899
9141
 
9900
9142
  ### min
9901
9143
 
9902
- ```typescript
9903
-
9904
- min<T extends Ord>(x: T, y: T): T
9905
- ```
9906
-
9907
9144
  It returns the lesser value between `x` and `y`.
9908
9145
 
9909
- <details>
9910
-
9911
- <summary>All Typescript definitions</summary>
9912
-
9913
- ```typescript
9914
- min<T extends Ord>(x: T, y: T): T;
9915
- min<T extends Ord>(x: T): (y: T) => T;
9916
- ```
9917
-
9918
- </details>
9919
-
9920
- <details>
9921
-
9922
- <summary><strong>R.min</strong> source</summary>
9923
-
9924
- ```javascript
9925
- export function min(x, y) {
9926
- if (arguments.length === 1) return _y => min(x, _y)
9927
-
9928
- return y < x ? y : x
9929
- }
9930
- ```
9931
-
9932
- </details>
9933
-
9934
- <details>
9935
-
9936
- <summary><strong>Tests</strong></summary>
9937
-
9938
- ```javascript
9939
- import {min} from './min'
9940
-
9941
- test('happy', () => {
9942
- expect(min(2, 1)).toBe(1)
9943
- expect(min(1)(2)).toBe(1)
9944
- })
9945
- ```
9946
-
9947
- </details>
9948
-
9949
- <details>
9950
-
9951
- <summary><strong>Typescript</strong> test</summary>
9952
-
9953
- ```typescript
9954
- import {min} from 'rambda'
9955
-
9956
- const first = 1
9957
- const second = 2
9958
-
9959
- describe('R.min', () => {
9960
- it('happy', () => {
9961
- const result = min(first, second)
9962
- result // $ExpectType 1 | 2
9963
- })
9964
- it('curried', () => {
9965
- const result = min(first, second)
9966
- result // $ExpectType 1 | 2
9967
- })
9968
- it('curried - cann pass type', () => {
9969
- const result = min<number>(first, second)
9970
- result // $ExpectType number
9971
- })
9972
- it('can pass type', () => {
9973
- const result = min<number>(first, second)
9974
- result // $ExpectType number
9975
- })
9976
- })
9977
- ```
9978
-
9979
- </details>
9980
-
9981
9146
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#min)
9982
9147
 
9983
9148
  ### minBy
9984
9149
 
9985
- ```typescript
9986
-
9987
- minBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T
9988
- ```
9989
-
9990
9150
  It returns the lesser value between `x` and `y` according to `compareFn` function.
9991
9151
 
9992
- <details>
9993
-
9994
- <summary>All Typescript definitions</summary>
9995
-
9996
- ```typescript
9997
- minBy<T>(compareFn: (input: T) => Ord, x: T, y: T): T;
9998
- minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
9999
- minBy<T>(compareFn: (input: T) => Ord): (x: T) => (y: T) => T;
10000
- ```
10001
-
10002
- </details>
10003
-
10004
- <details>
10005
-
10006
- <summary><strong>R.minBy</strong> source</summary>
10007
-
10008
- ```javascript
10009
- import {curry} from './curry'
10010
-
10011
- export function minByFn(compareFn, x, y) {
10012
- return compareFn(y) < compareFn(x) ? y : x
10013
- }
10014
-
10015
- export const minBy = curry(minByFn)
10016
- ```
10017
-
10018
- </details>
10019
-
10020
- <details>
10021
-
10022
- <summary><strong>Tests</strong></summary>
10023
-
10024
- ```javascript
10025
- import {minBy} from './minBy'
10026
-
10027
- test('happy', () => {
10028
- expect(minBy(Math.abs, -5, 2)).toEqual(2)
10029
- })
10030
-
10031
- test('curried', () => {
10032
- expect(minBy(Math.abs)(2, -5)).toEqual(2)
10033
- expect(minBy(Math.abs)(2)(-5)).toEqual(2)
10034
- })
10035
- ```
10036
-
10037
- </details>
10038
-
10039
- <details>
10040
-
10041
- <summary><strong>Typescript</strong> test</summary>
10042
-
10043
- ```typescript
10044
- import {minBy} from 'rambda'
10045
-
10046
- const compareFn = (x: number) => x % 2 === 0 ? 1 : -1
10047
- const first = 1
10048
- const second = 2
10049
-
10050
- describe('R.minBy', () => {
10051
- it('happy', () => {
10052
- const result = minBy(compareFn, first, second)
10053
- result // $ExpectType 1 | 2
10054
- })
10055
- })
10056
- ```
10057
-
10058
- </details>
10059
-
10060
9152
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#minBy)
10061
9153
 
10062
9154
  ### modulo
@@ -10067,115 +9159,8 @@ Curried version of `x%y`.
10067
9159
 
10068
9160
  ### move
10069
9161
 
10070
- ```typescript
10071
-
10072
- move<T>(fromIndex: number, toIndex: number, list: T[]): T[]
10073
- ```
10074
-
10075
9162
  It returns a copy of `list` with exchanged `fromIndex` and `toIndex` elements.
10076
9163
 
10077
- <details>
10078
-
10079
- <summary>All Typescript definitions</summary>
10080
-
10081
- ```typescript
10082
- move<T>(fromIndex: number, toIndex: number, list: T[]): T[];
10083
- move(fromIndex: number, toIndex: number): <T>(list: T[]) => T[];
10084
- move(fromIndex: number): {
10085
- <T>(toIndex: number, list: T[]): T[];
10086
- (toIndex: number): <T>(list: T[]) => T[];
10087
- };
10088
- ```
10089
-
10090
- </details>
10091
-
10092
- <details>
10093
-
10094
- <summary><strong>R.move</strong> source</summary>
10095
-
10096
- ```javascript
10097
- import {curry} from './curry'
10098
- import {cloneList} from './_internals/cloneList'
10099
-
10100
- function moveFn(fromIndex, toIndex, list) {
10101
- if (fromIndex < 0 || toIndex < 0) {
10102
- throw new Error('Rambda.move does not support negative indexes')
10103
- }
10104
- if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list
10105
-
10106
- const clone = cloneList(list)
10107
- clone[fromIndex] = list[toIndex]
10108
- clone[toIndex] = list[fromIndex]
10109
-
10110
- return clone
10111
- }
10112
-
10113
- export const move = curry(moveFn)
10114
- ```
10115
-
10116
- </details>
10117
-
10118
- <details>
10119
-
10120
- <summary><strong>Tests</strong></summary>
10121
-
10122
- ```javascript
10123
- import {move} from './move'
10124
- const list = [1, 2, 3, 4]
10125
-
10126
- test('happy', () => {
10127
- const result = move(0, 1, list)
10128
-
10129
- expect(result).toEqual([2, 1, 3, 4])
10130
- })
10131
-
10132
- test('with negative index', () => {
10133
- const errorMessage = 'Rambda.move does not support negative indexes'
10134
- expect(() => move(0, -1, list)).toThrowWithMessage(Error, errorMessage)
10135
- expect(() => move(-1, 0, list)).toThrowWithMessage(Error, errorMessage)
10136
- })
10137
-
10138
- test('when indexes are outside the list outbounds', () => {
10139
- const result1 = move(10, 1, list)
10140
- const result2 = move(1, 10, list)
10141
-
10142
- expect(result1).toEqual(list)
10143
- expect(result2).toEqual(list)
10144
- })
10145
- ```
10146
-
10147
- </details>
10148
-
10149
- <details>
10150
-
10151
- <summary><strong>Typescript</strong> test</summary>
10152
-
10153
- ```typescript
10154
- import {move} from 'rambda'
10155
-
10156
- const list = [1, 2, 3]
10157
-
10158
- describe('R.move', () => {
10159
- it('happy', () => {
10160
- const result = move(0, 1, list)
10161
-
10162
- result // $ExpectType number[]
10163
- })
10164
- it('curried 1', () => {
10165
- const result = move(0, 1)(list)
10166
-
10167
- result // $ExpectType number[]
10168
- })
10169
- it('curried 2', () => {
10170
- const result = move(0)(1)(list)
10171
-
10172
- result // $ExpectType number[]
10173
- })
10174
- })
10175
- ```
10176
-
10177
- </details>
10178
-
10179
9164
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#move)
10180
9165
 
10181
9166
  ### multiply
@@ -10673,10 +9658,10 @@ describe('R.omit with array as props input', () => {
10673
9658
 
10674
9659
  it('declare type of input object', () => {
10675
9660
  interface Input {
10676
- a: string,
10677
- b: number,
10678
- c: number,
10679
- d: number,
9661
+ a: string
9662
+ b: number
9663
+ c: number
9664
+ d: number
10680
9665
  }
10681
9666
  const input: Input = {a: 'foo', b: 2, c: 3, d: 4}
10682
9667
  const result = omit(['b,c'], input)
@@ -10694,8 +9679,8 @@ describe('R.omit with array as props input', () => {
10694
9679
 
10695
9680
  describe('R.omit with string as props input', () => {
10696
9681
  interface Output {
10697
- b: number,
10698
- d: number,
9682
+ b: number
9683
+ d: number
10699
9684
  }
10700
9685
 
10701
9686
  it('explicitly declare output', () => {
@@ -10710,10 +9695,10 @@ describe('R.omit with string as props input', () => {
10710
9695
 
10711
9696
  it('explicitly declare input and output', () => {
10712
9697
  interface Input {
10713
- a: number,
10714
- b: number,
10715
- c: number,
10716
- d: number,
9698
+ a: number
9699
+ b: number
9700
+ c: number
9701
+ d: number
10717
9702
  }
10718
9703
  const result = omit<Input, Output>('a,c', {a: 1, b: 2, c: 3, d: 4})
10719
9704
  result // $ExpectType Output
@@ -10885,76 +9870,8 @@ describe('R.once', () => {
10885
9870
 
10886
9871
  ### or
10887
9872
 
10888
- ```typescript
10889
-
10890
- or<T, U>(a: T, b: U): T | U
10891
- ```
10892
-
10893
9873
  Logical OR
10894
9874
 
10895
- <details>
10896
-
10897
- <summary>All Typescript definitions</summary>
10898
-
10899
- ```typescript
10900
- or<T, U>(a: T, b: U): T | U;
10901
- or<T>(a: T): <U>(b: U) => T | U;
10902
- ```
10903
-
10904
- </details>
10905
-
10906
- <details>
10907
-
10908
- <summary><strong>R.or</strong> source</summary>
10909
-
10910
- ```javascript
10911
- export function or(a, b) {
10912
- if (arguments.length === 1) return _b => or(a, _b)
10913
-
10914
- return a || b
10915
- }
10916
- ```
10917
-
10918
- </details>
10919
-
10920
- <details>
10921
-
10922
- <summary><strong>Tests</strong></summary>
10923
-
10924
- ```javascript
10925
- import {or} from './or'
10926
-
10927
- test('happy', () => {
10928
- expect(or(0, 'foo')).toBe('foo')
10929
- expect(or(true, true)).toBeTrue()
10930
- expect(or(false)(true)).toBeTrue()
10931
- expect(or(false, false)).toBeFalse()
10932
- })
10933
- ```
10934
-
10935
- </details>
10936
-
10937
- <details>
10938
-
10939
- <summary><strong>Typescript</strong> test</summary>
10940
-
10941
- ```typescript
10942
- import {or} from 'ramda'
10943
-
10944
- describe('R.or', () => {
10945
- it('happy', () => {
10946
- const result = or(true, false)
10947
- result // $ExpectType boolean
10948
- })
10949
- it('curried', () => {
10950
- const result = or(1)('foo')
10951
- result // $ExpectType number | "foo"
10952
- })
10953
- })
10954
- ```
10955
-
10956
- </details>
10957
-
10958
9875
  [![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#or)
10959
9876
 
10960
9877
  ### over
@@ -11539,10 +10456,10 @@ test('null is not a valid path', () => {
11539
10456
  import {path} from 'rambda'
11540
10457
 
11541
10458
  interface Input {
11542
- a: number,
10459
+ a: number
11543
10460
  b: {
11544
- c: boolean,
11545
- },
10461
+ c: boolean
10462
+ }
11546
10463
  }
11547
10464
 
11548
10465
  describe('R.path', () => {
@@ -12005,9 +10922,9 @@ test('returns undefined for items not found', () => {
12005
10922
  import {paths} from 'rambda'
12006
10923
 
12007
10924
  interface Input {
12008
- a: number,
12009
- b: number,
12010
- c: number,
10925
+ a: number
10926
+ b: number
10927
+ c: number
12011
10928
  }
12012
10929
 
12013
10930
  const input: Input = {a: 1, b: 2, c: 3}
@@ -12127,6 +11044,13 @@ test('when prop is missing', () => {
12127
11044
  expect(result).toEqual({a: 1})
12128
11045
  })
12129
11046
 
11047
+ test('with list indexes as props', () => {
11048
+ const list = [1, 2, 3]
11049
+ const expected = {0: 1, 2: 3}
11050
+ expect(pick([0, 2, 3], list)).toEqual(expected)
11051
+ expect(pick('0,2,3', list)).toEqual(expected)
11052
+ })
11053
+
12130
11054
  test('props to pick is an array', () => {
12131
11055
  expect(
12132
11056
  pick(['a', 'c'])({
@@ -12197,14 +11121,14 @@ describe('R.pick with array as props input', () => {
12197
11121
 
12198
11122
  describe('R.pick with string as props input', () => {
12199
11123
  interface Input {
12200
- a: string,
12201
- b: number,
12202
- c: number,
12203
- d: number,
11124
+ a: string
11125
+ b: number
11126
+ c: number
11127
+ d: number
12204
11128
  }
12205
11129
  interface Output {
12206
- a: string,
12207
- c: number,
11130
+ a: string
11131
+ c: number
12208
11132
  }
12209
11133
  it('explicitly declare output', () => {
12210
11134
  const result = pick<Output>('a,c', input)
@@ -12383,14 +11307,14 @@ test('with array as condition', () => {
12383
11307
  import {pickAll} from 'rambda'
12384
11308
 
12385
11309
  interface Input {
12386
- a: string,
12387
- b: number,
12388
- c: number,
12389
- d: number,
11310
+ a: string
11311
+ b: number
11312
+ c: number
11313
+ d: number
12390
11314
  }
12391
11315
  interface Output {
12392
- a?: string,
12393
- c?: number,
11316
+ a?: string
11317
+ c?: number
12394
11318
  }
12395
11319
  const input = {a: 'foo', b: 2, c: 3, d: 4}
12396
11320
 
@@ -12526,8 +11450,8 @@ import {pluck} from 'rambda'
12526
11450
  describe('R.pluck', () => {
12527
11451
  it('with object', () => {
12528
11452
  interface ListMember {
12529
- a: number,
12530
- b: string,
11453
+ a: number
11454
+ b: string
12531
11455
  }
12532
11456
  const input: ListMember[] = [
12533
11457
  {a: 1, b: 'foo'},
@@ -12940,7 +11864,7 @@ describe('R.propEq', () => {
12940
11864
 
12941
11865
  it('with optional property', () => {
12942
11866
  interface MyType {
12943
- optional?: string | number,
11867
+ optional?: string | number
12944
11868
  }
12945
11869
 
12946
11870
  const myObject: MyType = {}
@@ -12954,7 +11878,7 @@ describe('R.propEq', () => {
12954
11878
 
12955
11879
  it('imported from @types/ramda', () => {
12956
11880
  interface A {
12957
- foo: string | null,
11881
+ foo: string | null
12958
11882
  }
12959
11883
  const obj: A = {
12960
11884
  foo: 'bar',
@@ -13067,16 +11991,16 @@ export const propIs = curry(propIsFn)
13067
11991
  ```javascript
13068
11992
  import {propIs} from './propIs'
13069
11993
 
13070
- const obj = {value: 1}
13071
- const property = 'value'
11994
+ const obj = {a: 1, b: 'foo'}
13072
11995
 
13073
11996
  test('when true', () => {
13074
- expect(propIs(Number, property, obj)).toBeTrue()
11997
+ expect(propIs(Number, 'a', obj)).toBeTrue()
11998
+ expect(propIs(String, 'b', obj)).toBeTrue()
13075
11999
  })
13076
12000
 
13077
12001
  test('when false', () => {
13078
- expect(propIs(String, property, obj)).toBeFalse()
13079
- expect(propIs(String, property, {})).toBeFalse()
12002
+ expect(propIs(String, 'a', obj)).toBeFalse()
12003
+ expect(propIs(Number, 'b', obj)).toBeFalse()
13080
12004
  })
13081
12005
  ```
13082
12006
 
@@ -14331,7 +13255,7 @@ describe('R.slice', () => {
14331
13255
  sort<T>(sortFn: (a: T, b: T) => number, list: T[]): T[]
14332
13256
  ```
14333
13257
 
14334
- It returns copy of `list` sorted by `sortFn` function.
13258
+ It returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to return only `-1`, `0` or `1`.
14335
13259
 
14336
13260
  <details>
14337
13261
 
@@ -14452,7 +13376,7 @@ const replace = [
14452
13376
  sortBy<T>(sortFn: (a: T) => Ord, list: T[]): T[]
14453
13377
  ```
14454
13378
 
14455
- It returns copy of `list` sorted by `sortFn` function.
13379
+ It returns copy of `list` sorted by `sortFn` function, where `sortFn` function returns a value to compare, i.e. it doesn't need to return only `-1`, `0` or `1`.
14456
13380
 
14457
13381
  <details>
14458
13382
 
@@ -14539,7 +13463,7 @@ test('with compose', () => {
14539
13463
  import {sortBy, pipe} from 'rambda'
14540
13464
 
14541
13465
  interface Input {
14542
- a: number,
13466
+ a: number
14543
13467
  }
14544
13468
 
14545
13469
  describe('R.sortBy', () => {
@@ -14575,7 +13499,7 @@ describe('R.sortBy', () => {
14575
13499
  })
14576
13500
  it('with R.pipe', () => {
14577
13501
  interface Obj {
14578
- value: number,
13502
+ value: number
14579
13503
  }
14580
13504
  const fn = pipe(sortBy<Obj>(x => x.value))
14581
13505
 
@@ -16905,20 +15829,20 @@ describe('R.tryCatch', () => {
16905
15829
  result // $ExpectType string
16906
15830
  })
16907
15831
 
16908
- it('asynchronous', async() => {
16909
- const fn = async(input: any) => {
15832
+ it('asynchronous', async () => {
15833
+ const fn = async (input: any) => {
16910
15834
  return typeof JSON.parse('{a:')
16911
15835
  }
16912
15836
  const result = await tryCatch<string>(fn, 'fallback')(100)
16913
15837
  result // $ExpectType string
16914
15838
  })
16915
15839
 
16916
- it('asynchronous + fallback is asynchronous', async() => {
16917
- const fn = async(input: any) => {
15840
+ it('asynchronous + fallback is asynchronous', async () => {
15841
+ const fn = async (input: any) => {
16918
15842
  await delay(100)
16919
15843
  return JSON.parse(`{a:${input}`)
16920
15844
  }
16921
- const fallback = async(input: any) => {
15845
+ const fallback = async (input: any) => {
16922
15846
  await delay(100)
16923
15847
  return 'foo'
16924
15848
  }
@@ -18179,7 +17103,7 @@ test('happy', () => {
18179
17103
  import {lens, view, assoc} from 'rambda'
18180
17104
 
18181
17105
  interface Input {
18182
- foo: string,
17106
+ foo: string
18183
17107
  }
18184
17108
 
18185
17109
  const testObject: Input = {
@@ -19106,6 +18030,18 @@ describe('R.zipWith', () => {
19106
18030
 
19107
18031
  ## ❯ CHANGELOG
19108
18032
 
18033
+ WIP 7.1.0
18034
+
18035
+ - Replace `Async` with `Promise` as return type of `R.type`.
18036
+
18037
+ 7.0.2
18038
+
18039
+ Rambda doesn't work with `pnpm` due to wrong export configuration - [Issue #619](https://github.com/selfrefactor/rambda/issues/619)
18040
+
18041
+ 7.0.1
18042
+
18043
+ - Wrong ESM export configuration in `package.json` - [Issue #614](https://github.com/selfrefactor/rambda/issues/614)
18044
+
19109
18045
  7.0.0
19110
18046
 
19111
18047
  - Braking 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.