Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/nhz-io/ref-resolve
- Owner: nhz-io
- License: mit
- Created: 2016-09-10T14:56:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-10T21:08:17.000Z (over 8 years ago)
- Last Synced: 2024-08-09T14:33:17.705Z (5 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@nhz.io/ref-resolve
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)