rambda 10.3.1 → 10.3.3

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 CHANGED
@@ -1,6 +1,16 @@
1
+ 10.3.3
2
+
3
+ - Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
4
+
5
+ - Improve `R.pick` to not allow non-existing keys as input.
6
+
7
+ 10.3.2
8
+
9
+ - Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
10
+
1
11
  10.3.1
2
12
 
3
- - Fix issue with wrong order of inputs in `R.propOr` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
13
+ - Fix issue with wrong order of inputs in `R.propEq` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
4
14
 
5
15
  - Fix issue with TypeScript definitions for `R.includes`- [Issue #781](https://github.com/selfrefactor/rambda/issues/781)
6
16
 
@@ -8,16 +18,12 @@
8
18
 
9
19
  - Add `R.mapPropObject`
10
20
 
11
- - Add `R.duplicateBy`
12
21
  - Add `R.duplicateBy`
13
22
 
14
- - Add `R.filterAsync`
15
23
  - Add `R.filterAsync`
16
24
 
17
- - Add `R.indexBy`
18
25
  - Add `R.indexBy`
19
26
 
20
- - Restore `R.replaceAll`
21
27
  - Restore `R.replaceAll`
22
28
 
23
29
  - Remove option for `R.mapAsync` to be called outside of `R.pipeAsync`. This is done for consistency as all other methods follow this rule, i.e. they are all curried.
package/README.md CHANGED
@@ -834,13 +834,11 @@ append<T>(el: T): (list: T[]) => T[]
834
834
  It adds element `x` at the end of `iterable`.
835
835
 
836
836
  ```javascript
837
- const x = 'foo'
838
-
839
- const result = R.append(x, ['bar', 'baz'])
837
+ const result = R.append('foo')(['bar', 'baz'])
840
838
  // => ['bar', 'baz', 'foo']
841
839
  ```
842
840
 
843
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20x%20%3D%20'foo'%0A%0Aconst%20result%20%3D%20R.append(x%2C%20%5B'bar'%2C%20'baz'%5D)%0A%2F%2F%20%3D%3E%20%5B'bar'%2C%20'baz'%2C%20'foo'%5D">Try this <strong>R.append</strong> example in Rambda REPL</a>
841
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.append('foo')(%5B'bar'%2C%20'baz'%5D)%0A%2F%2F%20%3D%3E%20%5B'bar'%2C%20'baz'%2C%20'foo'%5D">Try this <strong>R.append</strong> example in Rambda REPL</a>
844
842
 
845
843
  <details>
846
844
 
@@ -1805,8 +1803,8 @@ createObjectFromKeys<const K extends readonly PropertyKey[], V>(
1805
1803
  <summary><strong>R.createObjectFromKeys</strong> source</summary>
1806
1804
 
1807
1805
  ```javascript
1808
- export function createObjectFromKeys(keys) {
1809
- return fn => {
1806
+ export function createObjectFromKeys(fn) {
1807
+ return keys => {
1810
1808
  const result = {}
1811
1809
  keys.forEach((key, index) => {
1812
1810
  result[key] = fn(key, index)
@@ -1827,7 +1825,7 @@ export function createObjectFromKeys(keys) {
1827
1825
  import { createObjectFromKeys } from './createObjectFromKeys.js'
1828
1826
 
1829
1827
  test('happy', () => {
1830
- const result = createObjectFromKeys(['a', 'b'])((key, index) => key.toUpperCase() + index)
1828
+ const result = createObjectFromKeys((key, index) => key.toUpperCase() + index)(['a', 'b'])
1831
1829
  const expected = { a: 'A0', b: 'B1' }
1832
1830
 
1833
1831
  expect(result).toEqual(expected)
@@ -3117,14 +3115,14 @@ const input = {
3117
3115
  }
3118
3116
  const result = R.pipe(
3119
3117
  input,
3120
- evolve({
3118
+ R.evolve({
3121
3119
  foo: x => x + 1,
3122
3120
  })
3123
3121
  )
3124
3122
  // => result is { foo: 3, baz: 'baz' }
3125
3123
  ```
3126
3124
 
3127
- <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20input%20%3D%20%7B%0A%09foo%3A%202%2C%0A%09baz%3A%20'baz'%2C%0A%7D%0Aconst%20result%20%3D%20R.pipe(%0A%09input%2C%0A%09evolve(%7B%0A%09%09foo%3A%20x%20%3D%3E%20x%20%2B%201%2C%0A%09%7D)%0A)%0A%2F%2F%20%3D%3E%20result%20is%20%7B%20foo%3A%203%2C%20baz%3A%20'baz'%20%7D">Try this <strong>R.evolve</strong> example in Rambda REPL</a>
3125
+ <a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20input%20%3D%20%7B%0A%09foo%3A%202%2C%0A%09baz%3A%20'baz'%2C%0A%7D%0Aconst%20result%20%3D%20R.pipe(%0A%09input%2C%0A%09R.evolve(%7B%0A%09%09foo%3A%20x%20%3D%3E%20x%20%2B%201%2C%0A%09%7D)%0A)%0A%2F%2F%20%3D%3E%20result%20is%20%7B%20foo%3A%203%2C%20baz%3A%20'baz'%20%7D">Try this <strong>R.evolve</strong> example in Rambda REPL</a>
3128
3126
 
3129
3127
  <details>
3130
3128
 
@@ -5887,13 +5885,13 @@ describe('R.lastIndexOf', () => {
5887
5885
  ```typescript
5888
5886
 
5889
5887
  map<T extends IterableContainer, U>(
5890
- fn: (value: T[number], index: number) => U,
5888
+ fn: (value: T[number], index: number) => U,
5891
5889
  ): (data: T) => Mapped<T, U>
5892
5890
  ```
5893
5891
 
5894
5892
  It returns the result of looping through `iterable` with `fn`.
5895
5893
 
5896
- It works with both array and object.
5894
+ > :boom: This function doesn't work with objects (use R.mapObject instead)
5897
5895
 
5898
5896
  ```javascript
5899
5897
  const fn = x => x * 2
@@ -5913,21 +5911,11 @@ const result = R.map(fn)(iterable),
5913
5911
 
5914
5912
  ```typescript
5915
5913
  map<T extends IterableContainer, U>(
5916
- fn: (value: T[number], index: number) => U,
5914
+ fn: (value: T[number], index: number) => U,
5917
5915
  ): (data: T) => Mapped<T, U>;
5918
5916
  map<T extends IterableContainer, U>(
5919
- fn: (value: T[number]) => U,
5917
+ fn: (value: T[number]) => U,
5920
5918
  ): (data: T) => Mapped<T, U>;
5921
- map<T extends IterableContainer, U>(
5922
- fn: (value: T[number], index: number) => U,
5923
- data: T
5924
- ) : Mapped<T, U>;
5925
- map<T extends IterableContainer, U>(
5926
- fn: (value: T[number]) => U,
5927
- data: T
5928
- ) : Mapped<T, U>;
5929
- ...
5930
- ...
5931
5919
  ```
5932
5920
 
5933
5921
  </details>
@@ -5981,7 +5969,7 @@ import { map, pipe } from 'rambda'
5981
5969
 
5982
5970
  const list = [1, 2, 3]
5983
5971
 
5984
- it('R.map', () => {
5972
+ it('R.map - within pipe', () => {
5985
5973
  const result = pipe(
5986
5974
  list,
5987
5975
  x => x,
@@ -5992,6 +5980,20 @@ it('R.map', () => {
5992
5980
  )
5993
5981
  result // $ExpectType string[]
5994
5982
  })
5983
+
5984
+ it('R.map - without pipe', () => {
5985
+ map(x => {
5986
+ x // $ExpectType unknown
5987
+ })([1, 2, 3])
5988
+ })
5989
+
5990
+ it('R.map - without pipe but explicitly typed', () => {
5991
+ const result = map<number[], string>(x => {
5992
+ x // $ExpectType number
5993
+ return String(x)
5994
+ })([1, 2, 3])
5995
+ result // $ExpectType string[]
5996
+ })
5995
5997
  ```
5996
5998
 
5997
5999
  </details>
@@ -8437,7 +8439,7 @@ export function permutations(inputArray) {
8437
8439
 
8438
8440
  ```typescript
8439
8441
 
8440
- pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>
8442
+ pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>
8441
8443
  ```
8442
8444
 
8443
8445
  It returns a partial copy of an `input` containing only `propsToPick` properties.
@@ -8480,8 +8482,8 @@ const expected = [
8480
8482
  <summary>All TypeScript definitions</summary>
8481
8483
 
8482
8484
  ```typescript
8483
- pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
8484
- pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
8485
+ pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
8486
+ pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
8485
8487
  ```
8486
8488
 
8487
8489
  </details>
@@ -8569,15 +8571,19 @@ const input = { a: 'foo', c: 3 }
8569
8571
 
8570
8572
  describe('R.pick', () => {
8571
8573
  it('with string as input', () => {
8572
- const result = pipe(input, pick('a,c,b,o'))
8574
+ const result = pipe(input, pick('a,c'))
8573
8575
  result.a // $ExpectType string
8574
8576
  result.c // $ExpectType number
8575
8577
  })
8576
8578
  it('with array as input', () => {
8577
- const result = pipe(input, pick(['a', 'c']))
8579
+ const result = pipe(input, pick(['a', 'c']))
8578
8580
  result.a // $ExpectType string
8579
8581
  result.c // $ExpectType number
8580
8582
  })
8583
+ it('throws error if some keys do not exist', () => {
8584
+ // @ts-expect-error
8585
+ pipe(input, pick('a,c,b,o'))
8586
+ })
8581
8587
  })
8582
8588
  ```
8583
8589
 
@@ -9792,9 +9798,8 @@ it('R.reduce', () => {
9792
9798
  ```typescript
9793
9799
 
9794
9800
  reject<T>(
9795
- predicate: (value: T) => boolean,
9796
- list: T[],
9797
- ): T[]
9801
+ predicate: BooleanConstructor,
9802
+ ): (list: readonly T[]) => ("" | null | undefined | false | 0)[]
9798
9803
  ```
9799
9804
 
9800
9805
  It has the opposite effect of `R.filter`.
@@ -9818,10 +9823,6 @@ const result = [
9818
9823
  <summary>All TypeScript definitions</summary>
9819
9824
 
9820
9825
  ```typescript
9821
- reject<T>(
9822
- predicate: (value: T) => boolean,
9823
- list: T[],
9824
- ): T[];
9825
9826
  reject<T>(
9826
9827
  predicate: BooleanConstructor,
9827
9828
  ): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
@@ -9831,8 +9832,6 @@ reject<T>(
9831
9832
  reject<T>(
9832
9833
  predicate: (value: T) => boolean,
9833
9834
  ): (list: T[]) => T[];
9834
- ...
9835
- ...
9836
9835
  ```
9837
9836
 
9838
9837
  </details>
@@ -13543,9 +13542,19 @@ describe('R.zipWith', () => {
13543
13542
 
13544
13543
  ## ❯ CHANGELOG
13545
13544
 
13545
+ 10.3.3
13546
+
13547
+ - Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
13548
+
13549
+ - Improve `R.pick` to not allow non-existing keys as input.
13550
+
13551
+ 10.3.2
13552
+
13553
+ - Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
13554
+
13546
13555
  10.3.1
13547
13556
 
13548
- - Fix issue with wrong order of inputs in `R.propOr` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
13557
+ - Fix issue with wrong order of inputs in `R.propEq` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)
13549
13558
 
13550
13559
  - Fix issue with TypeScript definitions for `R.includes`- [Issue #781](https://github.com/selfrefactor/rambda/issues/781)
13551
13560
 
@@ -13553,16 +13562,12 @@ describe('R.zipWith', () => {
13553
13562
 
13554
13563
  - Add `R.mapPropObject`
13555
13564
 
13556
- - Add `R.duplicateBy`
13557
13565
  - Add `R.duplicateBy`
13558
13566
 
13559
- - Add `R.filterAsync`
13560
13567
  - Add `R.filterAsync`
13561
13568
 
13562
- - Add `R.indexBy`
13563
13569
  - Add `R.indexBy`
13564
13570
 
13565
- - Restore `R.replaceAll`
13566
13571
  - Restore `R.replaceAll`
13567
13572
 
13568
13573
  - Remove option for `R.mapAsync` to be called outside of `R.pipeAsync`. This is done for consistency as all other methods follow this rule, i.e. they are all curried.
package/dist/rambda.cjs CHANGED
@@ -230,8 +230,8 @@ function countBy(fn) {
230
230
  }
231
231
  }
232
232
 
233
- function createObjectFromKeys(keys) {
234
- return fn => {
233
+ function createObjectFromKeys(fn) {
234
+ return keys => {
235
235
  const result = {};
236
236
  keys.forEach((key, index) => {
237
237
  result[key] = fn(key, index);
package/dist/rambda.js CHANGED
@@ -228,8 +228,8 @@ function countBy(fn) {
228
228
  }
229
229
  }
230
230
 
231
- function createObjectFromKeys(keys) {
232
- return fn => {
231
+ function createObjectFromKeys(fn) {
232
+ return keys => {
233
233
  const result = {};
234
234
  keys.forEach((key, index) => {
235
235
  result[key] = fn(key, index);
@@ -234,8 +234,8 @@
234
234
  }
235
235
  }
236
236
 
237
- function createObjectFromKeys(keys) {
238
- return fn => {
237
+ function createObjectFromKeys(fn) {
238
+ return keys => {
239
239
  const result = {};
240
240
  keys.forEach((key, index) => {
241
241
  result[key] = fn(key, index);
package/index.d.cts CHANGED
@@ -506,23 +506,13 @@ export function lastIndexOf<T>(target: T): (list: T[]) => number;
506
506
 
507
507
  /**
508
508
  * It returns the result of looping through `iterable` with `fn`.
509
- *
510
- * It works with both array and object.
511
509
  */
512
510
  export function map<T extends IterableContainer, U>(
513
- fn: (value: T[number], index: number) => U,
511
+ fn: (value: T[number], index: number) => U,
514
512
  ): (data: T) => Mapped<T, U>;
515
513
  export function map<T extends IterableContainer, U>(
516
- fn: (value: T[number]) => U,
514
+ fn: (value: T[number]) => U,
517
515
  ): (data: T) => Mapped<T, U>;
518
- export function map<T extends IterableContainer, U>(
519
- fn: (value: T[number], index: number) => U,
520
- data: T
521
- ) : Mapped<T, U>;
522
- export function map<T extends IterableContainer, U>(
523
- fn: (value: T[number]) => U,
524
- data: T
525
- ) : Mapped<T, U>;
526
516
 
527
517
  /**
528
518
  * Sequential asynchronous mapping with `fn` over members of `list`.
@@ -1233,8 +1223,8 @@ export function permutations<T>(list: T[]): T[][];
1233
1223
  *
1234
1224
  * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1235
1225
  */
1236
- export function pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
1237
- export function pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
1226
+ export function pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
1227
+ export function pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
1238
1228
 
1239
1229
  /**
1240
1230
  * It performs left-to-right function composition, where first argument is the input for the chain of functions.
@@ -1791,10 +1781,6 @@ export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: numbe
1791
1781
  /**
1792
1782
  * It has the opposite effect of `R.filter`.
1793
1783
  */
1794
- export function reject<T>(
1795
- predicate: (value: T) => boolean,
1796
- list: T[],
1797
- ): T[];
1798
1784
  export function reject<T>(
1799
1785
  predicate: BooleanConstructor,
1800
1786
  ): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
package/index.d.ts CHANGED
@@ -506,23 +506,13 @@ export function lastIndexOf<T>(target: T): (list: T[]) => number;
506
506
 
507
507
  /**
508
508
  * It returns the result of looping through `iterable` with `fn`.
509
- *
510
- * It works with both array and object.
511
509
  */
512
510
  export function map<T extends IterableContainer, U>(
513
- fn: (value: T[number], index: number) => U,
511
+ fn: (value: T[number], index: number) => U,
514
512
  ): (data: T) => Mapped<T, U>;
515
513
  export function map<T extends IterableContainer, U>(
516
- fn: (value: T[number]) => U,
514
+ fn: (value: T[number]) => U,
517
515
  ): (data: T) => Mapped<T, U>;
518
- export function map<T extends IterableContainer, U>(
519
- fn: (value: T[number], index: number) => U,
520
- data: T
521
- ) : Mapped<T, U>;
522
- export function map<T extends IterableContainer, U>(
523
- fn: (value: T[number]) => U,
524
- data: T
525
- ) : Mapped<T, U>;
526
516
 
527
517
  /**
528
518
  * Sequential asynchronous mapping with `fn` over members of `list`.
@@ -1233,8 +1223,8 @@ export function permutations<T>(list: T[]): T[][];
1233
1223
  *
1234
1224
  * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1235
1225
  */
1236
- export function pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
1237
- export function pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
1226
+ export function pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
1227
+ export function pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
1238
1228
 
1239
1229
  /**
1240
1230
  * It performs left-to-right function composition, where first argument is the input for the chain of functions.
@@ -1791,10 +1781,6 @@ export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: numbe
1791
1781
  /**
1792
1782
  * It has the opposite effect of `R.filter`.
1793
1783
  */
1794
- export function reject<T>(
1795
- predicate: (value: T) => boolean,
1796
- list: T[],
1797
- ): T[];
1798
1784
  export function reject<T>(
1799
1785
  predicate: BooleanConstructor,
1800
1786
  ): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "10.3.1",
3
+ "version": "10.3.3",
4
4
  "scripts": {
5
5
  "out": "yarn populatedocs && yarn populatereadme && yarn build && yarn create-docsify",
6
6
  "build": "yarn build:main && yarn build:web && yarn build:esm",
@@ -40,18 +40,18 @@
40
40
  "devDependencies": {
41
41
  "@definitelytyped/dtslint": "0.0.182",
42
42
  "@types/mocha": "10.0.10",
43
- "@types/node": "24.0.8",
44
- "@vitest/coverage-v8": "4.0.0-beta.2",
43
+ "@types/node": "24.7.0",
44
+ "@vitest/coverage-v8": "4.0.0-beta.17",
45
45
  "helpers-fn": "2.0.0",
46
46
  "lodash": "4.17.21",
47
47
  "radashi": "13.0.0-beta.ffa4778",
48
48
  "rambdax": "11.3.1",
49
49
  "ramda": "0.31.3",
50
- "remeda": "2.23.2",
51
- "rollup": "4.44.1",
52
- "types-ramda": "0.30.1",
53
- "typescript": "5.9.0-dev.20250630",
54
- "vitest": "4.0.0-beta.2"
50
+ "remeda": "2.32.0",
51
+ "rollup": "4.52.4",
52
+ "types-ramda": "0.31.0",
53
+ "typescript": "6.0.0-dev.20251006",
54
+ "vitest": "4.0.0-beta.17"
55
55
  },
56
56
  "jest": {
57
57
  "testEnvironment": "node",
@@ -1,5 +1,5 @@
1
- export function createObjectFromKeys(keys) {
2
- return fn => {
1
+ export function createObjectFromKeys(fn) {
2
+ return keys => {
3
3
  const result = {}
4
4
  keys.forEach((key, index) => {
5
5
  result[key] = fn(key, index)