dry-underscore
Advanced tools
Comparing version 0.17.1 to 0.17.2
@@ -612,9 +612,15 @@ "use strict"; | ||
_.get = function(obj, key){ | ||
_.get = function(obj, key, call_f){ | ||
if(obj[key] !== undefined){ return obj[key]; } | ||
function get_val(v){ | ||
if(!call_f){ return(v); } | ||
else if(_.isFunction(v)){ return(v()); } | ||
else{ return(v); } | ||
} | ||
if(obj[key] !== undefined){ return get_val(obj[key]); } | ||
for (var prop in obj){ | ||
if(_.has(obj, prop) && prop.toLowerCase() === key.toLowerCase()){ | ||
return obj[prop]; | ||
return get_val(obj[prop]); | ||
} | ||
@@ -626,2 +632,6 @@ } | ||
_.val = function(obj, key){ | ||
return _.get(obj, key, true); | ||
}; | ||
_.define = _.def = function(obj, key, defaultValue){ | ||
@@ -628,0 +638,0 @@ if(key === undefined){ return(obj); } |
@@ -436,4 +436,16 @@ "use strict"; | ||
eq(_.get({ 'a': 'b'}, 'a'), 'b'); | ||
eq(_.get({ 'a': function(){ return('fb'); }}, 'a', true), 'fb'); | ||
ok(_.isFunction(_.get({ 'a': function(){ return('fb'); }}, 'a'))); | ||
}); | ||
test('val', function(){ | ||
eq(_.val({ 'A': 'b'}, 'a'), 'b'); | ||
eq(_.val(['a', 'b'], 1), 'b'); | ||
eq(_.val({ 'A': 'b'}, 'c'), undefined); | ||
eq(_.val({ 'a': 'b'}, 'a'), 'b'); | ||
eq(_.val({ 'a': function(){ return('fb'); }}, 'a'), 'fb'); | ||
eq(_.val({ 'A': function(){ return('fb'); }}, 'a'), 'fb'); | ||
}); | ||
test('each', function(){ | ||
@@ -440,0 +452,0 @@ |
@@ -12,3 +12,3 @@ | ||
this.add(this._indent, " "); | ||
this._str += _.toArray(arguments).join("") + "\n"; | ||
this._str += _.format.apply(null, arguments) + "\n"; | ||
}; | ||
@@ -15,0 +15,0 @@ string_builder_class.prototype.add_line = string_builder_class.prototype.addLine; |
@@ -17,7 +17,7 @@ "use strict"; | ||
sb.in(2); | ||
sb.add_line("in_two"); | ||
sb.add_line("in_two", {a: true}, [1,2]); | ||
sb.in(2); | ||
sb.add_line("in_four"); | ||
sb.add_line("in_four", "five", "six"); | ||
sb.out(2); | ||
sb.add_line("in_two"); | ||
sb.add_line("in_two", [1,2,3]); | ||
sb.out(2); | ||
@@ -30,5 +30,5 @@ sb.add_line("in_zero"); | ||
expects += "in_zero\n"; | ||
expects += " in_two\n"; | ||
expects += " in_four\n"; | ||
expects += " in_two\n"; | ||
expects += " in_two { a: true } [ 1, 2 ]\n"; | ||
expects += " in_fourfivesix\n"; | ||
expects += " in_two [ 1, 2, 3 ]\n"; | ||
expects += "in_zero\n"; | ||
@@ -35,0 +35,0 @@ |
{ | ||
"name": "dry-underscore", | ||
"version": "0.17.1", | ||
"version": "0.17.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "formidable": { |
{ | ||
"name": "dry-underscore", | ||
"version": "0.17.1", | ||
"version": "0.17.2", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "description": "The DRY Undescore Library", |
Sorry, the diff of this file is too big to display
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
1821080
20675