lib/json-dry.js
function retrieveFromPath(current, keys) {

	var length = keys.length,
	    prev,
	    key,
	    i;

	// Keys [''] always means the root
	if (length == 1 && keys[0] === '') {
		return current;
	}

	for (i = 0; i < length; i++) {
		key = keys[i];

		// Normalize the key
		if (typeof key == 'number') {
			// Allow
		} else if (key.indexOf(safe_special_char) > -1) {
			key = key.replace(safe_special_char_rg, special_char);
		}

		prev = current;

		if (current) {
			if (current.hasOwnProperty(key)) {
				current = current[key];
			} else {
				return undefined;
			}
		} else {
			return undefined;
		}
	}

	return current;
}
function retrieveFromPath(current, keys) {

	var length = keys.length,
	    prev,
	    key,
	    i;

	// Keys [''] always means the root
	if (length == 1 && keys[0] === '') {
		return current;
	}

	for (i = 0; i < length; i++) {
		key = keys[i];

		// Normalize the key
		if (typeof key == 'number') {
			// Allow
		} else if (key.indexOf(safe_special_char) > -1) {
			key = key.replace(safe_special_char_rg, special_char);
		}

		prev = current;

		if (current) {
			if (current.hasOwnProperty(key)) {
				current = current[key];
			} else {
				return undefined;
			}
		} else {
			return undefined;
		}
	}

	return current;
}
function retrieveFromPath ( current , keys ) { var length = keys . length , prev , key , i ; // Keys [''] always means the root if ( length == 1 && keys [ 0 ] === '' ) { return current ; } for ( i = 0 ; i < length ; i ++ ) { key = keys [ i ] ; // Normalize the key if ( typeof key == 'number' ) { // Allow } else if ( key . indexOf ( safe_special_char ) > - 1 ) { key = key . replace ( safe_special_char_rg , special_char ) ; } prev = current ; if ( current ) { if ( current . hasOwnProperty ( key ) ) { current = current [ key ] ; } else { return undefined ; } } else { return undefined ; } } return current ; }
Retrieve from path.
Set the given value, but only if the containing object exists.

@author   Jelle De Loecker   <jelle@develry.be>
@since    0.1.4
@version  1.0.10

@param    {Object}   current   The object to look in
@param    {Array}    keys      The path to look for
@param    {Mixed}    value     Optional value to set

@return   {Mixed}
Retrieve from path . Set the given value but only if the containing object exists .