Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nhz-io/ref-resolve

JSON references resolver
https://github.com/nhz-io/ref-resolve

Last synced: 3 days ago
JSON representation

JSON references resolver

Awesome Lists containing this project

README

        

@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
```javascript
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
```javascript
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](LICENSE)