notate
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

notate

Resolve dot notation strings

import { notate } from "notate";

const obj = {
	top_level: {
		nested: {
			value: "My Value",
		},
	},
};

notate(obj, "top_level.nested.value"); // 'My Value'
notate(obj, "top_level.missing.value"); // undefined

Resolve list notation as well

const obj = {
	list: [{ name: "Alice" }, { name: "Bob" }],
};
notate(obj, "list[1].name"); // 'Bob'

Supports Map and Set

const map = new Map([["key", { chain: "value" }]]);
notate(map, "key.chain"); // 'value'

const set = new Set([{ chain: "value" }]);
notate(set, "[0].chain"); // 'value'

/notate/

    Package Sidebar

    Install

    npm i notate

    Weekly Downloads

    1,896

    Version

    2.1.1

    License

    UNLICENSE

    Unpacked Size

    11.8 kB

    Total Files

    9

    Last publish

    Collaborators

    • omrilotan