dry-underscore
Advanced tools
Comparing version 0.21.8 to 0.21.9
@@ -16,2 +16,3 @@ | ||
_.format = require('../lib/format.js').library(_); | ||
_.gis = require('../lib/gis.js').library(_); | ||
_.test = require('../lib/test.js').library(_); | ||
@@ -18,0 +19,0 @@ _.string_builder = require('../lib/string_builder.js').library(_); |
@@ -754,6 +754,9 @@ "use strict"; | ||
_.define = _.def = function(obj, key, defaultValue){ | ||
if(key === undefined){ return(obj); } | ||
_.define = _.def = function(obj, key, default_value){ | ||
if(default_value === undefined){ | ||
if(obj === undefined){ return(key); } | ||
if(obj !== undefined){ return(obj); } | ||
} | ||
if(obj[key] === undefined){ | ||
obj[key] = defaultValue; | ||
obj[key] = default_value; | ||
return(obj[key]); | ||
@@ -760,0 +763,0 @@ }else{ |
@@ -639,5 +639,21 @@ "use strict"; | ||
test('define', function(){ | ||
var z = {'a': 'b'}; | ||
_.define(z, 'c', {}).c = 'c'; | ||
eq(z, {'a' : 'b', 'c' : {'c' : 'c'}}); | ||
var foo = {'a': 'b'}; | ||
_.define(foo, 'c', {}).d = 'd'; | ||
eq(foo, {'a' : 'b', 'c' : {'d' : 'd'}}); | ||
var bar = { a: 'b' } | ||
eq(_.define(bar, 'c', 'c'), 'c'); | ||
eq(bar, { a: 'b', c: 'c' }); | ||
eq(_.define(), undefined); | ||
eq(_.define(undefined, undefined), undefined); | ||
eq(_.define(undefined, null), null); | ||
eq(_.define(undefined, true), true); | ||
eq(_.define({}.a, true), true); | ||
eq(_.define("str", undefined), "str"); | ||
eq(_.define("str", null), "str"); | ||
eq(_.define("str", true), "str"); | ||
}); | ||
@@ -644,0 +660,0 @@ |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.8", | ||
"version": "0.21.9", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "deep-diff": { |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.8", | ||
"version": "0.21.9", | ||
"main": "./index/node.index.js", | ||
"description": "The DRY Undescore Library", | ||
"description": "The DRY Underscore Library", | ||
"author": { | ||
@@ -7,0 +7,0 @@ "name": "Kendrick Taylor", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1924747
136
23428