Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/thejmazz/js-yaml-promise

Promise wrapper around js-yaml
https://github.com/thejmazz/js-yaml-promise

Last synced: 19 days ago
JSON representation

Promise wrapper around js-yaml

Awesome Lists containing this project

README

        

# js-yaml-promise

Promise wrapper around [js-yaml][js-yaml]. Assumes a Promise implementation is present.

```
npm install --save js-yaml-promise
```

All methods are the exact same, just return a Promise around the `try/catch`, for example:

```javascript
const yaml = require('js-yaml')

exports.safeLoad = (string, options) => new Promise((resolve, reject) => {
try {
resolve(yaml.safeLoad(string, options))
} catch (err) {
reject(err)
}
})
```

I made this since [node-yaml][node-yaml] did not provide a Promise wrapper
around `safeLoad` and `safeDump`, it merely exposed `parse` as `load` from
js-yaml. As well I prefer wrappers to do exactly that - wrap - not add extra
methods.

[js-yaml]: https://github.com/nodeca/js-yaml
[node-yaml]: https://github.com/octet-stream/node-yaml

## License

[MIT](https://jmazz.mit-license.org/)