@nhz.io/ref-resolve

1.0.2 • Public • Published

@nhz.io/ref-resolve

NPM Version Bithound Status License Downloads

JSON references resolver

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}'] */

License

MIT

Package Sidebar

Install

npm i @nhz.io/ref-resolve

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ishi.ruy