Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

delete-property

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delete-property - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

lib/index.js

@@ -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;
});
});
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