Skip to content

Commit 80f15dc

Browse files
docs(README.md): update
1 parent a5c5026 commit 80f15dc

File tree

2 files changed

+38
-176
lines changed

2 files changed

+38
-176
lines changed

README.md

Lines changed: 26 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ isDefined(defined); // false
539539

540540
![update][update]
541541

542+
The function denies [classes][classes] in check to differ from classes.
543+
542544
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object].
543545

544546
```typescript
@@ -834,21 +836,20 @@ isNumberType(NUMBER_NEW_INSTANCE); // false
834836

835837
### isObject
836838

837-
Use `isObject()` or `is.object()` to check if **any** `value` is an `object` of a generic `Obj` type and [`Object`][object] instance with the possibility of containing the `key`.
839+
![update][update]
840+
841+
The function no longer checks the `key` but has `callback` instead.
842+
843+
Use `isObject()` or `is.object()` to check if **any** `value` is an `object` of a generic `Obj` type and [`Object`][object] instance.
838844

839845
```typescript
840-
const isObject: IsObject = <Obj = object>(value: any, key?: Key): value is Obj =>
841-
(typeOf(value) === 'object' && typeof value === 'object' && value instanceof Object === true)
842-
? isKey(key)
843-
? key in value
844-
: true
845-
: false;
846+
const isObject: IsObject = <Obj = object>(value: any, callback: ResultCallback = resultCallback): value is Obj =>
847+
callback(typeOf(value) === 'object' && typeof value === 'object' && value instanceof Object === true, value);
846848
```
847849

848-
| Parameter | Type | Description |
849-
| :-------- | :-----------: | :---------- |
850-
| value | `any` | Any `value` to check |
851-
| key? | [`Key`][key] | Property name to find in the `value` |
850+
| Parameter | Type | Description |
851+
| :-------- | :----: | :------------------- |
852+
| value | `any` | Any `value` to check |
852853

853854
The **return value** is a `boolean` indicating whether or not the `value` is an `object`.
854855

@@ -866,22 +867,6 @@ import { isObject } from '@angular-package/type';
866867
*/
867868
const NUMBER: any = 10304050;
868869

869-
/**
870-
* typeof === 'number'
871-
* instanceof Function === false
872-
* instanceof Number === false
873-
* instanceof Object === false
874-
*/
875-
const NUMBER_INSTANCE: any = Number(NUMBER);
876-
877-
/**
878-
* typeof === 'number'
879-
* instanceof Function === false
880-
* instanceof Number === true
881-
* instanceof Object === true
882-
*/
883-
const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
884-
885870
/**
886871
* typeof === 'string'
887872
* instanceof Function === false
@@ -890,22 +875,6 @@ const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
890875
*/
891876
const STRING: any = '!@#$%^&*()abcdefghijklmnoprstuwyz';
892877

893-
/**
894-
* typeof === 'string'
895-
* instanceof Function === false
896-
* instanceof Object === false
897-
* instanceof String === false
898-
*/
899-
const STRING_INSTANCE: any = String(STRING);
900-
901-
/**
902-
* typeof === 'string'
903-
* instanceof Function === false
904-
* instanceof Object === true
905-
* instanceof String === true
906-
*/
907-
const STRING_NEW_INSTANCE: any = new String(STRING);
908-
909878
const SYMBOL_NUMBER: unique symbol = Symbol(NUMBER);
910879
const SYMBOL_STRING: unique symbol = Symbol(STRING);
911880

@@ -930,14 +899,6 @@ const OBJECT_ONE: ObjectOne = {
930899
};
931900

932901
isObject(OBJECT_ONE); // true
933-
isObject(OBJECT_ONE, 'key as string'); // true
934-
isObject(OBJECT_ONE, STRING); // true
935-
isObject(OBJECT_ONE, STRING_NEW_INSTANCE); // true
936-
isObject(OBJECT_ONE, 1030405027); // true
937-
isObject(OBJECT_ONE, NUMBER); // true
938-
isObject(OBJECT_ONE, NUMBER_NEW_INSTANCE); // true
939-
isObject(OBJECT_ONE, SYMBOL_NUMBER); // true
940-
isObject(OBJECT_ONE, SYMBOL_STRING); // true
941902

942903
```
943904

@@ -994,39 +955,6 @@ const NUMBER: any = 10304050;
994955
*/
995956
const STRING: any = '!@#$%^&*()abcdefghijklmnoprstuwyz';
996957

997-
/**
998-
* typeof === 'number'
999-
* instanceof Function === false
1000-
* instanceof Number === false
1001-
* instanceof Object === false
1002-
*/
1003-
const NUMBER_INSTANCE: any = Number(NUMBER);
1004-
1005-
/**
1006-
* typeof === 'number'
1007-
* instanceof Function === false
1008-
* instanceof Number === true
1009-
* instanceof Object === true
1010-
*/
1011-
const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
1012-
1013-
1014-
/**
1015-
* typeof === 'string'
1016-
* instanceof Function === false
1017-
* instanceof Object === false
1018-
* instanceof String === false
1019-
*/
1020-
const STRING_INSTANCE: any = String(STRING);
1021-
1022-
/**
1023-
* typeof === 'string'
1024-
* instanceof Function === false
1025-
* instanceof Object === true
1026-
* instanceof String === true
1027-
*/
1028-
const STRING_NEW_INSTANCE: any = new String(STRING);
1029-
1030958
const SYMBOL_NUMBER: unique symbol = Symbol(NUMBER);
1031959
const SYMBOL_STRING: unique symbol = Symbol(STRING);
1032960

@@ -1060,10 +988,8 @@ const OBJECT_ONE: ObjectOne = {
1060988
};
1061989

1062990
isObjectKey(OBJECT_ONE, STRING); // true
1063-
isObjectKey(OBJECT_ONE, STRING_NEW_INSTANCE); // true
1064991
isObjectKey(OBJECT_ONE, 1030405027); // true
1065992
isObjectKey(OBJECT_ONE, NUMBER); // true
1066-
isObjectKey(OBJECT_ONE, NUMBER_NEW_INSTANCE); // true
1067993
isObjectKey(OBJECT_ONE, SYMBOL_NUMBER); // true
1068994
isObjectKey(OBJECT_ONE, SYMBOL_STRING); // true
1069995

@@ -1743,6 +1669,10 @@ guardClass<Class>(FUNCTION); // type error
17431669

17441670
### guardFunction
17451671

1672+
![update][update]
1673+
1674+
The function deny [classes][classes] in check cause of updated [`isFunction`](#isfunction).
1675+
17461676
Use `guardFunction()` or `guard.is.function()` to guard the `value` to be a [`Func`](#func) type.
17471677

17481678
```typescript
@@ -1838,15 +1768,21 @@ The **return value** is a `boolean` indicating whether or not the `value` is a `
18381768

18391769
### guardObject
18401770

1771+
![update][update]
1772+
1773+
The function has a properly working callback cause of the updated [`isObject`](#isobject).
1774+
18411775
Use `guardObject()` or `guard.is.object()` to guard the `value` to be an `object` of a generic `Obj` type.
18421776

18431777
```typescript
1844-
const guardObject: GuardObject = <Obj extends object>(value: Obj): value is Obj => isObject<Obj>(value);
1778+
const guardObject: GuardObject = <Obj extends object>(value: Obj, callback?: ResultCallback): value is Obj =>
1779+
isObject<Obj>(value, callback);
18451780
```
18461781

1847-
| Parameter | Type | Description |
1848-
| :-------- | :--------------------: | :------------------------------------ |
1849-
| value | `Obj` extends `object` | A generic `Obj` type `value` to guard |
1782+
| Parameter | Type | Description |
1783+
| :-------- | :--------------------------------: | :------------------------------------ |
1784+
| value | `Obj` extends `object` | A generic `Obj` type `value` to guard |
1785+
| callback? | [`ResultCallback`][resultcallback] | An Optional [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
18501786

18511787
The **return value** is a `boolean` indicating whether or not the `value` is an `object` of a generic `Obj`.
18521788

packages/type/README.md

Lines changed: 12 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ isDefined(defined); // false
539539

540540
![update][update]
541541

542+
The function deny [classes][classes] in check.
543+
542544
Use `isFunction()` or `is.function()` to check if **any** `value` is a `function` type, an instance of [`Function`][function] and [`Object`][object].
543545

544546
```typescript
@@ -834,21 +836,20 @@ isNumberType(NUMBER_NEW_INSTANCE); // false
834836

835837
### isObject
836838

837-
Use `isObject()` or `is.object()` to check if **any** `value` is an `object` of a generic `Obj` type and [`Object`][object] instance with the possibility of containing the `key`.
839+
![update][update]
840+
841+
The function no longer checks the `key`.
842+
843+
Use `isObject()` or `is.object()` to check if **any** `value` is an `object` of a generic `Obj` type and [`Object`][object] instance.
838844

839845
```typescript
840-
const isObject: IsObject = <Obj = object>(value: any, key?: Key): value is Obj =>
841-
(typeOf(value) === 'object' && typeof value === 'object' && value instanceof Object === true)
842-
? isKey(key)
843-
? key in value
844-
: true
845-
: false;
846+
const isObject: IsObject = <Obj = object>(value: any, callback: ResultCallback = resultCallback): value is Obj =>
847+
callback(typeOf(value) === 'object' && typeof value === 'object' && value instanceof Object === true, value);
846848
```
847849

848-
| Parameter | Type | Description |
849-
| :-------- | :-----------: | :---------- |
850-
| value | `any` | Any `value` to check |
851-
| key? | [`Key`][key] | Property name to find in the `value` |
850+
| Parameter | Type | Description |
851+
| :-------- | :----: | :------------------- |
852+
| value | `any` | Any `value` to check |
852853

853854
The **return value** is a `boolean` indicating whether or not the `value` is an `object`.
854855

@@ -866,22 +867,6 @@ import { isObject } from '@angular-package/type';
866867
*/
867868
const NUMBER: any = 10304050;
868869

869-
/**
870-
* typeof === 'number'
871-
* instanceof Function === false
872-
* instanceof Number === false
873-
* instanceof Object === false
874-
*/
875-
const NUMBER_INSTANCE: any = Number(NUMBER);
876-
877-
/**
878-
* typeof === 'number'
879-
* instanceof Function === false
880-
* instanceof Number === true
881-
* instanceof Object === true
882-
*/
883-
const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
884-
885870
/**
886871
* typeof === 'string'
887872
* instanceof Function === false
@@ -890,22 +875,6 @@ const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
890875
*/
891876
const STRING: any = '!@#$%^&*()abcdefghijklmnoprstuwyz';
892877

893-
/**
894-
* typeof === 'string'
895-
* instanceof Function === false
896-
* instanceof Object === false
897-
* instanceof String === false
898-
*/
899-
const STRING_INSTANCE: any = String(STRING);
900-
901-
/**
902-
* typeof === 'string'
903-
* instanceof Function === false
904-
* instanceof Object === true
905-
* instanceof String === true
906-
*/
907-
const STRING_NEW_INSTANCE: any = new String(STRING);
908-
909878
const SYMBOL_NUMBER: unique symbol = Symbol(NUMBER);
910879
const SYMBOL_STRING: unique symbol = Symbol(STRING);
911880

@@ -930,14 +899,6 @@ const OBJECT_ONE: ObjectOne = {
930899
};
931900

932901
isObject(OBJECT_ONE); // true
933-
isObject(OBJECT_ONE, 'key as string'); // true
934-
isObject(OBJECT_ONE, STRING); // true
935-
isObject(OBJECT_ONE, STRING_NEW_INSTANCE); // true
936-
isObject(OBJECT_ONE, 1030405027); // true
937-
isObject(OBJECT_ONE, NUMBER); // true
938-
isObject(OBJECT_ONE, NUMBER_NEW_INSTANCE); // true
939-
isObject(OBJECT_ONE, SYMBOL_NUMBER); // true
940-
isObject(OBJECT_ONE, SYMBOL_STRING); // true
941902

942903
```
943904

@@ -994,39 +955,6 @@ const NUMBER: any = 10304050;
994955
*/
995956
const STRING: any = '!@#$%^&*()abcdefghijklmnoprstuwyz';
996957

997-
/**
998-
* typeof === 'number'
999-
* instanceof Function === false
1000-
* instanceof Number === false
1001-
* instanceof Object === false
1002-
*/
1003-
const NUMBER_INSTANCE: any = Number(NUMBER);
1004-
1005-
/**
1006-
* typeof === 'number'
1007-
* instanceof Function === false
1008-
* instanceof Number === true
1009-
* instanceof Object === true
1010-
*/
1011-
const NUMBER_NEW_INSTANCE: any = new Number(NUMBER);
1012-
1013-
1014-
/**
1015-
* typeof === 'string'
1016-
* instanceof Function === false
1017-
* instanceof Object === false
1018-
* instanceof String === false
1019-
*/
1020-
const STRING_INSTANCE: any = String(STRING);
1021-
1022-
/**
1023-
* typeof === 'string'
1024-
* instanceof Function === false
1025-
* instanceof Object === true
1026-
* instanceof String === true
1027-
*/
1028-
const STRING_NEW_INSTANCE: any = new String(STRING);
1029-
1030958
const SYMBOL_NUMBER: unique symbol = Symbol(NUMBER);
1031959
const SYMBOL_STRING: unique symbol = Symbol(STRING);
1032960

@@ -1060,10 +988,8 @@ const OBJECT_ONE: ObjectOne = {
1060988
};
1061989

1062990
isObjectKey(OBJECT_ONE, STRING); // true
1063-
isObjectKey(OBJECT_ONE, STRING_NEW_INSTANCE); // true
1064991
isObjectKey(OBJECT_ONE, 1030405027); // true
1065992
isObjectKey(OBJECT_ONE, NUMBER); // true
1066-
isObjectKey(OBJECT_ONE, NUMBER_NEW_INSTANCE); // true
1067993
isObjectKey(OBJECT_ONE, SYMBOL_NUMBER); // true
1068994
isObjectKey(OBJECT_ONE, SYMBOL_STRING); // true
1069995

0 commit comments

Comments
 (0)