Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nicolaslabbe
committed
Sep 21, 2016
1 parent
2777c53
commit 1966811
Showing
8 changed files
with
145 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
var set_deep_value = function(obj, is, value) { | ||
if (typeof is == 'string') | ||
return set_deep_value(obj,is.split('.'), value); | ||
else if (is.length==1 && value!==undefined) | ||
return obj[is[0]] = value; | ||
else if (is.length==0) | ||
return obj; | ||
else | ||
return set_deep_value(obj[is[0]],is.slice(1), value); | ||
if (typeof is == 'string'){ | ||
return set_deep_value(obj,is.split('.'), value); | ||
}else if (is.length == 1 && value !== undefined){ | ||
return obj[is[0]] = value; | ||
}else if (is.length==0){ | ||
return obj; | ||
}else { | ||
if(typeof obj[is[0]] === 'undefined' || obj[is[0]] === null) { | ||
obj[is[0]] = {} | ||
} | ||
return set_deep_value(obj[is[0]], is.slice(1), value); | ||
} | ||
} | ||
|
||
export default set_deep_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters