nanoresource-promise
Version:
Promises based nanoresource
71 lines (51 loc) • 1.97 kB
Markdown
[](https://travis-ci.com/geut/nanoresource-promise)
[](https://standardjs.com)
[](https://github.com/RichardLitt/standard-readme)
> Promises based [nanoresource](https://github.com/mafintosh/nanoresource)
```
$ npm install nanoresource-promise
```
```javascript
import { NanoresourcePromise } from 'nanoresource-promise'
;(async () => {
const resource = new NanoresourcePromise({
async open() {
// open the resource
},
async close() {
// close the resource
}
})
await resource.open()
await resource.close()
})()
```
```javascript
import { NanoresourcePromise } from 'nanoresource-promise/emitter' // for emittery support uses 'nanoresource-promise/emittery'
;(async () => {
const resource = new NanoresourcePromise({
async open() {
// open the resource
},
async close() {
// close the resource
}
})
resource.on('open', () => {})
resource.on('opened', () => {})
resource.on('close', () => {})
resource.on('closed', () => {})
await resource.open()
await resource.close()
})()
```
:bug: If you found an issue we encourage you to report it on [github](https://github.com/geut/nanoresource-promise/issues). Please specify your OS and the actions to reproduce it.
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this [guideline](https://github.com/geut/nanoresource-promise/blob/master/CONTRIBUTING.md).
MIT © A [**GEUT**](http://geutstudio.com/) project