Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

ready-resource

Modern single resource management

fork for deno πŸ¦•

Usage

import { ReadyResource } from 'https://deno.land/x/ready_resource@v1.0.0/mod.ts'

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