index.js
function pushByPath(target, path, value) {
  path = pathToArray(path);

  if (! path.length) {
    if (! Array.isArray(target)) {
      return [value];
    }
    else {
      target.push(value);
      return target;
    }
  }

  if (! isObject(target)) {
    target = {};
  }

  return at(target, path, function(finalTarget, key) {
    if (Array.isArray(finalTarget[key])) {
      finalTarget[key].push(value);
    }
    else {
      finalTarget[key] = [value];
    }

    return finalTarget;
  });
}
function pushByPath(target, path, value) {
  path = pathToArray(path);

  if (! path.length) {
    if (! Array.isArray(target)) {
      return [value];
    }
    else {
      target.push(value);
      return target;
    }
  }

  if (! isObject(target)) {
    target = {};
  }

  return at(target, path, function(finalTarget, key) {
    if (Array.isArray(finalTarget[key])) {
      finalTarget[key].push(value);
    }
    else {
      finalTarget[key] = [value];
    }

    return finalTarget;
  });
}
function pushByPath ( target , path , value ) { path = pathToArray ( path ) ; if ( ! path . length ) { if ( ! Array . isArray ( target ) ) { return [ value ] ; } else { target . push ( value ) ; return target ; } } if ( ! isObject ( target ) ) { target = { } ; } return at ( target , path , function ( finalTarget , key ) { if ( Array . isArray ( finalTarget [ key ] ) ) { finalTarget [ key ] . push ( value ) ; } else { finalTarget [ key ] = [ value ] ; } return finalTarget ; } ) ; }
Push deeply nested value into target object. If nested properties are not an
objects or not exists creates them.

@param {*} target Parent object.
@param {Path} path   Array of path segments.
@param {*} value Value to set.
@return {Object|Array} Returns updated `target`.
Push deeply nested value into target object . If nested properties are not an objects or not exists creates them .