1.0.1 • Published 4 years ago
@uppercod/get-prop v1.0.1
get-prop
Obtains the value of an object or array, according to a string or array type map.
install
npm install @uppercod/get-prop
usage
import getProp from "@uppercod/get-prop";
const data = {
a: {
b: {
c: {
d: "d",
},
},
},
};
getProp(data, "a.b.c.d"); // d
getProp(data, "f", "..."); //...
Selector Map Syntax
a.b.c
equivalent to selectordata.a.b.c
.a.b[1]
equivalent to selectordata.a.b[1]
.a/b/c
equivalent to selectordata.a.b.c
.["a","b","c"]
equivalent to selectordata.a.b.c
.