Skip to content

Commit 6cfd6cf

Browse files
authored
Merge pull request #10 from agiletech-web-dev/feat/update-is-utils
2 parents 5adc2f5 + 3a88b97 commit 6cfd6cf

30 files changed

+457
-7
lines changed

docs/reference/predicate/isBoolean.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# isBoolean
2+
3+
The `isBoolean` function checks if a value is a boolean.
4+
5+
## Signature
6+
7+
```typescript
8+
function isBoolean(val: any): val is boolean
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `unknown` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is boolean, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isBoolean } from 'js-utils-es/predicate';
23+
24+
isBoolean(1); // false
25+
isBoolean(true); // true
26+
```

docs/reference/predicate/isDate.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# isDate
2+
3+
The `isDate` function checks if a value is a `Date` object.
4+
5+
## Signature
6+
7+
```typescript
8+
function isDate(val: any): val is Date
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `unknown` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `Date`, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isDate } from 'js-utils-es/predicate';
23+
24+
isDate(1); // false
25+
isDate(true); // false
26+
isDate(new Date()); // true
27+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# isFunction
2+
3+
The `isFunction` function checks if a value is a `Function` object.
4+
5+
## Signature
6+
7+
```typescript
8+
function isFunction(val: any)
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `Function`, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isFunction } from 'js-utils-es/predicate';
23+
24+
isFunction(1); // false
25+
isFunction(true); // false
26+
isFunction(new Date()); // false
27+
isFunction(() => {}); // true
28+
```

docs/reference/predicate/isNull.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This function can also serve as a type predicate in TypeScript, narrowing the ty
1010
## Signature
1111

1212
```typescript
13-
function isNull(x: unknown): x is null;
13+
function isNull(val: any): val is null
1414
```
1515

1616
### Parameters

docs/reference/predicate/isNumber.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# isNumber
2+
3+
The `isNumber` function checks if a value is a `number`.
4+
5+
## Signature
6+
7+
```typescript
8+
function isNumber(val: any): val is number
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `number`, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isNumber } from 'js-utils-es/predicate';
23+
24+
isNumber(1); // true
25+
isNumber(true); // false
26+
isNumber(new Date()); // false
27+
isNumber(() => {}); // false
28+
```

docs/reference/predicate/isObject.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# isObject
2+
3+
The `isObject` function checks if a value is a plain object.
4+
5+
## Signature
6+
7+
```typescript
8+
function isObject(val: any): val is object
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a plain object, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isObject } from 'js-utils-es/predicate';
23+
24+
isObject({}); // true
25+
26+
isObject(1); // false
27+
isObject(true); // false
28+
isObject(new Date()); // false
29+
isObject(() => {}); // false
30+
```

docs/reference/predicate/isRegExp.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# isRegExp
2+
3+
The `isRegExp` function checks if a value is a `RegExp`.
4+
5+
## Signature
6+
7+
```typescript
8+
function isRegExp(val: any): val is RegExp
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `RegExp`, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isRegExp } from 'js-utils-es/predicate';
23+
24+
isRegExp(/[az]/g); // true
25+
26+
isRegExp(1); // false
27+
isRegExp(true); // false
28+
isRegExp(new Date()); // false
29+
isRegExp(() => {}); // false
30+
```

docs/reference/predicate/isString.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# isString
2+
3+
The `isString` function checks if a value is a `string`.
4+
5+
## Signature
6+
7+
```typescript
8+
function isString(val: unknown): val is string
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `string`, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isString } from 'js-utils-es/predicate';
23+
24+
isString('1'); // true
25+
26+
isString(1); // false
27+
isString(true); // false
28+
isString(new Date()); // false
29+
isString(() => {}); // false
30+
```

docs/reference/predicate/isUndefined.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ This function can also serve as a type predicate in TypeScript, narrowing the ty
1010
## Signature
1111

1212
```typescript
13-
function isUndefined(x: unknown): x is undefined;
13+
function isUndefined(val: any): val is undefined
1414
```
1515

1616
### Parameters
1717

18-
- `x` (`unknown`): The value to test if it is `undefined`.
18+
- `x` (`any`): The value to test if it is `undefined`.
1919

2020
### Returns
2121

docs/reference/predicate/isWindow.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# isWindow
2+
3+
The `isWindow` function checks if a value is a `window` object.
4+
5+
## Signature
6+
7+
```typescript
8+
function isWindow(val: any): boolean
9+
```
10+
11+
## Parameters
12+
13+
- **`val`**: `any` - The value to check.
14+
15+
## Returns
16+
17+
- **`boolean`** - Returns `true` if the value is a `window` object, otherwise `false`.
18+
19+
## Examples
20+
21+
```typescript
22+
import { isWindow } from 'js-utils-es/predicate';
23+
24+
isWindow(window); // true
25+
isWindow(true); // false
26+
isWindow(new Date()); // false
27+
isWindow(() => {}); // false
28+
```

0 commit comments

Comments
 (0)