rambda 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -21
- package/README.md +793 -526
- package/dist/rambda.js +188 -75
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +60 -26
- package/index.d.ts +60 -26
- package/package.json +24 -25
- package/rambda.js +8 -0
- package/src/_internals/utils.js +21 -0
- package/src/addIndex.js +23 -0
- package/src/addIndexRight.js +9 -0
- package/src/ap.js +7 -0
- package/src/aperture.js +15 -0
- package/src/applyTo.js +7 -0
- package/src/ascend.js +23 -0
- package/src/descend.js +17 -0
- package/src/differenceWith.js +20 -0
package/immutable.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type IndexedIterator<T, U> = (x: T, i: number) => U;
|
|
|
23
23
|
export type Iterator<T, U> = (x: T) => U;
|
|
24
24
|
export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U;
|
|
25
25
|
type Ord = number | string | boolean | Date;
|
|
26
|
+
type Ordering = -1 | 0 | 1;
|
|
26
27
|
type Path = string | readonly (number | string)[];
|
|
27
28
|
export type RamdaPath = readonly (number | string)[];
|
|
28
29
|
type Predicate<T> = (x: T) => boolean;
|
|
@@ -56,6 +57,9 @@ type Pred = (...x: readonly any[]) => boolean;
|
|
|
56
57
|
export interface Dictionary<T> {readonly [index: string]: T}
|
|
57
58
|
type Partial<T> = { readonly [P in keyof T]?: T[P]};
|
|
58
59
|
|
|
60
|
+
type _TupleOf<T, N extends number, R extends readonly unknown[]> = R['length'] extends N ? R : _TupleOf<T, N, readonly [T, ...R]>;
|
|
61
|
+
export type Tuple<T, N extends number> = N extends N ? (number extends N ? readonly T[] : _TupleOf<T, N, readonly []>) : never;
|
|
62
|
+
|
|
59
63
|
type Evolvable<E extends Evolver> = { readonly[P in keyof E]?: Evolved<E[P]>};
|
|
60
64
|
|
|
61
65
|
type Evolver<T extends Evolvable<any> = any> = { readonly [key in keyof Partial<T>]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable<any> ? Evolver<T[key]> : never);
|
|
@@ -178,6 +182,12 @@ export function T(): boolean;
|
|
|
178
182
|
export function add(a: number, b: number): number;
|
|
179
183
|
export function add(a: number): (b: number) => number;
|
|
180
184
|
|
|
185
|
+
export function addIndex(originalFn: any): (fn: any) => (list: readonly any[]) => readonly any[];
|
|
186
|
+
export function addIndex(originalFn: any): (fn: any, list: readonly any[]) => readonly any[];
|
|
187
|
+
|
|
188
|
+
export function addIndexRight(originalFn: any): (fn: any) => (list: readonly any[]) => readonly any[];
|
|
189
|
+
export function addIndexRight(originalFn: any): (fn: any, list: readonly any[]) => readonly any[];
|
|
190
|
+
|
|
181
191
|
/**
|
|
182
192
|
* It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
|
|
183
193
|
*/
|
|
@@ -219,6 +229,13 @@ export function any<T>(predicate: (x: T) => boolean): (list: readonly T[]) => bo
|
|
|
219
229
|
export function anyPass<T>(predicates: readonly ((x: T) => boolean)[]): (input: T) => boolean;
|
|
220
230
|
export function anyPass<T>(predicates: readonly ((...inputs: readonly T[]) => boolean)[]): (...inputs: readonly T[]) => boolean;
|
|
221
231
|
|
|
232
|
+
export function ap<T, U>(fns: readonly ReadonlyArray<(a: T) => U>[], vs: readonly T[]): readonly U[];
|
|
233
|
+
export function ap<T, U>(fns: ReadonlyArray<(a: T) => U>): (vs: readonly T[]) => readonly U[];
|
|
234
|
+
export function ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;
|
|
235
|
+
|
|
236
|
+
export function aperture<N extends number, T>(n: N, list: readonly T[]): ReadonlyArray<Tuple<T, N>> | readonly [];
|
|
237
|
+
export function aperture<N extends number>(n: N): <T>(list: readonly T[]) => ReadonlyArray<Tuple<T, N>> | readonly [];
|
|
238
|
+
|
|
222
239
|
/**
|
|
223
240
|
* It adds element `x` at the end of `list`.
|
|
224
241
|
*/
|
|
@@ -240,6 +257,12 @@ export function applySpec<Spec extends Record<string, AnyFunction>>(
|
|
|
240
257
|
) => { readonly [Key in keyof Spec]: ReturnType<Spec[Key]> };
|
|
241
258
|
export function applySpec<T>(spec: any): (...args: readonly unknown[]) => T;
|
|
242
259
|
|
|
260
|
+
export function applyTo<T, U>(el: T, fn: (t: T) => U): U;
|
|
261
|
+
export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U;
|
|
262
|
+
|
|
263
|
+
export function ascend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
|
264
|
+
export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
|
265
|
+
|
|
243
266
|
/**
|
|
244
267
|
* It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.
|
|
245
268
|
*/
|
|
@@ -426,6 +449,9 @@ export function dec(x: number): number;
|
|
|
426
449
|
export function defaultTo<T>(defaultValue: T, input: T | null | undefined): T;
|
|
427
450
|
export function defaultTo<T>(defaultValue: T): (input: T | null | undefined) => T;
|
|
428
451
|
|
|
452
|
+
export function descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
|
453
|
+
export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
|
454
|
+
|
|
429
455
|
/**
|
|
430
456
|
* It returns the uniq set of all elements in the first list `a` not contained in the second list `b`.
|
|
431
457
|
*
|
|
@@ -434,6 +460,19 @@ export function defaultTo<T>(defaultValue: T): (input: T | null | undefined) =>
|
|
|
434
460
|
export function difference<T>(a: readonly T[], b: readonly T[]): readonly T[];
|
|
435
461
|
export function difference<T>(a: readonly T[]): (b: readonly T[]) => readonly T[];
|
|
436
462
|
|
|
463
|
+
export function differenceWith<T1, T2>(
|
|
464
|
+
pred: (a: T1, b: T2) => boolean,
|
|
465
|
+
list1: readonly T1[],
|
|
466
|
+
list2: readonly T2[],
|
|
467
|
+
): readonly T1[];
|
|
468
|
+
export function differenceWith<T1, T2>(
|
|
469
|
+
pred: (a: T1, b: T2) => boolean,
|
|
470
|
+
): (list1: readonly T1[], list2: readonly T2[]) => readonly T1[];
|
|
471
|
+
export function differenceWith<T1, T2>(
|
|
472
|
+
pred: (a: T1, b: T2) => boolean,
|
|
473
|
+
list1: readonly T1[],
|
|
474
|
+
): (list2: readonly T2[]) => readonly T1[];
|
|
475
|
+
|
|
437
476
|
/**
|
|
438
477
|
* It returns a new object that does not contain property `prop`.
|
|
439
478
|
*/
|
|
@@ -495,10 +534,10 @@ export function either(firstPredicate: Pred): (secondPredicate: Pred) => Pred;
|
|
|
495
534
|
* When iterable is a string, then it behaves as `String.prototype.endsWith`.
|
|
496
535
|
* When iterable is a list, then it uses R.equals to determine if the target list ends in the same way as the given target.
|
|
497
536
|
*/
|
|
498
|
-
export function endsWith(
|
|
499
|
-
export function endsWith(
|
|
500
|
-
export function endsWith<T>(
|
|
501
|
-
export function endsWith<T>(
|
|
537
|
+
export function endsWith<T extends string>(question: T, str: string): boolean;
|
|
538
|
+
export function endsWith<T extends string>(question: T): (str: string) => boolean;
|
|
539
|
+
export function endsWith<T>(question: readonly T[], list: readonly T[]): boolean;
|
|
540
|
+
export function endsWith<T>(question: readonly T[]): (list: readonly T[]) => boolean;
|
|
502
541
|
|
|
503
542
|
/**
|
|
504
543
|
* It returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`.
|
|
@@ -622,7 +661,7 @@ export function hasPath<T>(
|
|
|
622
661
|
*/
|
|
623
662
|
export function head(input: string): string;
|
|
624
663
|
export function head(emptyList: readonly []): undefined;
|
|
625
|
-
export function head<T>(
|
|
664
|
+
export function head<T extends readonly unknown[]>(array: T): FirstArrayElement<T>
|
|
626
665
|
|
|
627
666
|
/**
|
|
628
667
|
* It returns `true` if its arguments `a` and `b` are identical.
|
|
@@ -659,8 +698,8 @@ export function inc(x: number): number;
|
|
|
659
698
|
*
|
|
660
699
|
* If `input` is array, then `R.equals` is used to define if `valueToFind` belongs to the list.
|
|
661
700
|
*/
|
|
662
|
-
export function includes(valueToFind:
|
|
663
|
-
export function includes(valueToFind:
|
|
701
|
+
export function includes<T extends string>(valueToFind: T, input: string): boolean;
|
|
702
|
+
export function includes<T extends string>(valueToFind: T): (input: string) => boolean;
|
|
664
703
|
export function includes<T>(valueToFind: T, input: readonly T[]): boolean;
|
|
665
704
|
export function includes<T>(valueToFind: T): (input: readonly T[]) => boolean;
|
|
666
705
|
|
|
@@ -747,9 +786,9 @@ export function keys<T>(x: T): readonly string[];
|
|
|
747
786
|
/**
|
|
748
787
|
* It returns the last element of `input`, as the `input` can be either a string or an array.
|
|
749
788
|
*/
|
|
750
|
-
export function last(
|
|
789
|
+
export function last(input: string): string;
|
|
751
790
|
export function last(emptyList: readonly []): undefined;
|
|
752
|
-
export function last<T extends
|
|
791
|
+
export function last<T extends readonly unknown[]>(array: T): LastArrayElement<T>
|
|
753
792
|
|
|
754
793
|
/**
|
|
755
794
|
* It returns the last index of `target` in `list` array.
|
|
@@ -952,11 +991,6 @@ export function negate(x: number): number;
|
|
|
952
991
|
export function none<T>(predicate: (x: T) => boolean, list: readonly T[]): boolean;
|
|
953
992
|
export function none<T>(predicate: (x: T) => boolean): (list: readonly T[]) => boolean;
|
|
954
993
|
|
|
955
|
-
/**
|
|
956
|
-
* It returns `undefined`.
|
|
957
|
-
*/
|
|
958
|
-
export function nop(): void;
|
|
959
|
-
|
|
960
994
|
/**
|
|
961
995
|
* It returns a boolean negated version of `input`.
|
|
962
996
|
*/
|
|
@@ -1251,11 +1285,11 @@ export function prop<P extends keyof never, T>(propToFind: P): {
|
|
|
1251
1285
|
/**
|
|
1252
1286
|
* It returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch`.
|
|
1253
1287
|
*/
|
|
1254
|
-
export function propEq<K extends string | number>(
|
|
1255
|
-
export function propEq<K extends string | number>(
|
|
1256
|
-
export function propEq
|
|
1257
|
-
(
|
|
1258
|
-
(
|
|
1288
|
+
export function propEq<K extends string | number>(valueToMatch: any, propToFind: K, obj: Record<K, any>): boolean;
|
|
1289
|
+
export function propEq<K extends string | number>(valueToMatch: any, propToFind: K): (obj: Record<K, any>) => boolean;
|
|
1290
|
+
export function propEq(valueToMatch: any): {
|
|
1291
|
+
<K extends string | number>(propToFind: K, obj: Record<K, any>): boolean;
|
|
1292
|
+
<K extends string | number>(propToFind: K): (obj: Record<K, any>) => boolean;
|
|
1259
1293
|
};
|
|
1260
1294
|
|
|
1261
1295
|
/**
|
|
@@ -1318,9 +1352,9 @@ export function repeat<T>(x: T, timesToRepeat: number): readonly T[];
|
|
|
1318
1352
|
/**
|
|
1319
1353
|
* It replaces `strOrRegex` found in `str` with `replacer`.
|
|
1320
1354
|
*/
|
|
1321
|
-
export function replace(strOrRegex: RegExp | string, replacer:
|
|
1322
|
-
export function replace(strOrRegex: RegExp | string, replacer:
|
|
1323
|
-
export function replace(strOrRegex: RegExp | string): (replacer:
|
|
1355
|
+
export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string;
|
|
1356
|
+
export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer): (str: string) => string;
|
|
1357
|
+
export function replace(strOrRegex: RegExp | string): (replacer: RegExpReplacer) => (str: string) => string;
|
|
1324
1358
|
|
|
1325
1359
|
/**
|
|
1326
1360
|
* It returns a reversed copy of list or string `input`.
|
|
@@ -1397,10 +1431,10 @@ export function splitWhen<T>(predicate: Predicate<T>): <U>(list: readonly U[]) =
|
|
|
1397
1431
|
* When iterable is a string, then it behaves as `String.prototype.startsWith`.
|
|
1398
1432
|
* When iterable is a list, then it uses R.equals to determine if the target list starts in the same way as the given target.
|
|
1399
1433
|
*/
|
|
1400
|
-
export function startsWith(
|
|
1401
|
-
export function startsWith(
|
|
1402
|
-
export function startsWith<T>(
|
|
1403
|
-
export function startsWith<T>(
|
|
1434
|
+
export function startsWith<T extends string>(question: T, input: string): boolean;
|
|
1435
|
+
export function startsWith<T extends string>(question: T): (input: string) => boolean;
|
|
1436
|
+
export function startsWith<T>(question: readonly T[], input: readonly T[]): boolean;
|
|
1437
|
+
export function startsWith<T>(question: readonly T[]): (input: readonly T[]) => boolean;
|
|
1404
1438
|
|
|
1405
1439
|
/**
|
|
1406
1440
|
* Curried version of `x - y`
|
package/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type IndexedIterator<T, U> = (x: T, i: number) => U;
|
|
|
23
23
|
export type Iterator<T, U> = (x: T) => U;
|
|
24
24
|
export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U;
|
|
25
25
|
type Ord = number | string | boolean | Date;
|
|
26
|
+
type Ordering = -1 | 0 | 1;
|
|
26
27
|
type Path = string | (number | string)[];
|
|
27
28
|
export type RamdaPath = (number | string)[];
|
|
28
29
|
type Predicate<T> = (x: T) => boolean;
|
|
@@ -56,6 +57,9 @@ type Pred = (...x: any[]) => boolean;
|
|
|
56
57
|
export interface Dictionary<T> {[index: string]: T}
|
|
57
58
|
type Partial<T> = { [P in keyof T]?: T[P]};
|
|
58
59
|
|
|
60
|
+
type _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>;
|
|
61
|
+
export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : _TupleOf<T, N, []>) : never;
|
|
62
|
+
|
|
59
63
|
type Evolvable<E extends Evolver> = {[P in keyof E]?: Evolved<E[P]>};
|
|
60
64
|
|
|
61
65
|
type Evolver<T extends Evolvable<any> = any> = { [key in keyof Partial<T>]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable<any> ? Evolver<T[key]> : never);
|
|
@@ -178,6 +182,12 @@ export function T(): boolean;
|
|
|
178
182
|
export function add(a: number, b: number): number;
|
|
179
183
|
export function add(a: number): (b: number) => number;
|
|
180
184
|
|
|
185
|
+
export function addIndex(originalFn: any): (fn: any) => (list: any[]) => any[];
|
|
186
|
+
export function addIndex(originalFn: any): (fn: any, list: any[]) => any[];
|
|
187
|
+
|
|
188
|
+
export function addIndexRight(originalFn: any): (fn: any) => (list: any[]) => any[];
|
|
189
|
+
export function addIndexRight(originalFn: any): (fn: any, list: any[]) => any[];
|
|
190
|
+
|
|
181
191
|
/**
|
|
182
192
|
* It replaces `index` in array `list` with the result of `replaceFn(list[i])`.
|
|
183
193
|
*/
|
|
@@ -219,6 +229,13 @@ export function any<T>(predicate: (x: T) => boolean): (list: T[]) => boolean;
|
|
|
219
229
|
export function anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
|
|
220
230
|
export function anyPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;
|
|
221
231
|
|
|
232
|
+
export function ap<T, U>(fns: Array<(a: T) => U>[], vs: T[]): U[];
|
|
233
|
+
export function ap<T, U>(fns: Array<(a: T) => U>): (vs: T[]) => U[];
|
|
234
|
+
export function ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;
|
|
235
|
+
|
|
236
|
+
export function aperture<N extends number, T>(n: N, list: T[]): Array<Tuple<T, N>> | [];
|
|
237
|
+
export function aperture<N extends number>(n: N): <T>(list: T[]) => Array<Tuple<T, N>> | [];
|
|
238
|
+
|
|
222
239
|
/**
|
|
223
240
|
* It adds element `x` at the end of `list`.
|
|
224
241
|
*/
|
|
@@ -240,6 +257,12 @@ export function applySpec<Spec extends Record<string, AnyFunction>>(
|
|
|
240
257
|
) => { [Key in keyof Spec]: ReturnType<Spec[Key]> };
|
|
241
258
|
export function applySpec<T>(spec: any): (...args: unknown[]) => T;
|
|
242
259
|
|
|
260
|
+
export function applyTo<T, U>(el: T, fn: (t: T) => U): U;
|
|
261
|
+
export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U;
|
|
262
|
+
|
|
263
|
+
export function ascend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
|
264
|
+
export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
|
265
|
+
|
|
243
266
|
/**
|
|
244
267
|
* It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.
|
|
245
268
|
*/
|
|
@@ -426,6 +449,9 @@ export function dec(x: number): number;
|
|
|
426
449
|
export function defaultTo<T>(defaultValue: T, input: T | null | undefined): T;
|
|
427
450
|
export function defaultTo<T>(defaultValue: T): (input: T | null | undefined) => T;
|
|
428
451
|
|
|
452
|
+
export function descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
|
453
|
+
export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
|
454
|
+
|
|
429
455
|
/**
|
|
430
456
|
* It returns the uniq set of all elements in the first list `a` not contained in the second list `b`.
|
|
431
457
|
*
|
|
@@ -434,6 +460,19 @@ export function defaultTo<T>(defaultValue: T): (input: T | null | undefined) =>
|
|
|
434
460
|
export function difference<T>(a: T[], b: T[]): T[];
|
|
435
461
|
export function difference<T>(a: T[]): (b: T[]) => T[];
|
|
436
462
|
|
|
463
|
+
export function differenceWith<T1, T2>(
|
|
464
|
+
pred: (a: T1, b: T2) => boolean,
|
|
465
|
+
list1: T1[],
|
|
466
|
+
list2: T2[],
|
|
467
|
+
): T1[];
|
|
468
|
+
export function differenceWith<T1, T2>(
|
|
469
|
+
pred: (a: T1, b: T2) => boolean,
|
|
470
|
+
): (list1: T1[], list2: T2[]) => T1[];
|
|
471
|
+
export function differenceWith<T1, T2>(
|
|
472
|
+
pred: (a: T1, b: T2) => boolean,
|
|
473
|
+
list1: T1[],
|
|
474
|
+
): (list2: T2[]) => T1[];
|
|
475
|
+
|
|
437
476
|
/**
|
|
438
477
|
* It returns a new object that does not contain property `prop`.
|
|
439
478
|
*/
|
|
@@ -495,10 +534,10 @@ export function either(firstPredicate: Pred): (secondPredicate: Pred) => Pred;
|
|
|
495
534
|
* When iterable is a string, then it behaves as `String.prototype.endsWith`.
|
|
496
535
|
* When iterable is a list, then it uses R.equals to determine if the target list ends in the same way as the given target.
|
|
497
536
|
*/
|
|
498
|
-
export function endsWith(
|
|
499
|
-
export function endsWith(
|
|
500
|
-
export function endsWith<T>(
|
|
501
|
-
export function endsWith<T>(
|
|
537
|
+
export function endsWith<T extends string>(question: T, str: string): boolean;
|
|
538
|
+
export function endsWith<T extends string>(question: T): (str: string) => boolean;
|
|
539
|
+
export function endsWith<T>(question: T[], list: T[]): boolean;
|
|
540
|
+
export function endsWith<T>(question: T[]): (list: T[]) => boolean;
|
|
502
541
|
|
|
503
542
|
/**
|
|
504
543
|
* It returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`.
|
|
@@ -622,7 +661,7 @@ export function hasPath<T>(
|
|
|
622
661
|
*/
|
|
623
662
|
export function head(input: string): string;
|
|
624
663
|
export function head(emptyList: []): undefined;
|
|
625
|
-
export function head<T>(
|
|
664
|
+
export function head<T extends readonly unknown[]>(array: T): FirstArrayElement<T>
|
|
626
665
|
|
|
627
666
|
/**
|
|
628
667
|
* It returns `true` if its arguments `a` and `b` are identical.
|
|
@@ -659,8 +698,8 @@ export function inc(x: number): number;
|
|
|
659
698
|
*
|
|
660
699
|
* If `input` is array, then `R.equals` is used to define if `valueToFind` belongs to the list.
|
|
661
700
|
*/
|
|
662
|
-
export function includes(valueToFind:
|
|
663
|
-
export function includes(valueToFind:
|
|
701
|
+
export function includes<T extends string>(valueToFind: T, input: string): boolean;
|
|
702
|
+
export function includes<T extends string>(valueToFind: T): (input: string) => boolean;
|
|
664
703
|
export function includes<T>(valueToFind: T, input: T[]): boolean;
|
|
665
704
|
export function includes<T>(valueToFind: T): (input: T[]) => boolean;
|
|
666
705
|
|
|
@@ -747,9 +786,9 @@ export function keys<T>(x: T): string[];
|
|
|
747
786
|
/**
|
|
748
787
|
* It returns the last element of `input`, as the `input` can be either a string or an array.
|
|
749
788
|
*/
|
|
750
|
-
export function last(
|
|
789
|
+
export function last(input: string): string;
|
|
751
790
|
export function last(emptyList: []): undefined;
|
|
752
|
-
export function last<T extends
|
|
791
|
+
export function last<T extends readonly unknown[]>(array: T): LastArrayElement<T>
|
|
753
792
|
|
|
754
793
|
/**
|
|
755
794
|
* It returns the last index of `target` in `list` array.
|
|
@@ -952,11 +991,6 @@ export function negate(x: number): number;
|
|
|
952
991
|
export function none<T>(predicate: (x: T) => boolean, list: T[]): boolean;
|
|
953
992
|
export function none<T>(predicate: (x: T) => boolean): (list: T[]) => boolean;
|
|
954
993
|
|
|
955
|
-
/**
|
|
956
|
-
* It returns `undefined`.
|
|
957
|
-
*/
|
|
958
|
-
export function nop(): void;
|
|
959
|
-
|
|
960
994
|
/**
|
|
961
995
|
* It returns a boolean negated version of `input`.
|
|
962
996
|
*/
|
|
@@ -1251,11 +1285,11 @@ export function prop<P extends keyof never, T>(propToFind: P): {
|
|
|
1251
1285
|
/**
|
|
1252
1286
|
* It returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch`.
|
|
1253
1287
|
*/
|
|
1254
|
-
export function propEq<K extends string | number>(
|
|
1255
|
-
export function propEq<K extends string | number>(
|
|
1256
|
-
export function propEq
|
|
1257
|
-
(
|
|
1258
|
-
(
|
|
1288
|
+
export function propEq<K extends string | number>(valueToMatch: any, propToFind: K, obj: Record<K, any>): boolean;
|
|
1289
|
+
export function propEq<K extends string | number>(valueToMatch: any, propToFind: K): (obj: Record<K, any>) => boolean;
|
|
1290
|
+
export function propEq(valueToMatch: any): {
|
|
1291
|
+
<K extends string | number>(propToFind: K, obj: Record<K, any>): boolean;
|
|
1292
|
+
<K extends string | number>(propToFind: K): (obj: Record<K, any>) => boolean;
|
|
1259
1293
|
};
|
|
1260
1294
|
|
|
1261
1295
|
/**
|
|
@@ -1318,9 +1352,9 @@ export function repeat<T>(x: T, timesToRepeat: number): T[];
|
|
|
1318
1352
|
/**
|
|
1319
1353
|
* It replaces `strOrRegex` found in `str` with `replacer`.
|
|
1320
1354
|
*/
|
|
1321
|
-
export function replace(strOrRegex: RegExp | string, replacer:
|
|
1322
|
-
export function replace(strOrRegex: RegExp | string, replacer:
|
|
1323
|
-
export function replace(strOrRegex: RegExp | string): (replacer:
|
|
1355
|
+
export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string;
|
|
1356
|
+
export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer): (str: string) => string;
|
|
1357
|
+
export function replace(strOrRegex: RegExp | string): (replacer: RegExpReplacer) => (str: string) => string;
|
|
1324
1358
|
|
|
1325
1359
|
/**
|
|
1326
1360
|
* It returns a reversed copy of list or string `input`.
|
|
@@ -1397,10 +1431,10 @@ export function splitWhen<T>(predicate: Predicate<T>): <U>(list: U[]) => (U[])[]
|
|
|
1397
1431
|
* When iterable is a string, then it behaves as `String.prototype.startsWith`.
|
|
1398
1432
|
* When iterable is a list, then it uses R.equals to determine if the target list starts in the same way as the given target.
|
|
1399
1433
|
*/
|
|
1400
|
-
export function startsWith(
|
|
1401
|
-
export function startsWith(
|
|
1402
|
-
export function startsWith<T>(
|
|
1403
|
-
export function startsWith<T>(
|
|
1434
|
+
export function startsWith<T extends string>(question: T, input: string): boolean;
|
|
1435
|
+
export function startsWith<T extends string>(question: T): (input: string) => boolean;
|
|
1436
|
+
export function startsWith<T>(question: T[], input: T[]): boolean;
|
|
1437
|
+
export function startsWith<T>(question: T[]): (input: T[]) => boolean;
|
|
1404
1438
|
|
|
1405
1439
|
/**
|
|
1406
1440
|
* Curried version of `x - y`
|
package/package.json
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rambda",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
5
|
+
"benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
|
|
6
|
+
"benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
|
|
7
|
+
"benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
|
|
8
|
+
"benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
|
|
9
|
+
"build": "yarn build:main && yarn build:web",
|
|
10
|
+
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
|
|
11
|
+
"build:step": "yarn populatereadme && yarn build:main",
|
|
12
|
+
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
|
|
13
|
+
"d": "yarn out && yarn lint && run d",
|
|
14
|
+
"docs": "npx docsify-cli init ./docs && yarn fix-docsify",
|
|
13
15
|
"fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
|
|
16
|
+
"git:add": "git add -A",
|
|
17
|
+
"github": "cd ../rambda-scripts && yarn github",
|
|
14
18
|
"immutable": "cd ../rambda-scripts && yarn immutable:rambda",
|
|
15
19
|
"immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
|
|
16
|
-
"
|
|
20
|
+
"lint": "yarn git:add && yarn lint:staged && yarn git:add",
|
|
17
21
|
"lint:all": "cd ../rambda-scripts && yarn lint",
|
|
18
22
|
"lint:staged": "cd ../rambda-scripts && yarn lint:staged",
|
|
19
|
-
"lint": "yarn git:add && yarn lint:staged && yarn git:add",
|
|
20
|
-
"git:add": "git add -A",
|
|
21
|
-
"build": "yarn build:main && yarn build:web",
|
|
22
|
-
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
|
|
23
|
-
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
|
|
24
|
-
"docs": "npx docsify-cli init ./docs && yarn fix-docsify",
|
|
25
23
|
"new": "cd ../rambda-scripts && yarn new",
|
|
24
|
+
"out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
|
|
25
|
+
"populatedocs": "cd ../rambda-scripts && yarn populate:docs",
|
|
26
|
+
"populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
|
|
27
|
+
"populatereadme": "cd ../rambda-scripts && yarn populate:readme",
|
|
28
|
+
"populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
|
|
29
|
+
"publish:experimental": "node files/publish",
|
|
26
30
|
"run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
|
|
27
|
-
"test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
|
|
28
|
-
"test:all": "jest source/*.spec.js -u --bail=false",
|
|
29
31
|
"test": "jest -o -u --watch",
|
|
32
|
+
"test:all": "jest source/*.spec.js -u --bail=false",
|
|
30
33
|
"test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
|
|
35
|
-
"benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
|
|
36
|
-
"d:rambda-scripts": "cd ../rambda-scripts && run d",
|
|
37
|
-
"d": "yarn out && yarn lint && yarn d:rambda-scripts && run d"
|
|
34
|
+
"test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
|
|
35
|
+
"usedby": "cd ../rambda-scripts && yarn usedby",
|
|
36
|
+
"x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {},
|
|
40
39
|
"devDependencies": {
|
package/rambda.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export * from './src/F.js'
|
|
3
3
|
export * from './src/T.js'
|
|
4
4
|
export * from './src/add.js'
|
|
5
|
+
export * from './src/addIndex.js'
|
|
6
|
+
export * from './src/addIndexRight.js'
|
|
5
7
|
export * from './src/adjust.js'
|
|
6
8
|
export * from './src/all.js'
|
|
7
9
|
export * from './src/allPass.js'
|
|
@@ -9,9 +11,13 @@ export * from './src/always.js'
|
|
|
9
11
|
export * from './src/and.js'
|
|
10
12
|
export * from './src/any.js'
|
|
11
13
|
export * from './src/anyPass.js'
|
|
14
|
+
export * from './src/ap.js'
|
|
15
|
+
export * from './src/aperture.js'
|
|
12
16
|
export * from './src/append.js'
|
|
13
17
|
export * from './src/apply.js'
|
|
14
18
|
export * from './src/applySpec.js'
|
|
19
|
+
export * from './src/applyTo.js'
|
|
20
|
+
export * from './src/ascend.js'
|
|
15
21
|
export * from './src/assoc.js'
|
|
16
22
|
export * from './src/assocPath.js'
|
|
17
23
|
export * from './src/bind.js'
|
|
@@ -30,7 +36,9 @@ export * from './src/curry.js'
|
|
|
30
36
|
export * from './src/curryN.js'
|
|
31
37
|
export * from './src/dec.js'
|
|
32
38
|
export * from './src/defaultTo.js'
|
|
39
|
+
export * from './src/descend.js'
|
|
33
40
|
export * from './src/difference.js'
|
|
41
|
+
export * from './src/differenceWith.js'
|
|
34
42
|
export * from './src/dissoc.js'
|
|
35
43
|
export * from './src/divide.js'
|
|
36
44
|
export * from './src/drop.js'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function _concat(set1, set2){
|
|
2
|
+
set1 = set1 || []
|
|
3
|
+
set2 = set2 || []
|
|
4
|
+
let idx
|
|
5
|
+
const len1 = set1.length
|
|
6
|
+
const len2 = set2.length
|
|
7
|
+
const result = []
|
|
8
|
+
|
|
9
|
+
idx = 0
|
|
10
|
+
while (idx < len1){
|
|
11
|
+
result[ result.length ] = set1[ idx ]
|
|
12
|
+
idx += 1
|
|
13
|
+
}
|
|
14
|
+
idx = 0
|
|
15
|
+
while (idx < len2){
|
|
16
|
+
result[ result.length ] = set2[ idx ]
|
|
17
|
+
idx += 1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result
|
|
21
|
+
}
|
package/src/addIndex.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _concat } from './_internals/utils.js'
|
|
2
|
+
import { curryN } from './curryN.js'
|
|
3
|
+
|
|
4
|
+
export function addIndex(
|
|
5
|
+
originalFunction,
|
|
6
|
+
initialIndexFn = () => 0,
|
|
7
|
+
loopIndexChange = x => x + 1
|
|
8
|
+
){
|
|
9
|
+
return curryN(originalFunction.length, function (){
|
|
10
|
+
const origFn = arguments[ 0 ]
|
|
11
|
+
const list = arguments[ arguments.length - 1 ]
|
|
12
|
+
let idx = initialIndexFn(list.length)
|
|
13
|
+
const args = Array.prototype.slice.call(arguments, 0)
|
|
14
|
+
args[ 0 ] = function (){
|
|
15
|
+
const result = origFn.apply(this, _concat(arguments, [ idx, list ]))
|
|
16
|
+
idx = loopIndexChange(idx)
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return originalFunction.apply(this, args)
|
|
22
|
+
})
|
|
23
|
+
}
|
package/src/ap.js
ADDED
package/src/aperture.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function aperture(step, list){
|
|
2
|
+
if (arguments.length === 1){
|
|
3
|
+
return _list => aperture(step, _list)
|
|
4
|
+
}
|
|
5
|
+
if (step > list.length) return []
|
|
6
|
+
let idx = 0
|
|
7
|
+
const limit = list.length - (step - 1)
|
|
8
|
+
const acc = new Array(limit)
|
|
9
|
+
while (idx < limit){
|
|
10
|
+
acc[ idx ] = list.slice(idx, idx + step)
|
|
11
|
+
idx += 1
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return acc
|
|
15
|
+
}
|
package/src/applyTo.js
ADDED
package/src/ascend.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function createCompareFunction(
|
|
2
|
+
a, b, winner, loser
|
|
3
|
+
){
|
|
4
|
+
if (a === b) return 0
|
|
5
|
+
|
|
6
|
+
return a < b ? winner : loser
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ascend(
|
|
10
|
+
getFunction, a, b
|
|
11
|
+
){
|
|
12
|
+
if (arguments.length === 1){
|
|
13
|
+
return (_a, _b) => ascend(
|
|
14
|
+
getFunction, _a, _b
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
const aValue = getFunction(a)
|
|
18
|
+
const bValue = getFunction(b)
|
|
19
|
+
|
|
20
|
+
return createCompareFunction(
|
|
21
|
+
aValue, bValue, -1, 1
|
|
22
|
+
)
|
|
23
|
+
}
|
package/src/descend.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createCompareFunction } from './ascend.js'
|
|
2
|
+
|
|
3
|
+
export function descend(
|
|
4
|
+
getFunction, a, b
|
|
5
|
+
){
|
|
6
|
+
if (arguments.length === 1){
|
|
7
|
+
return (_a, _b) => descend(
|
|
8
|
+
getFunction, _a, _b
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
const aValue = getFunction(a)
|
|
12
|
+
const bValue = getFunction(b)
|
|
13
|
+
|
|
14
|
+
return createCompareFunction(
|
|
15
|
+
aValue, bValue, 1, -1
|
|
16
|
+
)
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { _indexOf } from './equals.js'
|
|
3
|
+
|
|
4
|
+
export function differenceWithFn(
|
|
5
|
+
fn, a, b
|
|
6
|
+
){
|
|
7
|
+
const willReturn = []
|
|
8
|
+
const [ first, second ] = a.length > b.length ? [ a, b ] : [ b, a ]
|
|
9
|
+
|
|
10
|
+
first.forEach(item => {
|
|
11
|
+
const hasItem = second.some(secondItem => fn(item, secondItem))
|
|
12
|
+
if (!hasItem && _indexOf(item, willReturn) === -1){
|
|
13
|
+
willReturn.push(item)
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
return willReturn
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const differenceWith = curry(differenceWithFn)
|