ramda-adjunct 2.30.0 → 2.33.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/.nvmrc +1 -0
- package/CHANGELOG.md +44 -0
- package/README.md +6 -6
- package/dist/RA.node.js +7544 -7169
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +7544 -7169
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +20077 -18989
- package/dist/RA.web.standalone.min.js +1 -1
- package/es/catchP.js +24 -0
- package/es/dispatch.js +1 -1
- package/es/fantasy-land/Identity.js +61 -74
- package/es/fantasy-land/mapping.js +20 -23
- package/es/fantasy-land/traits.js +1 -1
- package/es/filterIndexed.js +27 -0
- package/es/findOr.js +28 -0
- package/es/flattenDepth.js +1 -1
- package/es/index.js +14 -3
- package/es/internal/ap.js +1 -1
- package/es/internal/ponyfills/Array.from.js +1 -1
- package/es/internal/ponyfills/Promise.allSettled.js +1 -1
- package/es/internal/ponyfills/Promise.any.js +2 -2
- package/es/invoke.js +20 -0
- package/es/isInteger32.js +28 -0
- package/es/isNotPrimitive.js +22 -0
- package/es/isPrimitive.js +31 -0
- package/es/isPrototypeOf.js +34 -0
- package/es/isSentinelValue.js +26 -0
- package/es/lastP.js +1 -1
- package/es/pathOrLazy.js +1 -1
- package/es/reduceP.js +1 -1
- package/es/reduceRightP.js +1 -1
- package/es/sortByProps.js +1 -1
- package/lib/anyP.js +2 -2
- package/lib/catchP.js +30 -0
- package/lib/dispatch.js +1 -1
- package/lib/fantasy-land/Identity.js +65 -75
- package/lib/fantasy-land/mapping.js +41 -25
- package/lib/fantasy-land/traits.js +18 -12
- package/lib/filterIndexed.js +33 -0
- package/lib/findOr.js +34 -0
- package/lib/flattenDepth.js +1 -1
- package/lib/index.js +40 -3
- package/lib/internal/ap.js +9 -3
- package/lib/internal/ponyfills/Array.from.js +1 -1
- package/lib/internal/ponyfills/Promise.allSettled.js +1 -1
- package/lib/internal/ponyfills/Promise.any.js +2 -2
- package/lib/invoke.js +29 -0
- package/lib/isInteger32.js +37 -0
- package/lib/isNotPrimitive.js +31 -0
- package/lib/isPrimitive.js +47 -0
- package/lib/isPrototypeOf.js +43 -0
- package/lib/isSentinelValue.js +35 -0
- package/lib/lastP.js +1 -1
- package/lib/pathOrLazy.js +1 -1
- package/lib/reduceP.js +1 -1
- package/lib/reduceRightP.js +1 -1
- package/lib/sortByProps.js +1 -1
- package/package.json +34 -32
- package/src/catchP.js +25 -0
- package/src/fantasy-land/Identity.js +24 -27
- package/src/fantasy-land/mapping.js +20 -24
- package/src/fantasy-land/traits.js +1 -1
- package/src/filterIndexed.js +28 -0
- package/src/findOr.js +30 -0
- package/src/fnull.js +4 -4
- package/src/index.js +10 -0
- package/src/internal/ap.js +1 -1
- package/src/internal/makeFlat.js +2 -3
- package/src/internal/ponyfills/Promise.allSettled.js +4 -3
- package/src/invoke.js +22 -0
- package/src/isInteger32.js +28 -0
- package/src/isNotPrimitive.js +25 -0
- package/src/isPrimitive.js +45 -0
- package/src/isPrototypeOf.js +36 -0
- package/src/isSentinelValue.js +26 -0
- package/src/isSymbol.js +4 -4
- package/src/pathOrLazy.js +4 -4
- package/src/replaceAll.js +0 -1
- package/types/index.d.ts +85 -1
- package/.mocharc.js +0 -9
package/types/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ declare namespace RamdaAdjunct {
|
|
|
14
14
|
reduce<Acc>(fn: (acc: Acc, val: T) => Acc, initAcc: Acc): Acc;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
interface Filterable<T> {
|
|
18
|
+
filter(fn: (t: T) => Boolean): Filterable<T>;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
interface Semigroup {
|
|
18
22
|
// https://www.typescriptlang.org/docs/handbook/advanced-types.html#polymorphic-this-types
|
|
19
23
|
concat(other: this): this;
|
|
@@ -40,6 +44,7 @@ declare namespace RamdaAdjunct {
|
|
|
40
44
|
interface Dictionary<T> { [key: string]: T; }
|
|
41
45
|
|
|
42
46
|
type DictPred<T> = (value: T, key: string) => boolean;
|
|
47
|
+
type Primitive = string | number | bigint | boolean | undefined | null | symbol;
|
|
43
48
|
|
|
44
49
|
interface Static {
|
|
45
50
|
/**
|
|
@@ -62,6 +67,24 @@ declare namespace RamdaAdjunct {
|
|
|
62
67
|
*/
|
|
63
68
|
isBoolean(val: any): val is boolean;
|
|
64
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Checks if value is a primitive data type. There are 6 primitive data types: `string`, `number`, `bigint`, `boolean`, `undefined`, `symbol` and a special case of `null`.
|
|
72
|
+
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values
|
|
73
|
+
* for definition of what sub-types comprise a primitive.
|
|
74
|
+
*/
|
|
75
|
+
isPrimitive<T>(val: T | Primitive): val is Primitive;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Checks if value is not a primitive data type. There are 6 primitive data types: `string`, `number`, `bigint`, `boolean`, `undefined`, `symbol` and a special case of `null`.
|
|
79
|
+
*/
|
|
80
|
+
isNotPrimitive<T>(val: T | Primitive): val is T;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Checks if an object exists in another object's prototype chain.
|
|
84
|
+
*/
|
|
85
|
+
isPrototypeOf(type: object, object: object): boolean;
|
|
86
|
+
isPrototypeOf(type: object): (object: object) => boolean;
|
|
87
|
+
|
|
65
88
|
/**
|
|
66
89
|
* Returns `true` if the given value is its type's empty value, `null` or `undefined`.
|
|
67
90
|
*/
|
|
@@ -95,7 +118,8 @@ declare namespace RamdaAdjunct {
|
|
|
95
118
|
/**
|
|
96
119
|
* Checks if input value is complement of `null` or `undefined`.
|
|
97
120
|
*/
|
|
98
|
-
|
|
121
|
+
/* tslint:disable-next-line:no-null-undefined-union null or undefined is the accurate type here */
|
|
122
|
+
isNotNil<T>(val: T | null | undefined): val is T;
|
|
99
123
|
|
|
100
124
|
/**
|
|
101
125
|
* Checks if input value is complement of `null`.
|
|
@@ -331,6 +355,11 @@ declare namespace RamdaAdjunct {
|
|
|
331
355
|
*/
|
|
332
356
|
isInteger(val: any): val is number;
|
|
333
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Checks whether the passed value is a signed 32 bit `integer`.
|
|
360
|
+
*/
|
|
361
|
+
isInteger32(val: any): boolean;
|
|
362
|
+
|
|
334
363
|
/**
|
|
335
364
|
* Checks whether the passed value is complement of `integer`.
|
|
336
365
|
*/
|
|
@@ -426,6 +455,12 @@ declare namespace RamdaAdjunct {
|
|
|
426
455
|
*/
|
|
427
456
|
isSparseArray(val: any): boolean;
|
|
428
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Checks whether the passed value is
|
|
460
|
+
* {@link https://github.com/getify/You-Dont-Know-JS/blob/9959fc904d584bbf0b02cf41c192f74ff4238581/types-grammar/ch4.md#the-curious-case-of-the-|a sentinel value}.
|
|
461
|
+
*/
|
|
462
|
+
isSentinelValue(val: any): boolean;
|
|
463
|
+
|
|
429
464
|
/**
|
|
430
465
|
* A function that returns `undefined`.
|
|
431
466
|
*/
|
|
@@ -705,6 +740,28 @@ declare namespace RamdaAdjunct {
|
|
|
705
740
|
(acc: TResult, list: R): TResult
|
|
706
741
|
};
|
|
707
742
|
|
|
743
|
+
/**
|
|
744
|
+
* {@link http://ramdajs.com/docs/#filter|R.filter} function that more closely resembles `Array.prototype.filter`.
|
|
745
|
+
* It takes two new parameters to its callback function: the current index, and the entire list.
|
|
746
|
+
*
|
|
747
|
+
* `filterIndexed` implementation is simple: `
|
|
748
|
+
* const filterIndexed = R.addIndex(R.filter);
|
|
749
|
+
* `
|
|
750
|
+
*/
|
|
751
|
+
filterIndexed<T>(iterator: (elem: T, idx: number, list: T[]) => Boolean, list: ReadonlyArray<T>): T[];
|
|
752
|
+
filterIndexed<T>(iterator: (elem: T, idx: number, list: T[]) => Boolean): (list: ReadonlyArray<T>) => T[];
|
|
753
|
+
filterIndexed<T>(
|
|
754
|
+
iterator: (elem: T, idx: number, list: Dictionary<T>) => Boolean,
|
|
755
|
+
list: Dictionary<T>,
|
|
756
|
+
): Dictionary<T>;
|
|
757
|
+
filterIndexed<T>(
|
|
758
|
+
iterator: (elem: T, idx: number, list: Dictionary<T>) => Boolean,
|
|
759
|
+
): (list: Dictionary<T>) => Dictionary<T>;
|
|
760
|
+
filterIndexed<T>(iterator: (elem: T, idx: number, list: Filterable<T>) => Boolean, list: Filterable<T>): Filterable<T>;
|
|
761
|
+
filterIndexed<T>(iterator: (elem: T, idx: number, list: Filterable<T>) => Boolean): (list: Filterable<T>) => Filterable<Boolean>;
|
|
762
|
+
filterIndexed(iterator: (char: string, idx: number, str: string) => Boolean, str: string): string[];
|
|
763
|
+
filterIndexed(iterator: (char: string, idx: number, str: string) => Boolean): (str: string) => string[];
|
|
764
|
+
|
|
708
765
|
/**
|
|
709
766
|
* Given an `Iterable`(arrays are `Iterable`), or a promise of an `Iterable`,
|
|
710
767
|
* which produces promises (or a mix of promises and values),
|
|
@@ -945,6 +1002,14 @@ declare namespace RamdaAdjunct {
|
|
|
945
1002
|
reject<T>(options: { timeout: number, value: T }): Promise<T>
|
|
946
1003
|
};
|
|
947
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Composable shortcut for `Promise.catch`.
|
|
1007
|
+
* The catchP function returns a Promise. It takes two arguments: a callback function for the rejections of the Promise
|
|
1008
|
+
* and the promise instance itself.
|
|
1009
|
+
*/
|
|
1010
|
+
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<A | B>;
|
|
1011
|
+
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<A | B>;
|
|
1012
|
+
|
|
948
1013
|
/**
|
|
949
1014
|
* Composable shortcut for `Promise.then`.
|
|
950
1015
|
* The thenP function returns a Promise. It takes two arguments: a callback function for the success of the Promise
|
|
@@ -1125,6 +1190,19 @@ declare namespace RamdaAdjunct {
|
|
|
1125
1190
|
defaultWhen<DefVal, Val>(predicate: Function, defaultVal: DefVal): (val: Val) => DefVal | Val;
|
|
1126
1191
|
defaultWhen(predicate: Function): <DefVal, Val>(defaultVal: DefVal) => (val: Val) => DefVal | Val;
|
|
1127
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* Returns the first element of the list which matches the predicate.
|
|
1195
|
+
* Returns default value if no element matches or matched element is `null`, `undefined` or `NaN`.
|
|
1196
|
+
* Dispatches to the find method of the second argument, if present.
|
|
1197
|
+
* Acts as a transducer if a transformer is given in list position.
|
|
1198
|
+
*/
|
|
1199
|
+
findOr<DefVal, T>(defaultVal: DefVal, predicate: (element: T) => boolean, list: ReadonlyArray<T>): T | DefVal;
|
|
1200
|
+
findOr<DefVal, T>(defaultVal: DefVal, predicate: (element: T) => boolean): (list: ReadonlyArray<T>) => T | DefVal;
|
|
1201
|
+
findOr<DefVal, T>(defaultVal: DefVal): {
|
|
1202
|
+
(predicate: (element: T) => boolean, list: ReadonlyArray<T>): T | DefVal;
|
|
1203
|
+
(predicate: (element: T) => boolean): (list: ReadonlyArray<T>) => T | DefVal;
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1128
1206
|
/**
|
|
1129
1207
|
* Y-combinator
|
|
1130
1208
|
*
|
|
@@ -1434,6 +1512,12 @@ declare namespace RamdaAdjunct {
|
|
|
1434
1512
|
invokeArgs(pathToMethod: string[], args: any[]): (obj: object) => any;
|
|
1435
1513
|
invokeArgs(pathToMethod: string[]): (args: any[], obj: object) => any;
|
|
1436
1514
|
|
|
1515
|
+
/**
|
|
1516
|
+
* Invokes the method at path of object.
|
|
1517
|
+
*/
|
|
1518
|
+
invoke(pathToMethod: string[], obj: object): any;
|
|
1519
|
+
invoke(pathToMethod: string[]): (obj: object) => any;
|
|
1520
|
+
|
|
1437
1521
|
/**
|
|
1438
1522
|
* Converts double-precision 64-bit binary format IEEE 754 to signed 32 bit integer number.
|
|
1439
1523
|
*/
|