Comparing version 0.0.1 to 0.0.2
@@ -10,3 +10,3 @@ var type = require( "type-component" ), | ||
var key = keys.length > 0 ? keys.shift() : "", | ||
keyExists = has.call( object, key ), | ||
keyExists = has.call( object, key ) || object[ key ] !== void 0, | ||
keyValue = keyExists ? object[ key ] : undefined, | ||
@@ -13,0 +13,0 @@ keyTypeIsCorrect = type( keyValue ) === keyType; |
{ | ||
"name": "sc-haskey", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A utility that checks objects for deep keys and validates their type", | ||
@@ -17,2 +17,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -26,2 +26,45 @@ var hasKey = require( "../index" ), | ||
it( "should check a instantiated class has a property", function () { | ||
var MyClass = function () {}; | ||
MyClass.prototype.chicken = function () {}; | ||
MyClass.prototype.active = false; | ||
var myClass = new MyClass(); | ||
hasKey( myClass, "chicken", "function" ).should.be.true; | ||
hasKey( myClass, "active", "boolean" ).should.be.true; | ||
hasKey( myClass, "invalid" ).should.be.false; | ||
} ); | ||
it( "should check falsey values", function () { | ||
var a = { | ||
chicken: { | ||
is: { | ||
tasty: false | ||
} | ||
}, | ||
duck: { | ||
is: { | ||
really: { | ||
tasty: void 0 | ||
} | ||
} | ||
}, | ||
horse: { | ||
is: { | ||
big: undefined | ||
} | ||
} | ||
}; | ||
hasKey( a, "chicken.is.tasty" ).should.be.true; | ||
hasKey( a, "duck.is.really.tasty" ).should.be.true; | ||
hasKey( a, "horse.is.big" ).should.be.true; | ||
} ); | ||
} ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2715
67