Wait for a nanoresource to be ready (opened) and call a callback.
$ npm install nanoresource-ready
Stable
const ready = require('nanoresource-ready')
// will call `resource.open()` if not already "opening"
ready(resource, (err) => {
})
// fast ready (possibly synchronous) if `true === resource.opening`
ready(resource, { opening: true }, (err) => {
})
Waits for a nanoresource to be ready (opened
) and
calls callback(err)
. opts
can be an object that can look like:
{
opening: false // if `true`, will call callback synchronously if resource is "opening"
}
Mixes in a ready()
method to nanoresource
instance object.
resource = ready.mixin(resource)
MIT