Détail du package

notate

omrilotan7.9kUNLICENSE2.1.1

Resolve dot notation strings

string, dot, notation, resolve

readme

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'