@rimbu/base 0.11.0 → 0.11.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.
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches any type of function
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type AnyFunc = (...args: any[]) => any;
|
|
5
5
|
/**
|
|
6
6
|
* Gives true if the given type T is a function, false otherwise.
|
|
7
7
|
* @typeparam T - the input type
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type IsAnyFunc<T> = AnyFunc extends T ? true : false;
|
|
10
10
|
/**
|
|
11
11
|
* A predicate type for any record that resolves to true if any of the record
|
|
12
12
|
* properties is a function, false otherwise.
|
|
13
13
|
* This is useful to have a coarse discrimination between pure data objects and class instances.
|
|
14
14
|
* @typeparam T - the input type
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type IsObjWithoutFunctions<T> = AnyFunc extends T[keyof T] ? false : true;
|
|
17
17
|
/**
|
|
18
18
|
* A predicate type that resolves to true if the given type satisfies:
|
|
19
19
|
* - it is an object type (not a primitive)
|
|
@@ -23,28 +23,28 @@ export declare type IsObjWithoutFunctions<T> = AnyFunc extends T[keyof T] ? fals
|
|
|
23
23
|
* Otherwise, it resolves to false
|
|
24
24
|
* @typeparam T - the input type
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type IsPlainObj<T> = T extends null | undefined | number | string | boolean | bigint | symbol | AnyFunc | Iterable<any> | AsyncIterable<any> ? false : IsObjWithoutFunctions<T>;
|
|
27
27
|
/**
|
|
28
28
|
* Utility type that will only accept objects that are considered 'plain objects' according
|
|
29
29
|
* to the `IsPlainObj` predicate type.
|
|
30
30
|
* @typeparam T - the value type to test
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export type PlainObj<T> = IsPlainObj<T> extends true ? T : never;
|
|
33
33
|
/**
|
|
34
34
|
* Utility type that will only return true if the input type T is equal to `any`.
|
|
35
35
|
* @typeparam T - the value type to test
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
38
38
|
/**
|
|
39
39
|
* Utility type that will only return true if the input type T is a (readonly) array.
|
|
40
40
|
* @typeparm T - the value type to test
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export type IsArray<T> = T extends readonly any[] ? true : false;
|
|
43
43
|
/**
|
|
44
44
|
* Utility type to exclude any types that are iterable. Useful in cases where
|
|
45
45
|
* plain objects are required as inputs but not arrays.
|
|
46
46
|
*/
|
|
47
|
-
export
|
|
47
|
+
export type NotIterable = {
|
|
48
48
|
[Symbol.iterator]?: never;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
@@ -54,7 +54,7 @@ export declare type NotIterable = {
|
|
|
54
54
|
* @returns true if the given object is a pure data object
|
|
55
55
|
* @note does not check whether a record's properties are not functions
|
|
56
56
|
*/
|
|
57
|
-
export declare function isPlainObj(obj: any):
|
|
57
|
+
export declare function isPlainObj(obj: any): obj is object;
|
|
58
58
|
/**
|
|
59
59
|
* Returns true if the given object is Iterable
|
|
60
60
|
* @param obj - the object to check
|
package/dist/types/token.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const Token: unique symbol;
|
|
2
|
-
export
|
|
2
|
+
export type Token = typeof Token;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimbu/base",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Utilities to implement Rimbu collections",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@rimbu/common": "^0.12.
|
|
56
|
-
"tslib": "^2.
|
|
55
|
+
"@rimbu/common": "^0.12.1",
|
|
56
|
+
"tslib": "^2.5.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f7a7662f81e9246b244cab22c14776617652833f"
|
|
62
62
|
}
|
package/src/plain-object.ts
CHANGED
|
@@ -76,7 +76,7 @@ export type NotIterable = {
|
|
|
76
76
|
* @returns true if the given object is a pure data object
|
|
77
77
|
* @note does not check whether a record's properties are not functions
|
|
78
78
|
*/
|
|
79
|
-
export function isPlainObj(obj: any):
|
|
79
|
+
export function isPlainObj(obj: any): obj is object {
|
|
80
80
|
return (
|
|
81
81
|
typeof obj === 'object' &&
|
|
82
82
|
null !== obj &&
|