1.0.1 • Published 4 years ago

@uppercod/get-prop v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

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

  1. a.b.c equivalent to selector data.a.b.c.
  2. a.b[1] equivalent to selector data.a.b[1].
  3. a/b/c equivalent to selector data.a.b.c.
  4. ["a","b","c"] equivalent to selector data.a.b.c.