New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

defaulty

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defaulty - npm Package Compare versions

Comparing version 1.2.2 to 2.0.0

3

CHANGELOG.md

@@ -7,2 +7,5 @@ # Change Log

## [2.0.0] - 2017-12-09
- Now `undefined` value will be overwrite by the default
## [1.2.2] - 2017-11-04

@@ -9,0 +12,0 @@ - Added support to ES5

8

dist/src/defaulty.js

@@ -18,6 +18,6 @@ 'use strict';

/* istanbul ignore else */
if (defaultObj.hasOwnProperty(i) && exclude.indexOf(i) === -1) if (!targetObj.hasOwnProperty(i)) {
targetObj[i] = defaultObj[i];
} else {
if (_typeof(targetObj[i]) === 'object') {
if (defaultObj.hasOwnProperty(i) && exclude.indexOf(i) === -1) {
if (!targetObj.hasOwnProperty(i) || typeof targetObj[i] === 'undefined') {
targetObj[i] = defaultObj[i];
} else if (_typeof(targetObj[i]) === 'object') {
defaulty(targetObj[i], defaultObj[i]);

@@ -24,0 +24,0 @@ }

'use strict';
var defaulty = require('../dist/src/defaulty');
var defaulty = require('../index');
var be = require('bejs');

@@ -62,3 +62,15 @@

});
describe('defaults, undefined value', function () {
it('should be return true', function () {
var targetObj = { a: undefined, b: 5, c: 8 };
var defaultObj = { a: 1, b: 2 };
var result = defaulty(targetObj, defaultObj);
console.log(targetObj);
console.log(result);
be.err.equal(result, targetObj);
be.err.equal(result, { a: 1, b: 5, c: 8 });
});
});
});
//# sourceMappingURL=defaulty.js.map
{
"name": "defaulty",
"version": "1.2.2",
"version": "2.0.0",
"description": "Copies missing properties to the target object.",

@@ -5,0 +5,0 @@ "main": "dist/src/defaulty.js",

@@ -12,10 +12,9 @@ /**

/* istanbul ignore else */
if (defaultObj.hasOwnProperty(i) && exclude.indexOf(i) === -1)
if (!targetObj.hasOwnProperty(i)) {
if (defaultObj.hasOwnProperty(i) && exclude.indexOf(i) === -1) {
if (!targetObj.hasOwnProperty(i) || typeof targetObj[i] === 'undefined') {
targetObj[i] = defaultObj[i];
} else {
if (typeof targetObj[i] === 'object') {
defaulty(targetObj[i], defaultObj[i]);
}
} else if (typeof targetObj[i] === 'object') {
defaulty(targetObj[i], defaultObj[i]);
}
}
}

@@ -22,0 +21,0 @@ return targetObj;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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