yaml-to-object-path-record
v0.1.0 i18n object path record yaml
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 = require('yaml-to-object-path-record');
const yamlString = `
foo: bar
some: value
something:
deep: 'is a path'
else: 'also works'
`;
yamlToObjectPathRecord('unicorns');
//=> {foo: 'bar', some: 'value', 'something.deep': 'is a path', 'something.else': 'also works'}
npm i yaml-to-object-path-record
Metadata
- MIT
- >=10
- EdJoPaTo
- released 10/5/2020