ready-resource

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ready-resource

Weekly Downloads

1,159

Version

1.0.3

License

MIT

Unpacked Size

3.17 kB

Total Files

4

Last publish

Collaborators

  • mafintosh