1.0.9 • Published 8 months ago

aa-digx v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

D I G X

Dig values out of nested objects.

Installation

npm install digx --save

or

yarn add digx

Usage

Digging values from deeply nested objects

import dg from "digx";
const source = { param: [{}, { test: "A" }] };

dg(source, "param[1].test") //=> A

Sets and Maps also work in the similar manner.

const source = new Map([
  ["param", new Set()],
  ["innerSet", new Set([new Map(), new Map([["innerKey", "value"]])])],
]);

dg(source, "innerSet[1].innerKey"); //=> value

When path is incorrect it returns undefined

dg({ param: [] }, "param[1].test") //=> undefined

Or it can thrown an exception when optional shouldThrow parameter is set to true

dg({ param: [] }, "param[1].test", true) //=> ! Could not dig the value using path
1.0.9

8 months ago

1.0.8

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago