index.js
function _set (data, keys, value) {
  var i = 0;
  var prop;
  var length = keys.length;
  for(; i < length; i ++){
    prop = keys[i];
    if (i === length - 1) {
      // if the last key, set value
      data[prop] = value;
      return;
    }

    if (
      !(prop in data)

      // If the current value is not an object, we will override it.
      // The logic who invoke `.set()` method should make sure `data[prop]` is an object,
      // which `.set()` doesn't concern
      || !is_object(data[prop])
    ) {
      data[prop] = {};
    }

    data = data[prop];
  }
}
function _set (data, keys, value) {
  var i = 0;
  var prop;
  var length = keys.length;
  for(; i < length; i ++){
    prop = keys[i];
    if (i === length - 1) {
      // if the last key, set value
      data[prop] = value;
      return;
    }

    if (
      !(prop in data)

      // If the current value is not an object, we will override it.
      // The logic who invoke `.set()` method should make sure `data[prop]` is an object,
      // which `.set()` doesn't concern
      || !is_object(data[prop])
    ) {
      data[prop] = {};
    }

    data = data[prop];
  }
}
function _set ( data , keys , value ) { var i = 0 ; var prop ; var length = keys . length ; for ( ; i < length ; i ++ ) { prop = keys [ i ] ; if ( i === length - 1 ) { // if the last key, set value data [ prop ] = value ; return ; } if ( ! ( prop in data ) // If the current value is not an object, we will override it. // The logic who invoke `.set()` method should make sure `data[prop]` is an object, // which `.set()` doesn't concern || ! is_object ( data [ prop ] ) ) { data [ prop ] = { } ; } data = data [ prop ] ; } }
For better testing
For better testing