rambda 10.3.2 → 10.3.4

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/dist/rambda.cjs CHANGED
@@ -1044,8 +1044,18 @@ function mapObjectAsync(fn) {
1044
1044
  }
1045
1045
  }
1046
1046
 
1047
- function mapParallelAsync(fn) {
1048
- return async list => Promise.all(list.map((x, i) => fn(x, i)))
1047
+ function mapParallelAsync(fn, batchSize){
1048
+ if(!batchSize) return async list => Promise.all(list.map(fn))
1049
+
1050
+ return async list => {
1051
+ const result = [];
1052
+ for(let i = 0; i < list.length; i += batchSize){
1053
+ const batch = list.slice(i, i + batchSize);
1054
+ const batchResult = await Promise.all(batch.map((x, j) => fn(x, i + j)));
1055
+ result.push(...batchResult);
1056
+ }
1057
+ return result
1058
+ }
1049
1059
  }
1050
1060
 
1051
1061
  function mapPropObject(fn, prop) {
package/dist/rambda.js CHANGED
@@ -1042,8 +1042,18 @@ function mapObjectAsync(fn) {
1042
1042
  }
1043
1043
  }
1044
1044
 
1045
- function mapParallelAsync(fn) {
1046
- return async list => Promise.all(list.map((x, i) => fn(x, i)))
1045
+ function mapParallelAsync(fn, batchSize){
1046
+ if(!batchSize) return async list => Promise.all(list.map(fn))
1047
+
1048
+ return async list => {
1049
+ const result = [];
1050
+ for(let i = 0; i < list.length; i += batchSize){
1051
+ const batch = list.slice(i, i + batchSize);
1052
+ const batchResult = await Promise.all(batch.map((x, j) => fn(x, i + j)));
1053
+ result.push(...batchResult);
1054
+ }
1055
+ return result
1056
+ }
1047
1057
  }
1048
1058
 
1049
1059
  function mapPropObject(fn, prop) {
@@ -1048,8 +1048,18 @@
1048
1048
  }
1049
1049
  }
1050
1050
 
1051
- function mapParallelAsync(fn) {
1052
- return async list => Promise.all(list.map((x, i) => fn(x, i)))
1051
+ function mapParallelAsync(fn, batchSize){
1052
+ if(!batchSize) return async list => Promise.all(list.map(fn))
1053
+
1054
+ return async list => {
1055
+ const result = [];
1056
+ for(let i = 0; i < list.length; i += batchSize){
1057
+ const batch = list.slice(i, i + batchSize);
1058
+ const batchResult = await Promise.all(batch.map((x, j) => fn(x, i + j)));
1059
+ result.push(...batchResult);
1060
+ }
1061
+ return result
1062
+ }
1053
1063
  }
1054
1064
 
1055
1065
  function mapPropObject(fn, prop) {
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`.
@@ -557,23 +547,30 @@ export function mapObjectAsync<T extends object, Value>(
557
547
 
558
548
  /**
559
549
  * Wrapper around `Promise.all` for asynchronous mapping with `fn` over members of `list`.
550
+ * There is optional `batchSize` parameter to allow parallel execution to run in batches. In this case, the whole batch must complete before the next batch starts.
560
551
  */
561
- export function mapParallelAsync<T extends IterableContainer, U>(
562
- fn: (value: T[number], index: number) => Promise<U>,
563
- ): (data: T) => Promise<Mapped<T, U>>;
564
552
  export function mapParallelAsync<T extends IterableContainer, U>(
565
553
  fn: (value: T[number]) => Promise<U>,
554
+ batchSize?: number,
566
555
  ): (data: T) => Promise<Mapped<T, U>>;
567
556
 
568
557
  /**
569
- * It maps over a property of object that is a list.
558
+ * Convenience method, when one needs to maps over a object property that is a list.
570
559
  */
571
- export function mapPropObject<T extends object, K extends keyof T, Value>(
560
+ export function mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
561
+ prop: K,
562
+ valueMapper: (
563
+ listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
564
+ list: T[K] extends ReadonlyArray<any> ? T[K] : never,
565
+ ) => Value,
566
+ ): (data: T) => T[K] extends ReadonlyArray<any>
567
+ ? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
568
+ : never;
569
+ export function mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
570
+ prop: K,
572
571
  valueMapper: (
573
- value: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
574
- data: T[K],
572
+ listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
575
573
  ) => Value,
576
- prop: K,
577
574
  ): (data: T) => T[K] extends ReadonlyArray<any>
578
575
  ? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
579
576
  : never;
@@ -1233,8 +1230,8 @@ export function permutations<T>(list: T[]): T[][];
1233
1230
  *
1234
1231
  * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1235
1232
  */
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>>>>>>;
1233
+ 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>>;
1234
+ 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
1235
 
1239
1236
  /**
1240
1237
  * It performs left-to-right function composition, where first argument is the input for the chain of functions.
@@ -1791,10 +1788,6 @@ export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: numbe
1791
1788
  /**
1792
1789
  * It has the opposite effect of `R.filter`.
1793
1790
  */
1794
- export function reject<T>(
1795
- predicate: (value: T) => boolean,
1796
- list: T[],
1797
- ): T[];
1798
1791
  export function reject<T>(
1799
1792
  predicate: BooleanConstructor,
1800
1793
  ): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
@@ -1841,7 +1834,7 @@ export function sort<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1841
1834
  */
1842
1835
  export function sortBy<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
1843
1836
 
1844
- export function sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1837
+ export function sortByDescending<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
1845
1838
 
1846
1839
  /**
1847
1840
  * It sorts `list` by the value of `path` property.
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`.
@@ -557,23 +547,30 @@ export function mapObjectAsync<T extends object, Value>(
557
547
 
558
548
  /**
559
549
  * Wrapper around `Promise.all` for asynchronous mapping with `fn` over members of `list`.
550
+ * There is optional `batchSize` parameter to allow parallel execution to run in batches. In this case, the whole batch must complete before the next batch starts.
560
551
  */
561
- export function mapParallelAsync<T extends IterableContainer, U>(
562
- fn: (value: T[number], index: number) => Promise<U>,
563
- ): (data: T) => Promise<Mapped<T, U>>;
564
552
  export function mapParallelAsync<T extends IterableContainer, U>(
565
553
  fn: (value: T[number]) => Promise<U>,
554
+ batchSize?: number,
566
555
  ): (data: T) => Promise<Mapped<T, U>>;
567
556
 
568
557
  /**
569
- * It maps over a property of object that is a list.
558
+ * Convenience method, when one needs to maps over a object property that is a list.
570
559
  */
571
- export function mapPropObject<T extends object, K extends keyof T, Value>(
560
+ export function mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
561
+ prop: K,
562
+ valueMapper: (
563
+ listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
564
+ list: T[K] extends ReadonlyArray<any> ? T[K] : never,
565
+ ) => Value,
566
+ ): (data: T) => T[K] extends ReadonlyArray<any>
567
+ ? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
568
+ : never;
569
+ export function mapPropObject<T extends object, K extends keyof T, Value extends unknown>(
570
+ prop: K,
572
571
  valueMapper: (
573
- value: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
574
- data: T[K],
572
+ listItem: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
575
573
  ) => Value,
576
- prop: K,
577
574
  ): (data: T) => T[K] extends ReadonlyArray<any>
578
575
  ? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
579
576
  : never;
@@ -1233,8 +1230,8 @@ export function permutations<T>(list: T[]): T[][];
1233
1230
  *
1234
1231
  * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1235
1232
  */
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>>>>>>;
1233
+ 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>>;
1234
+ 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
1235
 
1239
1236
  /**
1240
1237
  * It performs left-to-right function composition, where first argument is the input for the chain of functions.
@@ -1791,10 +1788,6 @@ export function reduce<T, TResult>(reducer: (prev: TResult, current: T, i: numbe
1791
1788
  /**
1792
1789
  * It has the opposite effect of `R.filter`.
1793
1790
  */
1794
- export function reject<T>(
1795
- predicate: (value: T) => boolean,
1796
- list: T[],
1797
- ): T[];
1798
1791
  export function reject<T>(
1799
1792
  predicate: BooleanConstructor,
1800
1793
  ): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
@@ -1841,7 +1834,7 @@ export function sort<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1841
1834
  */
1842
1835
  export function sortBy<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
1843
1836
 
1844
- export function sortByDescending<T>(sortFn: (a: T, b: T) => number): (list: T[]) => T[];
1837
+ export function sortByDescending<T>(sortFn: (x: T) => Ord): (list: T[]) => T[];
1845
1838
 
1846
1839
  /**
1847
1840
  * It sorts `list` by the value of `path` property.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "10.3.2",
3
+ "version": "10.3.4",
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",
@@ -16,7 +16,8 @@
16
16
  "test": "vitest run --watch -u",
17
17
  "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
18
18
  "create-docsify": "cd ../rambda-scripts && yarn create-docsify",
19
- "deps": "run dep:next",
19
+ "deps": "run dep:next 10",
20
+ "x": "run dep:stable 10",
20
21
  "ts": "yarn test:typings"
21
22
  },
22
23
  "niketaScripts": {
@@ -40,18 +41,18 @@
40
41
  "devDependencies": {
41
42
  "@definitelytyped/dtslint": "0.0.182",
42
43
  "@types/mocha": "10.0.10",
43
- "@types/node": "24.0.8",
44
- "@vitest/coverage-v8": "4.0.0-beta.2",
44
+ "@types/node": "24.10.1",
45
+ "@vitest/coverage-v8": "4.0.10",
45
46
  "helpers-fn": "2.0.0",
46
47
  "lodash": "4.17.21",
47
48
  "radashi": "13.0.0-beta.ffa4778",
48
49
  "rambdax": "11.3.1",
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
+ "ramda": "0.32.0",
51
+ "remeda": "2.32.0",
52
+ "rollup": "4.53.3",
53
+ "types-ramda": "0.31.0",
54
+ "typescript": "6.0.0-dev.20251119",
55
+ "vitest": "4.0.10"
55
56
  },
56
57
  "jest": {
57
58
  "testEnvironment": "node",
@@ -1,3 +1,13 @@
1
- export function mapParallelAsync(fn) {
2
- return async list => Promise.all(list.map((x, i) => fn(x, i)))
1
+ export function mapParallelAsync(fn, batchSize){
2
+ if(!batchSize) return async list => Promise.all(list.map(fn))
3
+
4
+ return async list => {
5
+ const result = []
6
+ for(let i = 0; i < list.length; i += batchSize){
7
+ const batch = list.slice(i, i + batchSize)
8
+ const batchResult = await Promise.all(batch.map((x, j) => fn(x, i + j)))
9
+ result.push(...batchResult)
10
+ }
11
+ return result
12
+ }
3
13
  }