1.0.2 • Published 10 years ago

getvaluer v1.0.2

Weekly downloads
8
License
-
Repository
github
Last release
10 years ago

getValueR

Returns the value from an array or an object.

getValueR(key, collection, result)
{string} key           The key or property name of the value (can be a string consisting of dot notation that will be used to recursivly traverse the collection).
{mixed} collection     The array or object to search.
{mixed} result         The value to return if the key does not exist.

Example

var getValueR = require("getValueR");
var object = {
	a: {
		b: {
			c: 1,
			d: [1,2,3],
			e: false
		}
	}
};
getValueR("a.b.c", object); // 1
getValueR("a.b.e", object); // false
getValueR("a.b.notExists", object, null); // null
// Arrays
var array = [["a", "b", "c"], ["A"], ["X"]];
getValueR("0.0", array); // "a"
getValueR("1.0", array); // "A"
1.0.2

10 years ago

1.0.0

10 years ago