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

object-path

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-path - npm Package Compare versions

Comparing version 0.11.3 to 0.11.4

17

index.js

@@ -86,4 +86,8 @@ (function (root, factory){

function hasShallowProperty(obj, prop) {
return (options.includeInheritedProps || (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop))
}
function getShallowProperty(obj, prop) {
if (options.includeInheritedProps || (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop)) {
if (hasShallowProperty(obj, prop)) {
return obj[prop];

@@ -190,3 +194,3 @@ }

for (i in value) {
if (hasOwnProperty(value, i)) {
if (hasShallowProperty(value, i)) {
delete value[i];

@@ -266,5 +270,4 @@ }

var currentPath = getKey(path[0]);
var currentVal = getShallowProperty(obj, currentPath);
if(currentVal == null) {
return currentVal;
if (!hasShallowProperty(obj, currentPath)) {
return obj;
}

@@ -279,5 +282,3 @@

} else {
if (obj[currentPath] !== void 0) {
return objectPath.del(obj[currentPath], path.slice(1));
}
return objectPath.del(obj[currentPath], path.slice(1));
}

@@ -284,0 +285,0 @@

{
"name": "object-path",
"description": "Access deep object properties using a path",
"version": "0.11.3",
"version": "0.11.4",
"author": {

@@ -6,0 +6,0 @@ "name": "Mario Casciaro"

@@ -46,3 +46,3 @@

```
tsd query object-path --action install --save
typings install --save dt~object-path
```

@@ -49,0 +49,0 @@

@@ -388,2 +388,5 @@ 'use strict';

expect(objectPath.empty(obj, 'inexistant')).to.equal(void 0);
expect(objectPath.empty(null, 'path')).to.equal(void 0);
expect(objectPath.empty(void 0, 'path')).to.equal(void 0);
});

@@ -411,3 +414,5 @@

'property': true
}
},
nullProp: null,
undefinedProp: void 0
},

@@ -426,2 +431,13 @@ instance: new Instance()

objectPath.empty(obj, 'object.nullProp');
expect(obj.object.nullProp).to.equal(null);
objectPath.empty(obj, 'object.undefinedProp');
expect(obj.object.undefinedProp).to.equal(void 0);
expect(obj.object).to.have.property('undefinedProp');
objectPath.empty(obj, 'object.notAProp');
expect(obj.object.notAProp).to.equal(void 0);
expect(obj.object).to.not.have.property('notAProp');
objectPath.empty(obj, 'instance.test');

@@ -458,2 +474,20 @@ //instance.test is not own property, so it shouldn't be emptied

it('should remove null and undefined props (but not explode on nested)', function(){
var obj = { nullProp: null, undefinedProp: void 0 };
expect(obj).to.have.property('nullProp');
expect(obj).to.have.property('undefinedProp');
objectPath.del(obj, 'nullProp.foo');
objectPath.del(obj, 'undefinedProp.bar');
expect(obj).to.have.property('nullProp');
expect(obj).to.have.property('undefinedProp');
expect(obj).to.deep.equal({ nullProp: null, undefinedProp: void 0 });
objectPath.del(obj, 'nullProp');
objectPath.del(obj, 'undefinedProp');
expect(obj).to.not.have.property('nullProp');
expect(obj).to.not.have.property('undefinedProp');
expect(obj).to.deep.equal({});
});
it('should delete deep paths', function(){

@@ -460,0 +494,0 @@ var obj = getTestObj();

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