@nhz.io/ref-resolve
v1.0.2
Published
JSON references resolver
Downloads
7
Readme
Install
npm i -S @nhz.io/ref-resolve
Example
Successful reference resolution
const resolve = require('@nhz.io/ref-resolve')
const result = resolve({
a: {foo: 'FOO', bar: 'BAR'},
b: {foo: '${a.foo}', bar: '${a.bar}'},
c: '${a.foo}${b.bar}',
})
/* result = {
a: { foo: 'FOO', bar: 'BAR' },
b: { foo: 'FOO', bar: 'BAR' },
c: 'FOOBAR',
} */
Get unresolved references
const resolve = require('@nhz.io/ref-resolve')
const unresolved = []
const result = resolve({
a: {foo: 'FOO', bar: 'BAR'},
b: {foo: '${a.FOO}', bar: '${a.BAR}'},
c: '${a.FOO}${a.BAR}'
}, unresolved)
/* result = {
a: { foo: 'FOO', bar: 'BAR' },
b: {},
} */
/* unresolved = ['${a.FOO}', '${a.BAR}'] */