File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
// Function.
2
- import { isClass } from './is-class.func' ;
3
- import { isFunction } from './is-function.func' ;
4
- import { isObject } from './is-object.func' ;
5
2
import { resultCallback } from '../../lib/result-callback.func' ;
6
3
// Interface.
7
4
import { CallbackPayload } from '../../interface/callback-payload.interface' ;
8
5
// Type.
9
6
import { Constructor } from '../../type/constructor.type' ;
10
7
import { ResultCallback } from '../../type/result-callback.type' ;
11
8
/**
12
- * Checks if any `value` is an `object` of a generic `Obj` type and an ` instance` of `Constructor` type .
9
+ * Checks if any `value` is an `object` type, an instance of `Object` and an instance of the provided `constructor` .
13
10
* @param value The `value` of any type to check against an instance of the provided `constructor`.
14
11
* @param constructor A `class` or `function` that specifies the type of the `Constructor`.
15
12
* @param callback A callback function of `ResultCallback` type with `payload` parameter of the default `CallbackPayload` shape and the
@@ -28,11 +25,11 @@ export const isInstance = <Obj, Payload extends object>(
28
25
payload ?: Payload
29
26
) : value is Obj =>
30
27
callback (
31
- isObject < Obj > ( value )
32
- ? isClass < Obj > ( constructor ) || isFunction ( constructor )
33
- ? value instanceof constructor === true
34
- : false
35
- : false ,
28
+ typeof value === 'object' &&
29
+ value instanceof Object === true &&
30
+ typeof constructor === 'function'
31
+ ? value instanceof constructor === true
32
+ : false ,
36
33
{
37
34
...{
38
35
name : isInstance . name ,
You can’t perform that action at this time.
0 commit comments