index.js
function define(obj, prop, getter) {
  if (!~prop.indexOf('.')) {
    defineProperty(obj, prop, getter);
    return obj;
  }

  var keys = prop.split('.');
  var last = keys.pop();
  var target = obj;
  var key;

  while ((key = keys.shift())) {
    while (key.slice(-1) === '\\') {
      key = key.slice(0, -1) + '.' + keys.shift();
    }
    target = target[key] || (target[key] = {});
  }

  defineProperty(target, last, getter);
  return obj;
}
function define(obj, prop, getter) {
  if (!~prop.indexOf('.')) {
    defineProperty(obj, prop, getter);
    return obj;
  }

  var keys = prop.split('.');
  var last = keys.pop();
  var target = obj;
  var key;

  while ((key = keys.shift())) {
    while (key.slice(-1) === '\\') {
      key = key.slice(0, -1) + '.' + keys.shift();
    }
    target = target[key] || (target[key] = {});
  }

  defineProperty(target, last, getter);
  return obj;
}
function define ( obj , prop , getter ) { if ( ! ~ prop . indexOf ( '.' ) ) { defineProperty ( obj , prop , getter ) ; return obj ; } var keys = prop . split ( '.' ) ; var last = keys . pop ( ) ; var target = obj ; var key ; while ( ( key = keys . shift ( ) ) ) { while ( key . slice ( - 1 ) === '\\' ) { key = key . slice ( 0 , - 1 ) + '.' + keys . shift ( ) ; } target = target [ key ] || ( target [ key ] = { } ) ; } defineProperty ( target , last , getter ) ; return obj ; }
Define getter function on object or object hierarchy using dot notation.

@param  {Object} `obj` Object to define getter property on.
@param  {String} `prop` Property string to define.
@param  {Function} `getter` Getter function to define.
@return {Object} Returns original object.
Define getter function on object or object hierarchy using dot notation .