Socket
Socket
Sign inDemoInstall

101

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

101 - npm Package Compare versions

Comparing version 0.18.0 to 0.19.0

21

defaults.js

@@ -5,2 +5,4 @@ /**

var isObject = require('./is-object');
var isBoolean = require('./is-boolean');
var exists = require('./exists');

@@ -17,3 +19,3 @@

function defaults (target, source) {
function defaults (target, source, deep) {
if (arguments.length === 1) {

@@ -24,11 +26,26 @@ source = target;

};
} else if (isBoolean(source)) {
deep = source;
source = target;
return function (target) {
return defaults(target, source, deep);
};
}
target = target || {};
deep = deep || false;
if (!source) {
return target;
}
return reduceObject(target, source, deep);
}
function reduceObject (target, source, deep) {
return Object.keys(source).reduce(function (target, key) {
if (isObject(target[key]) && isObject(source[key]) && deep) {
reduceObject(target[key], source[key]);
return target;
}
target[key] = exists(target[key]) ? target[key] : source[key];
return target;
}, target);
}
}

6

package.json
{
"name": "101",
"version": "0.18.0",
"version": "0.19.0",
"description": "common javascript utils that can be required selectively that assume es5+",
"main": "index.js",
"scripts": {
"test": "lab -c -t 100 -a code test",
"test-watch": "nodemon --exec lab -c test"
"test": "lab -c -t 100 -a code",
"test-watch": "nodemon --exec lab -c"
},

@@ -10,0 +10,0 @@ "repository": {

@@ -166,3 +166,3 @@ ![101](http://i.imgur.com/MFrmMt6.png)

Fill non-existing object values with defaults. Use it to set defaults on options.
Fill non-existing object values with defaults. Use it to set defaults on options. Works with supplying default values in sub-objects as well.
Supports partial functionality (great with array functions).

@@ -178,2 +178,16 @@

[opts].map(defaults(defs)); // [ { foo: 0, bar: 1, qux: 2 } ]
var opts = {
foo: {
one: 1,
two: 2
}
};
var defs = {
foo: {
two: 20,
three: 30
}
};
defaults(opts, defs); // { foo: { one: 1, two: 2, three: 30 } }
```

@@ -180,0 +194,0 @@

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