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

diver

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diver - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

17

lib/get.js

@@ -5,3 +5,18 @@ module.exports = function(rootLevel, keys, defaultValue) {

var key = keys[i];
var val = level[key];
var val;
if (key instanceof Array) {
var keyOptions = key;
var keyElm;
for (var j = 0; j < keyOptions.length; j++) {
keyElm = keyOptions[j];
val = level[keyElm];
if (val !== undefined && val !== null) {
break;
}
}
} else {
val = level[key];
}
if (val === undefined || val === null) {

@@ -8,0 +23,0 @@ if (defaultValue !== undefined) {

17

package.json
{
"name": "diver",
"version": "1.0.0",
"version": "1.1.0",
"description": "Deep access to nested object values",

@@ -17,5 +17,14 @@ "main": "index.js",

},
"dependencies": {
"chai": "^2.2.0"
}
"repository": {
"type": "git",
"url": "https://github.com/grudzinski/diver.git"
},
"keywords": [
"deep",
"object"
],
"bugs": {
"url": "https://github.com/grudzinski/diver/issues"
},
"homepage": "https://github.com/grudzinski/diver"
}

@@ -25,2 +25,15 @@ var chai = require('chai');

it('works with array of keys per level', function() {
var result = get({ x: { y: 'y', z: 'z' } }, ['x', ['y','z']]);
assert.strictEqual(result, 'y');
result = get({ x: { y: 'y', z: 'z' } }, ['x', ['other','z']]);
assert.strictEqual(result, 'z');
result = get({ x: { y: 'y', z: 'z' } }, ['x', ['other','other2']], 'default');
assert.strictEqual(result, 'default');
});
});

@@ -13,4 +13,2 @@ var chai = require('chai');

debugger;
set(testObject, ['x', 'y', 'z'], 'test');

@@ -22,2 +20,13 @@

it('works 2', function() {
var testObject = {};
set(testObject, ['x', 'y', 'z'], 'test');
set(testObject, ['x', 'y', 'q'], 'test2');
assert.deepEqual(testObject, { x: { y: { z: 'test', q: 'test2' } } });
});
});
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