rambda 7.1.3 → 7.2.1

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/immutable.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type RambdaTypes = "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "NaN" | "Function" | "Undefined" | "Async" | "Promise" | "Symbol" | "Set" | "Error" | "Map" | "WeakMap" | "Generator" | "GeneratorFunction" | "BigInt" | "ArrayBuffer";
2
2
 
3
+ // used in R.reduce to stop the loop
4
+ export function reduceStopper<T>(input: T) : T
3
5
  export type IndexedIterator<T, U> = (x: T, i: number) => U;
4
6
  export type Iterator<T, U> = (x: T) => U;
5
7
  export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U;
@@ -30,7 +32,6 @@ type Arity1Fn = (x: any) => any;
30
32
  type Arity2Fn = (x: any, y: any) => any;
31
33
 
32
34
  type Pred = (...x: readonly any[]) => boolean;
33
- type SafePred<T> = (...x: readonly T[]) => boolean;
34
35
 
35
36
  export interface Dictionary<T> {readonly [index: string]: T}
36
37
  type Partial<T> = { readonly [P in keyof T]?: T[P]};
@@ -72,6 +73,9 @@ interface AssocPartialOne<K extends keyof any> {
72
73
  <T, U>(val: T, obj: U): Record<K, T> & U;
73
74
  }
74
75
 
76
+ type AnyFunction = (...args: readonly any[]) => unknown;
77
+ type AnyConstructor = new (...args: readonly any[]) => unknown;
78
+
75
79
  // RAMBDAX INTERFACES
76
80
  // ============================================
77
81
  type Func<T> = (input: any) => T;
@@ -179,7 +183,7 @@ export function any<T>(predicate: (x: T) => boolean): (list: readonly T[]) => bo
179
183
  /**
180
184
  * It accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`.
181
185
  */
182
- export function anyPass<T>(predicates: readonly SafePred<T>[]): SafePred<T>;
186
+ export function anyPass<T>(predicates: readonly ((x: T) => boolean)[]): (input: T) => boolean;
183
187
 
184
188
  /**
185
189
  * It adds element `x` at the end of `list`.
@@ -187,12 +191,12 @@ export function anyPass<T>(predicates: readonly SafePred<T>[]): SafePred<T>;
187
191
  export function append<T>(x: T, list: readonly T[]): readonly T[];
188
192
  export function append<T>(x: T): <T>(list: readonly T[]) => readonly T[];
189
193
 
190
- export function applySpec<Spec extends Record<string, (...args: readonly any[]) => any>>(
194
+ export function applySpec<Spec extends Record<string, AnyFunction>>(
191
195
  spec: Spec
192
196
  ): (
193
197
  ...args: Parameters<ValueOfRecord<Spec>>
194
198
  ) => { readonly [Key in keyof Spec]: ReturnType<Spec[Key]> };
195
- export function applySpec<T>(spec: any): (...args: readonly any[]) => T;
199
+ export function applySpec<T>(spec: any): (...args: readonly unknown[]) => T;
196
200
 
197
201
  /**
198
202
  * It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.
@@ -342,12 +346,12 @@ export function converge(after: ((...a: readonly any[]) => any), fns: readonly (
342
346
  /**
343
347
  * It expects a function as input and returns its curried version.
344
348
  */
345
- export function curry(fn: (...args: readonly any[]) => any): (...a: readonly any[]) => any;
349
+ export function curry(fn: AnyFunction): (...a: readonly any[]) => any;
346
350
 
347
351
  /**
348
352
  * It returns a curried equivalent of the provided function, with the specified arity.
349
353
  */
350
- export function curryN(length: number, fn: (...args: readonly any[]) => any): (...a: readonly any[]) => any;
354
+ export function curryN(length: number, fn: AnyFunction): (...a: readonly any[]) => any;
351
355
 
352
356
  /**
353
357
  * It decrements a number.
@@ -547,6 +551,11 @@ export function identity<T>(input: T): T;
547
551
  *
548
552
  * When `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation.
549
553
  */
554
+ export function ifElse<T, TFiltered extends T, TOnTrueResult, TOnFalseResult>(
555
+ pred: (a: T) => a is TFiltered,
556
+ onTrue: (a: TFiltered) => TOnTrueResult,
557
+ onFalse: (a: Exclude<T, TFiltered>) => TOnFalseResult,
558
+ ): (a: T) => TOnTrueResult | TOnFalseResult;
550
559
  export function ifElse<TArgs extends readonly any[], TOnTrueResult, TOnFalseResult>(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult;
551
560
 
552
561
  /**
@@ -862,7 +871,7 @@ export function objOf<K extends string>(key: K): <T>(value: T) => Record<K, T>;
862
871
  /**
863
872
  * It returns a function, which invokes only once `fn` function.
864
873
  */
865
- export function once<T extends (...args: readonly any[]) => any>(func: T): T;
874
+ export function once<T extends AnyFunction>(func: T): T;
866
875
 
867
876
  /**
868
877
  * It returns a partial copy of an `obj` without `propsToOmit` properties.
@@ -1064,18 +1073,14 @@ export function propEq<K extends string | number>(propToFind: K): {
1064
1073
  /**
1065
1074
  * It returns `true` if `property` of `obj` is from `target` type.
1066
1075
  */
1067
- export function propIs<C extends (...args: readonly any[]) => any, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>;
1068
- export function propIs<C extends new (...args: readonly any[]) => any, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, InstanceType<C>>;
1069
- export function propIs<C extends (...args: readonly any[]) => any, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1070
- export function propIs<C extends new (...args: readonly any[]) => any, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1071
- export function propIs<C extends (...args: readonly any[]) => any>(type: C): {
1076
+ export function propIs<C extends AnyFunction, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>;
1077
+ export function propIs<C extends AnyConstructor, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, InstanceType<C>>;
1078
+ export function propIs<C extends AnyFunction, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1079
+ export function propIs<C extends AnyConstructor, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1080
+ export function propIs<C extends AnyFunction>(type: C): {
1072
1081
  <K extends keyof any>(name: K, obj: any): obj is Record<K, ReturnType<C>>;
1073
1082
  <K extends keyof any>(name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1074
1083
  };
1075
- export function propIs<C extends new (...args: readonly any[]) => any>(type: C): {
1076
- <K extends keyof any>(name: K, obj: any): obj is Record<K, InstanceType<C>>;
1077
- <K extends keyof any>(name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1078
- };
1079
1084
 
1080
1085
  /**
1081
1086
  * It returns either `defaultValue` or the value of `property` in `obj`.
@@ -1472,15 +1477,15 @@ export function apply<T = any>(fn: (...args: readonly any[]) => T): (args: reado
1472
1477
  /**
1473
1478
  * Creates a function that is bound to a context.
1474
1479
  */
1475
- export function bind<F extends (...args: readonly any[]) => any, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
1476
- export function bind<F extends (...args: readonly any[]) => any, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
1480
+ export function bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
1481
+ export function bind<F extends AnyFunction, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
1477
1482
 
1478
1483
  /**
1479
1484
  * It takes two objects and a function, which will be used when there is an overlap between the keys.
1480
1485
  */
1481
1486
  export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>, b: Record<string, unknown>): Record<string, unknown>;
1482
1487
  export function mergeWith<Output>(fn: (x: any, z: any) => any, a: Record<string, unknown>, b: Record<string, unknown>): Output;
1483
- export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Obj;
1488
+ export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Record<string, unknown>;
1484
1489
  export function mergeWith<Output>(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Output;
1485
1490
  export function mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => Record<string, unknown>;
1486
1491
  export function mergeWith<Output>(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => Output;
@@ -1539,3 +1544,13 @@ export function partialObject<Input, PartialInput, Output>(
1539
1544
  fn: (input: Input) => Output,
1540
1545
  partialInput: PartialInput,
1541
1546
  ): (input: Pick<Input, Exclude<keyof Input, keyof PartialInput>>) => Output;
1547
+
1548
+ export function uniqBy<T, U>(fn: (a: T) => U, list: readonly T[]): readonly T[];
1549
+ export function uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => readonly T[];
1550
+
1551
+ /**
1552
+ * It changes a property of object on the base of provided path and transformer function.
1553
+ */
1554
+ export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown, object: Record<string, unknown>): T;
1555
+ export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown): (object: Record<string, unknown>) => T;
1556
+ export function modifyPath<T extends Record<string, unknown>>(path: Path): (fn: (x: any) => unknown) => (object: Record<string, unknown>) => T;
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type RambdaTypes = "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "NaN" | "Function" | "Undefined" | "Async" | "Promise" | "Symbol" | "Set" | "Error" | "Map" | "WeakMap" | "Generator" | "GeneratorFunction" | "BigInt" | "ArrayBuffer";
2
2
 
3
+ // used in R.reduce to stop the loop
4
+ export function reduceStopper<T>(input: T) : T
3
5
  export type IndexedIterator<T, U> = (x: T, i: number) => U;
4
6
  export type Iterator<T, U> = (x: T) => U;
5
7
  export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U;
@@ -30,7 +32,6 @@ type Arity1Fn = (x: any) => any;
30
32
  type Arity2Fn = (x: any, y: any) => any;
31
33
 
32
34
  type Pred = (...x: any[]) => boolean;
33
- type SafePred<T> = (...x: T[]) => boolean;
34
35
 
35
36
  export interface Dictionary<T> {[index: string]: T}
36
37
  type Partial<T> = { [P in keyof T]?: T[P]};
@@ -72,6 +73,9 @@ interface AssocPartialOne<K extends keyof any> {
72
73
  <T, U>(val: T, obj: U): Record<K, T> & U;
73
74
  }
74
75
 
76
+ type AnyFunction = (...args: any[]) => unknown;
77
+ type AnyConstructor = new (...args: any[]) => unknown;
78
+
75
79
  // RAMBDAX INTERFACES
76
80
  // ============================================
77
81
  type Func<T> = (input: any) => T;
@@ -179,7 +183,7 @@ export function any<T>(predicate: (x: T) => boolean): (list: T[]) => boolean;
179
183
  /**
180
184
  * It accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`.
181
185
  */
182
- export function anyPass<T>(predicates: SafePred<T>[]): SafePred<T>;
186
+ export function anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
183
187
 
184
188
  /**
185
189
  * It adds element `x` at the end of `list`.
@@ -187,12 +191,12 @@ export function anyPass<T>(predicates: SafePred<T>[]): SafePred<T>;
187
191
  export function append<T>(x: T, list: T[]): T[];
188
192
  export function append<T>(x: T): <T>(list: T[]) => T[];
189
193
 
190
- export function applySpec<Spec extends Record<string, (...args: any[]) => any>>(
194
+ export function applySpec<Spec extends Record<string, AnyFunction>>(
191
195
  spec: Spec
192
196
  ): (
193
197
  ...args: Parameters<ValueOfRecord<Spec>>
194
198
  ) => { [Key in keyof Spec]: ReturnType<Spec[Key]> };
195
- export function applySpec<T>(spec: any): (...args: any[]) => T;
199
+ export function applySpec<T>(spec: any): (...args: unknown[]) => T;
196
200
 
197
201
  /**
198
202
  * It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.
@@ -342,12 +346,12 @@ export function converge(after: ((...a: any[]) => any), fns: ((...x: any[]) => a
342
346
  /**
343
347
  * It expects a function as input and returns its curried version.
344
348
  */
345
- export function curry(fn: (...args: any[]) => any): (...a: any[]) => any;
349
+ export function curry(fn: AnyFunction): (...a: any[]) => any;
346
350
 
347
351
  /**
348
352
  * It returns a curried equivalent of the provided function, with the specified arity.
349
353
  */
350
- export function curryN(length: number, fn: (...args: any[]) => any): (...a: any[]) => any;
354
+ export function curryN(length: number, fn: AnyFunction): (...a: any[]) => any;
351
355
 
352
356
  /**
353
357
  * It decrements a number.
@@ -547,6 +551,11 @@ export function identity<T>(input: T): T;
547
551
  *
548
552
  * When `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation.
549
553
  */
554
+ export function ifElse<T, TFiltered extends T, TOnTrueResult, TOnFalseResult>(
555
+ pred: (a: T) => a is TFiltered,
556
+ onTrue: (a: TFiltered) => TOnTrueResult,
557
+ onFalse: (a: Exclude<T, TFiltered>) => TOnFalseResult,
558
+ ): (a: T) => TOnTrueResult | TOnFalseResult;
550
559
  export function ifElse<TArgs extends any[], TOnTrueResult, TOnFalseResult>(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult;
551
560
 
552
561
  /**
@@ -862,7 +871,7 @@ export function objOf<K extends string>(key: K): <T>(value: T) => Record<K, T>;
862
871
  /**
863
872
  * It returns a function, which invokes only once `fn` function.
864
873
  */
865
- export function once<T extends (...args: any[]) => any>(func: T): T;
874
+ export function once<T extends AnyFunction>(func: T): T;
866
875
 
867
876
  /**
868
877
  * It returns a partial copy of an `obj` without `propsToOmit` properties.
@@ -1064,18 +1073,14 @@ export function propEq<K extends string | number>(propToFind: K): {
1064
1073
  /**
1065
1074
  * It returns `true` if `property` of `obj` is from `target` type.
1066
1075
  */
1067
- export function propIs<C extends (...args: any[]) => any, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>;
1068
- export function propIs<C extends new (...args: any[]) => any, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, InstanceType<C>>;
1069
- export function propIs<C extends (...args: any[]) => any, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1070
- export function propIs<C extends new (...args: any[]) => any, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1071
- export function propIs<C extends (...args: any[]) => any>(type: C): {
1076
+ export function propIs<C extends AnyFunction, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>;
1077
+ export function propIs<C extends AnyConstructor, K extends keyof any>(type: C, name: K, obj: any): obj is Record<K, InstanceType<C>>;
1078
+ export function propIs<C extends AnyFunction, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1079
+ export function propIs<C extends AnyConstructor, K extends keyof any>(type: C, name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1080
+ export function propIs<C extends AnyFunction>(type: C): {
1072
1081
  <K extends keyof any>(name: K, obj: any): obj is Record<K, ReturnType<C>>;
1073
1082
  <K extends keyof any>(name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
1074
1083
  };
1075
- export function propIs<C extends new (...args: any[]) => any>(type: C): {
1076
- <K extends keyof any>(name: K, obj: any): obj is Record<K, InstanceType<C>>;
1077
- <K extends keyof any>(name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
1078
- };
1079
1084
 
1080
1085
  /**
1081
1086
  * It returns either `defaultValue` or the value of `property` in `obj`.
@@ -1472,15 +1477,15 @@ export function apply<T = any>(fn: (...args: any[]) => T): (args: any[]) => T;
1472
1477
  /**
1473
1478
  * Creates a function that is bound to a context.
1474
1479
  */
1475
- export function bind<F extends (...args: any[]) => any, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
1476
- export function bind<F extends (...args: any[]) => any, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
1480
+ export function bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
1481
+ export function bind<F extends AnyFunction, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
1477
1482
 
1478
1483
  /**
1479
1484
  * It takes two objects and a function, which will be used when there is an overlap between the keys.
1480
1485
  */
1481
1486
  export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>, b: Record<string, unknown>): Record<string, unknown>;
1482
1487
  export function mergeWith<Output>(fn: (x: any, z: any) => any, a: Record<string, unknown>, b: Record<string, unknown>): Output;
1483
- export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Obj;
1488
+ export function mergeWith(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Record<string, unknown>;
1484
1489
  export function mergeWith<Output>(fn: (x: any, z: any) => any, a: Record<string, unknown>): (b: Record<string, unknown>) => Output;
1485
1490
  export function mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => Record<string, unknown>;
1486
1491
  export function mergeWith<Output>(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => Output;
@@ -1539,3 +1544,13 @@ export function partialObject<Input, PartialInput, Output>(
1539
1544
  fn: (input: Input) => Output,
1540
1545
  partialInput: PartialInput,
1541
1546
  ): (input: Pick<Input, Exclude<keyof Input, keyof PartialInput>>) => Output;
1547
+
1548
+ export function uniqBy<T, U>(fn: (a: T) => U, list: T[]): T[];
1549
+ export function uniqBy<T, U>(fn: (a: T) => U): (list: T[]) => T[];
1550
+
1551
+ /**
1552
+ * It changes a property of object on the base of provided path and transformer function.
1553
+ */
1554
+ export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown, object: Record<string, unknown>): T;
1555
+ export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown): (object: Record<string, unknown>) => T;
1556
+ export function modifyPath<T extends Record<string, unknown>>(path: Path): (fn: (x: any) => unknown) => (object: Record<string, unknown>) => T;
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "7.1.3",
3
+ "version": "7.2.1",
4
4
  "scripts": {
5
5
  "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
6
6
  "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
7
7
  "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
8
8
  "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
9
9
  "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
10
+ "pull": "cd ../rambda-scripts && git pull",
11
+ "outx": "yarn pull && yarn out",
10
12
  "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x",
11
13
  "github": "cd ../rambda-scripts && yarn github",
12
14
  "fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
@@ -20,7 +22,7 @@
20
22
  "build": "yarn build:main && yarn build:web",
21
23
  "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.js",
22
24
  "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.js",
23
- "docs": "npx docsify-cli init ./docs --yes && yarn fix-docsify",
25
+ "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
24
26
  "new": "cd ../rambda-scripts && yarn new",
25
27
  "test:all": "jest source -u --bail=false",
26
28
  "test": "jest -o --watch",
@@ -29,39 +31,41 @@
29
31
  "build:step": "yarn populatedocs && yarn populatereadme && yarn build:main",
30
32
  "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
31
33
  "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
32
- "benchmark:single": "cd ../rambda-scripts && METHOD=pipe RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
34
+ "benchmark:single": "cd ../rambda-scripts && METHOD=uniqWith RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
33
35
  "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
34
36
  "benchmark": "yarn build:step && yarn benchmark:single",
35
37
  "typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
38
+ "d:rambda-scripts": "cd ../rambda-scripts && run d",
39
+ "d": "yarn out && yarn lint && run d && yarn d:rambda-scripts",
36
40
  "fix": "mkdir $HOME/.dts/perf -p"
37
41
  },
38
42
  "dependencies": {},
39
43
  "devDependencies": {
40
- "@babel/core": "7.17.10",
41
- "@babel/plugin-proposal-object-rest-spread": "7.17.3",
42
- "@babel/preset-env": "7.17.10",
44
+ "@babel/core": "7.18.9",
45
+ "@babel/plugin-proposal-object-rest-spread": "7.18.9",
46
+ "@babel/preset-env": "7.18.9",
43
47
  "@rollup/plugin-babel": "5.3.1",
44
- "@rollup/plugin-commonjs": "22.0.0",
48
+ "@rollup/plugin-commonjs": "22.0.1",
45
49
  "@rollup/plugin-json": "4.1.0",
46
- "@rollup/plugin-node-resolve": "13.2.1",
50
+ "@rollup/plugin-node-resolve": "13.3.0",
47
51
  "@rollup/plugin-replace": "4.0.0",
48
- "@types/jest": "27.4.1",
49
- "@types/ramda": "0.28.11",
52
+ "@types/jest": "28.1.6",
53
+ "@types/ramda": "0.28.15",
50
54
  "combinate": "1.1.11",
51
55
  "cross-env": "7.0.3",
52
56
  "dtslint": "4.2.1",
53
57
  "helpers-fn": "1.6.0",
54
58
  "is-ci": "3.0.1",
55
- "jest": "28.0.3",
56
- "jest-extended": "2.0.0",
59
+ "jest": "28.1.3",
60
+ "jest-extended": "3.0.1",
57
61
  "lodash": "4.17.21",
58
62
  "rambdax": "8.0.1",
59
63
  "ramda": "0.28.0",
60
- "rollup": "2.70.2",
64
+ "rollup": "2.77.2",
61
65
  "rollup-plugin-cleanup": "3.2.1",
62
66
  "rollup-plugin-sourcemaps": "0.6.3",
63
67
  "rollup-plugin-uglify": "6.0.4",
64
- "typescript": "4.6.4"
68
+ "typescript": "4.7.4"
65
69
  },
66
70
  "jest": {
67
71
  "testEnvironment": "node",
package/src/map.js CHANGED
@@ -17,6 +17,9 @@ export function mapArray(
17
17
  }
18
18
 
19
19
  export function mapObject(fn, obj){
20
+ if (arguments.length === 1){
21
+ return _obj => mapObject(fn, _obj)
22
+ }
20
23
  let index = 0
21
24
  const keys = _keys(obj)
22
25
  const len = keys.length
@@ -0,0 +1,33 @@
1
+ import { _isArray } from './_internals/_isArray.js'
2
+ import { createPath } from './_internals/createPath.js'
3
+ import { assoc } from './assoc.js'
4
+ import { curry } from './curry.js'
5
+ import { path as pathModule } from './path.js'
6
+
7
+ export function modifyPathFn(
8
+ pathInput, fn, object
9
+ ){
10
+ const path = createPath(pathInput)
11
+ if (path.length === 1){
12
+ return {
13
+ ...object,
14
+ [ path[0] ] : fn(object[ path[0] ]),
15
+ }
16
+ }
17
+ if (pathModule(path, object) === undefined) return object
18
+
19
+ const val = modifyPath(
20
+ Array.prototype.slice.call(path, 1),
21
+ fn,
22
+ object[ path[ 0 ] ]
23
+ )
24
+ if (val === object[ path[ 0 ] ]){
25
+ return object
26
+ }
27
+
28
+ return assoc(
29
+ path[ 0 ], val, object
30
+ )
31
+ }
32
+
33
+ export const modifyPath = curry(modifyPathFn)
package/src/propEq.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { curry } from './curry.js'
2
+ import { equals } from './equals.js'
3
+ import { prop } from './prop.js'
2
4
 
3
5
  function propEqFn(
4
6
  propToFind, valueToMatch, obj
5
7
  ){
6
8
  if (!obj) return false
7
9
 
8
- return obj[ propToFind ] === valueToMatch
10
+ return equals(valueToMatch, prop(propToFind, obj))
9
11
  }
10
12
 
11
13
  export const propEq = curry(propEqFn)
package/src/reduce.js CHANGED
@@ -2,6 +2,12 @@ import { _isArray } from './_internals/_isArray.js'
2
2
  import { _keys } from './_internals/_keys.js'
3
3
  import { curry } from './curry.js'
4
4
 
5
+ class ReduceStopper{
6
+ constructor(value){
7
+ this.value = value
8
+ }
9
+ }
10
+
5
11
  export function reduceFn(
6
12
  reducer, acc, list
7
13
  ){
@@ -15,6 +21,9 @@ export function reduceFn(
15
21
  acc = reducer(
16
22
  acc, list[ index ], index, list
17
23
  )
24
+ if (acc instanceof ReduceStopper){
25
+ return acc.value
26
+ }
18
27
  index++
19
28
  }
20
29
 
@@ -22,3 +31,4 @@ export function reduceFn(
22
31
  }
23
32
 
24
33
  export const reduce = curry(reduceFn)
34
+ export const reduceStopper = value => new ReduceStopper(value)
package/src/uniqBy.js ADDED
@@ -0,0 +1,13 @@
1
+ export function uniqBy(fn, list){
2
+ if (arguments.length === 1){
3
+ return _list => uniqBy(fn, _list)
4
+ }
5
+ const set = new Set()
6
+
7
+ return list.filter(item => {
8
+ if (set.has(fn(item))) return false
9
+ set.add(fn(item))
10
+
11
+ return true
12
+ })
13
+ }