Socket
Socket
Sign inDemoInstall

sc-haskey

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sc-haskey - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

index.js

@@ -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;
} );
} );
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc