Code coverage report for lib/utils/set.js

Statements: 63.64% (7 / 11)      Branches: 50% (2 / 4)      Functions: 100% (1 / 1)      Lines: 63.64% (7 / 11)      Ignored: none     

All files » lib/utils/ » set.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181   20 20 20   20               20 20    
module.exports = function(target, keypath, value) {
 
  var keys = typeof keypath === "string" ? keypath.split(".") : keypath;
  var ct   = target;
  var key;
 
  for (var i = 0, n = keys.length - 1; i < n; i++) {
    key = keys[i];
    if (!ct[key]) {
      ct[key] = {};
    }
    ct = ct[key];
  }
 
  ct[keys[keys.length - 1]] = value;
  return value;
};