delete-property
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -21,3 +21,3 @@ 'use strict'; | ||
// Return false for non-objects or non-existent props | ||
if (obj !== Object(obj) || !obj[property]) return false; | ||
if (obj !== Object(obj) || !obj.hasOwnProperty(property)) return false; | ||
return delete obj[property]; | ||
@@ -24,0 +24,0 @@ }; |
{ | ||
"name": "delete-property", | ||
"description": "Deletes a deeply nested object property", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -79,2 +79,17 @@ /* eslint-env mocha */ | ||
it('should return false for properties higher up the prototype chain', () => { | ||
let proto = { a: { a: 1 } }; | ||
obj = Object.create(proto); | ||
// It'll work for nested properties higher up the chain | ||
expect(obj.a.hasOwnProperty('a')).to.be.true; | ||
let deleteAA = deleteProperty('a.a'); | ||
expect(deleteAA(obj)).to.be.true; | ||
// But not for properties that aren't on the obj itself | ||
expect(obj.hasOwnProperty('a')).to.be.false; | ||
let deleteA = deleteProperty('a'); | ||
expect(deleteA(obj)).to.be.false; | ||
}); | ||
}); |
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
7177
111