UNPKG
modella-validators
Version:
latest (0.1.3)
0.1.3
0.1.2
0.1.1
0.1.0
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
Validators for Modella
github.com/modella/validators
modella/validators
modella-validators
/
deps
/
instance.js
14 lines
(12 loc)
•
297 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/** * Improved instanceof */
module
.
exports
=
function
instance
(
obj,
type
) {
switch
(
typeof
obj) {
case
'undefined'
:
return
false
;
case
'null'
:
return
false
;
case
'object'
:
return
obj
instanceof
type
; }
// compare constructor of primitive
return
obj.
constructor
==
type
; }