mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
split user.fns
This commit is contained in:
14
common/script/libs/dotSet.js
Normal file
14
common/script/libs/dotSet.js
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user