split user.fns

This commit is contained in:
Matteo Pagliazzi
2016-03-08 18:58:39 +01:00
parent 393a26e51a
commit bb6f0f4252
21 changed files with 808 additions and 704 deletions

View File

@@ -0,0 +1,14 @@
import _ from 'lodash';
module.exports = function(obj, path, val) {
var arr;
arr = path.split('.');
return _.reduce(arr, (function(_this) {
return function(curr, next, index) {
if ((arr.length - 1) === index) {
curr[next] = val;
}
return curr[next] != null ? curr[next] : curr[next] = {};
};
})(this), obj);
};