-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.ts
38 lines (36 loc) · 953 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Check if the value is a number
*
* @param value The value to check
* @returns True if the value is a number, false otherwise
* @example
* isNumber("5");
* // => true
* isNumber("hello");
* // => false
*/
export const isNumber = (value: string): boolean => {
return value.match(/[0-9]/i) ? true : false;
};
/**
* Check if the value is a string
*
* @param value The value to check
* @returns True if the value is a string, false otherwise
* @example
* isString("hello");
* // => true
* isString("5");
* // => false
*/
export const isString = (value: string): boolean => {
return value.match(/[a-z]/i) ? true : false;
};
/**
* Check if the value is a whitespace character
* @param value The value to check
* @returns True if the value is a whitespace character, false otherwise
*/
export const isWhitespace = (value: string): boolean => {
return value === " " || value === "\n" || value === "\t" || value === "\r";
};