ready-resource
v1.1.1
Published
Modern single resource management
Downloads
8,493
Readme
ready-resource
Modern single resource management
npm install ready-resource
Usage
const ReadyResource = require('ready-resource')
class Thing extends ReadyResource {
constructor () {
super()
}
async _open () {
// open the resource
}
async _close () {
// close the resource
}
}
const r = new Thing()
await r.ready() // calls _open once
await r.ready() // noop
await r.close() // calls _close after _open has finished
await r.close() // noop
License
MIT