1.1.1 • Published 2 years ago

ready-resource-map v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ready-resource-map

Manage collections of ready-resources keyed by IDs, ensuring that the same resource is never concurrently opened more than once.

Usage

const ReadyResourceMap = require('ready-resource-map')

const m = new ReadyResourceMap()

// r1 === r2
const [r1, r2] = await Promise.all([
  m.open('my-id', create),
  m.open('my-id', create)
])

m.close('my-id')
// Will wait for the above close to resolve before overwriting 'my-id'
const r3 = await m.open('my-id', create)

function create () {
  // MyResource extends ReadyResource
  return new MyResource()
}

License

MIT

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago