Skip to content

Commit 915535a

Browse files
docs(README.md): update
1 parent 00d395c commit 915535a

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Guard
178178
* [Installation](#installation)
179179
* [Callback](#callback)
180180
* [Check](#check)
181+
* [typeOf](#typeof)
181182
* [are](#are)
182183
* [is](#is)
183184
* [isNot](#isnot)
@@ -243,6 +244,14 @@ const stringResult = isString('Lorem ipsum', customCallback);
243244

244245
## Check
245246

247+
### typeOf
248+
249+
Check functions are using `typeOf()` function as first. More about it [here](https://javascript.plainenglish.io/the-best-way-to-type-check-in-vanilla-js-55197b4f45ec).
250+
251+
```typescript
252+
const typeOf = (value: any): string => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
253+
```
254+
246255
### are
247256

248257
Tne object contains prefixed with `are` functions.
@@ -323,7 +332,7 @@ const is: Is = {
323332

324333
----
325334

326-
### isArray
335+
### `isArray`
327336

328337
Use `isArray()` or `is.array()` to check if **any** `value` is an [`Array`][array], [`Array`][array] instance, and `object` type.
329338

@@ -388,8 +397,8 @@ const isBigInt: IsBigInt = (value: any, callback: ResultCallback = resultCallbac
388397

389398
**Parameters:**
390399

391-
| Name | Type | Description |
392-
| :-------- | :-------------------------------------------------------------: | :---------- |
400+
| Name | Type | Description |
401+
| :-------- | :-------------------------------------------------------------: | :------------------- |
393402
| value | `any` | Any `value` to check |
394403
| callback | [`ResultCallback`][resultcallback]=[`resultCallback`][callback] | [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
395404

@@ -430,9 +439,9 @@ const isBoolean: IsBoolean = (value: any, callback: ResultCallback = resultCallb
430439

431440
**Parameters:**
432441

433-
| Name | Type | Description |
434-
| :---------| :---: | :------------------- |
435-
| value | `any` | Any `value` to check |
442+
| Name | Type | Description |
443+
| :-------- | :-------------------------------------------------------------: | :------------------- |
444+
| value | `any` | Any `value` to check |
436445
| callback | [`ResultCallback`][resultcallback]=[`resultCallback`][callback] | [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
437446

438447
**Return type:**
@@ -479,9 +488,9 @@ const isBooleanObject: IsBooleanObject = (value: any, callback: ResultCallback =
479488

480489
**Return type:**
481490

482-
| Returns | Type | Description |
483-
| :------------------- | :-------: | :---------------------------------------------------------------- |
484-
| `value` is `Boolean` | `boolean` | The **return type** is a `boolean` as the result of its statement |
491+
| Returns | Type | Description |
492+
| :------------------------------ | :-------: | :---------------------------------------------------------------- |
493+
| `value` is [`Boolean`][boolean] | `boolean` | The **return type** is a `boolean` as the result of its statement |
485494

486495
The **return value** is a `boolean` indicating whether or not the `value` is a [`Boolean`][boolean] instance.
487496

@@ -549,7 +558,7 @@ isBooleanType(BOOLEAN_INSTANCE); // false
549558

550559
### isClass
551560

552-
Use `isClass()` or `is.class()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object] as a generic `Class` type of [`class`][classes].
561+
Use `isClass()` or `is.class()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object] as a generic `Class` type of [`class`][classes]. It also **confirms** with the regexp that function is a [`class`][classes].
553562

554563
```typescript
555564
const isClass: IsClass = <Class = Function>(value: any, callback: ResultCallback = resultCallback): value is Class =>
@@ -646,7 +655,7 @@ isDefined(defined); // false
646655

647656
### isFunction
648657

649-
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object].
658+
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object]. It also **denies** with the regexp that function is a [`class`][classes].
650659

651660
```typescript
652661
const isFunction: IsFunction = (value: any, callback: ResultCallback = resultCallback): value is Func =>
@@ -2015,6 +2024,8 @@ const guard: Guard = {
20152024

20162025
```
20172026

2027+
----
2028+
20182029
### guardArray
20192030

20202031
Use `guardArray()` or `guard.is.array()` to guard the `value` to be an [`Array`][array] of a generic `Type`.

packages/type/README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Guard
178178
* [Installation](#installation)
179179
* [Callback](#callback)
180180
* [Check](#check)
181+
* [typeOf](#typeof)
181182
* [are](#are)
182183
* [is](#is)
183184
* [isNot](#isnot)
@@ -243,6 +244,14 @@ const stringResult = isString('Lorem ipsum', customCallback);
243244

244245
## Check
245246

247+
### typeOf
248+
249+
Check functions are using `typeOf()` function as first. More about it [here](https://javascript.plainenglish.io/the-best-way-to-type-check-in-vanilla-js-55197b4f45ec).
250+
251+
```typescript
252+
const typeOf = (value: any): string => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
253+
```
254+
246255
### are
247256

248257
Tne object contains prefixed with `are` functions.
@@ -323,7 +332,7 @@ const is: Is = {
323332

324333
----
325334

326-
### isArray
335+
### `isArray`
327336

328337
Use `isArray()` or `is.array()` to check if **any** `value` is an [`Array`][array], [`Array`][array] instance, and `object` type.
329338

@@ -388,8 +397,8 @@ const isBigInt: IsBigInt = (value: any, callback: ResultCallback = resultCallbac
388397

389398
**Parameters:**
390399

391-
| Name | Type | Description |
392-
| :-------- | :-------------------------------------------------------------: | :---------- |
400+
| Name | Type | Description |
401+
| :-------- | :-------------------------------------------------------------: | :------------------- |
393402
| value | `any` | Any `value` to check |
394403
| callback | [`ResultCallback`][resultcallback]=[`resultCallback`][callback] | [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
395404

@@ -430,9 +439,9 @@ const isBoolean: IsBoolean = (value: any, callback: ResultCallback = resultCallb
430439

431440
**Parameters:**
432441

433-
| Name | Type | Description |
434-
| :---------| :---: | :------------------- |
435-
| value | `any` | Any `value` to check |
442+
| Name | Type | Description |
443+
| :-------- | :-------------------------------------------------------------: | :------------------- |
444+
| value | `any` | Any `value` to check |
436445
| callback | [`ResultCallback`][resultcallback]=[`resultCallback`][callback] | [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
437446

438447
**Return type:**
@@ -479,9 +488,9 @@ const isBooleanObject: IsBooleanObject = (value: any, callback: ResultCallback =
479488

480489
**Return type:**
481490

482-
| Returns | Type | Description |
483-
| :------------------- | :-------: | :---------------------------------------------------------------- |
484-
| `value` is `Boolean` | `boolean` | The **return type** is a `boolean` as the result of its statement |
491+
| Returns | Type | Description |
492+
| :------------------------------ | :-------: | :---------------------------------------------------------------- |
493+
| `value` is [`Boolean`][boolean] | `boolean` | The **return type** is a `boolean` as the result of its statement |
485494

486495
The **return value** is a `boolean` indicating whether or not the `value` is a [`Boolean`][boolean] instance.
487496

@@ -549,7 +558,7 @@ isBooleanType(BOOLEAN_INSTANCE); // false
549558

550559
### isClass
551560

552-
Use `isClass()` or `is.class()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object] as a generic `Class` type of [`class`][classes].
561+
Use `isClass()` or `is.class()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object] as a generic `Class` type of [`class`][classes]. It also **confirms** with the regexp that function is a [`class`][classes].
553562

554563
```typescript
555564
const isClass: IsClass = <Class = Function>(value: any, callback: ResultCallback = resultCallback): value is Class =>
@@ -646,7 +655,7 @@ isDefined(defined); // false
646655

647656
### isFunction
648657

649-
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object].
658+
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object]. It also **denies** with the regexp that function is a [`class`][classes].
650659

651660
```typescript
652661
const isFunction: IsFunction = (value: any, callback: ResultCallback = resultCallback): value is Func =>
@@ -2015,6 +2024,8 @@ const guard: Guard = {
20152024

20162025
```
20172026

2027+
----
2028+
20182029
### guardArray
20192030

20202031
Use `guardArray()` or `guard.is.array()` to guard the `value` to be an [`Array`][array] of a generic `Type`.

0 commit comments

Comments
 (0)