yaml-to-object-path-record
Parses yaml into a
Record<string, string>
with object paths as key
This is often useful when having translation files in yaml and access them by object path. For example this is used in telegraf-i18n.
The name of the package is inspired by the TypeScript type Record<Key, Value>
as thats the structure of the result.
An object path is the path in dot notation needed to uniquely identify a key within the object.
For example {some: {deep: {object: {structure: 'value'}}}}
would have some.deep.object.structure
as object path.
Install
$ npm install yaml-to-object-path-record
Usage
const yamlToObjectPathRecord = ; const yamlString = `foo: barsome: valuesomething: deep: 'is a path' else: 'also works'`; ;//=> {foo: 'bar', some: 'value', 'something.deep': 'is a path', 'something.else': 'also works'}