@react-fabric/utilities 1.0.0-beta.0 → 1.0.0-beta.11
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/types/_isType.d.ts +12 -12
- package/package.json +2 -2
- package/src/_isType.ts +12 -12
package/dist/types/_isType.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare const isUndefined: (value:
|
|
2
|
-
export declare const isNull: (value:
|
|
3
|
-
export declare const isNil: (val:
|
|
4
|
-
export declare const isEmpty: (val:
|
|
5
|
-
export declare const isObject: (val:
|
|
6
|
-
export declare const isArray: <T =
|
|
7
|
-
export declare const isString: (value:
|
|
8
|
-
export declare const isNumber: (value:
|
|
9
|
-
export declare const isBoolean: (value:
|
|
10
|
-
export declare const isTrue: (value?:
|
|
11
|
-
export declare const isFalse: (value?:
|
|
1
|
+
export declare const isUndefined: (value: AnyObject) => value is undefined;
|
|
2
|
+
export declare const isNull: (value: AnyObject) => value is null;
|
|
3
|
+
export declare const isNil: (val: AnyObject) => val is undefined;
|
|
4
|
+
export declare const isEmpty: (val: AnyObject) => val is undefined;
|
|
5
|
+
export declare const isObject: (val: AnyObject) => val is KeyValue<any>;
|
|
6
|
+
export declare const isArray: <T = any>(val: AnyObject) => val is T[];
|
|
7
|
+
export declare const isString: (value: AnyObject) => value is string;
|
|
8
|
+
export declare const isNumber: (value: AnyObject) => value is number;
|
|
9
|
+
export declare const isBoolean: (value: AnyObject) => value is boolean;
|
|
10
|
+
export declare const isTrue: (value?: AnyObject) => value is true;
|
|
11
|
+
export declare const isFalse: (value?: AnyObject) => value is false;
|
|
12
12
|
export declare const isColor: (color: string) => boolean;
|
|
13
|
-
export declare const isSvgPath: (value:
|
|
13
|
+
export declare const isSvgPath: (value: AnyObject) => value is string;
|
|
14
14
|
export declare const isRtl: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/utilities",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "RUF: Utility package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"node": ">=18.12.0",
|
|
45
45
|
"npm": ">=8.19.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c113890832384265335f0572bfad9438e811917f"
|
|
48
48
|
}
|
package/src/_isType.ts
CHANGED
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
export const isUndefined = (value:
|
|
24
|
+
export const isUndefined = (value: AnyObject): value is undefined => {
|
|
25
25
|
return value === undefined;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export const isNull = (value:
|
|
28
|
+
export const isNull = (value: AnyObject): value is null => {
|
|
29
29
|
return value === null;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const isNil = (val:
|
|
32
|
+
export const isNil = (val: AnyObject): val is undefined => {
|
|
33
33
|
return val === undefined || val === null;
|
|
34
34
|
};
|
|
35
|
-
export const isEmpty = (val:
|
|
35
|
+
export const isEmpty = (val: AnyObject): val is undefined => {
|
|
36
36
|
if (val instanceof Date) return false;
|
|
37
37
|
if (isNil(val) || val === "") {
|
|
38
38
|
return true;
|
|
@@ -47,7 +47,7 @@ export const isEmpty = (val: unknown): val is undefined => {
|
|
|
47
47
|
return !!val && typeof val === "object" && Object.entries(val).length === 0;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export const isObject = (val:
|
|
50
|
+
export const isObject = (val: AnyObject): val is KeyValue => {
|
|
51
51
|
return (
|
|
52
52
|
!isNil(val) &&
|
|
53
53
|
!(val instanceof Date) &&
|
|
@@ -55,22 +55,22 @@ export const isObject = (val: unknown): val is KeyValue => {
|
|
|
55
55
|
!Array.isArray(val)
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
|
-
export const isArray = <T =
|
|
58
|
+
export const isArray = <T = AnyObject>(val: AnyObject): val is T[] => {
|
|
59
59
|
return Array.isArray(val);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export const isString = (value:
|
|
62
|
+
export const isString = (value: AnyObject): value is string => {
|
|
63
63
|
return typeof value === "string";
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
export const isNumber = (value:
|
|
66
|
+
export const isNumber = (value: AnyObject): value is number => {
|
|
67
67
|
return typeof value === "number";
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const isBoolean = (value:
|
|
70
|
+
export const isBoolean = (value: AnyObject): value is boolean => {
|
|
71
71
|
return typeof value === "boolean";
|
|
72
72
|
};
|
|
73
|
-
export const isTrue = (value:
|
|
73
|
+
export const isTrue = (value: AnyObject = ""): value is true => {
|
|
74
74
|
return (
|
|
75
75
|
value === true ||
|
|
76
76
|
value === 1 ||
|
|
@@ -78,7 +78,7 @@ export const isTrue = (value: unknown = ""): value is true => {
|
|
|
78
78
|
value?.toString().toLowerCase() === "true"
|
|
79
79
|
);
|
|
80
80
|
};
|
|
81
|
-
export const isFalse = (value:
|
|
81
|
+
export const isFalse = (value: AnyObject = ""): value is false => {
|
|
82
82
|
return (
|
|
83
83
|
value === false ||
|
|
84
84
|
value === 0 ||
|
|
@@ -94,7 +94,7 @@ export const isColor = (color: string) =>
|
|
|
94
94
|
color.startsWith?.("lab") ||
|
|
95
95
|
color === "transparent";
|
|
96
96
|
|
|
97
|
-
export const isSvgPath = (value:
|
|
97
|
+
export const isSvgPath = (value: AnyObject): value is string => {
|
|
98
98
|
return (
|
|
99
99
|
typeof value === "string" && value.match(/^[Mm][\d.].*[\dzZ]$/) !== null
|
|
100
100
|
);
|