1.0.3 • Published 4 years ago

@iamnapo/get v1.0.3

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

@iamnapo/get

Get the value at a specific object (or string) path, without caring if it exists

build npm size license

Install

$ npm i @iamnapo/get

Usage

const get = require("@iamnapo/get");

get([4, 5], "[0]"); // => 4
get({ a: { b: 1 } }, "a.b"); // => 1
get({ a: { b: 1 } }, "a.c", "blah"); // => "blah"
get("napo", "[1]"); // => "a"

API

get(object, path, defaultValue?)

Get path of object, returning defaultValue if it doesn‘t exist.

object

Type: object | Array | string

Base object to get value from.

path

Type: string

Path to get value at.

defaultValue

Type: string\ Default: undefined

Return value if path doesn‘t exist.