https://github.com/little-core-labs/nanoresource-ready
Wait for a nanoresource to be ready (opened) and call a callback.
https://github.com/little-core-labs/nanoresource-ready
callback nanoresource ready
Last synced: 3 months ago
JSON representation
Wait for a nanoresource to be ready (opened) and call a callback.
- Host: GitHub
- URL: https://github.com/little-core-labs/nanoresource-ready
- Owner: little-core-labs
- License: mit
- Created: 2019-10-27T18:00:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-01T18:24:56.000Z (over 6 years ago)
- Last Synced: 2025-10-18T16:49:49.213Z (8 months ago)
- Topics: callback, nanoresource, ready
- Language: JavaScript
- Size: 5.86 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nanoresource-ready
==================
> Wait for a [nanoresource][nanoresource] to be ready (opened) and call
> a callback.
## Installation
```sh
$ npm install nanoresource-ready
```
## Status
> **Stable**
## Usage
```js
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) => {
})
```
## API
### `ready(resource[, opts], callback)`
Waits for a [nanoresource][nanoresource] to be ready (`opened`) and
calls `callback(err)`. `opts` can be an object that can look like:
```js
{
opening: false // if `true`, will call callback synchronously if resource is "opening"
}
```
### `ready.mixin(resource)`
Mixes in a [`ready()`](#ready) method to [nanoresource][nanoresource]
instance object.
```js
resource = ready.mixin(resource)
```
## License
MIT
[nanoresource]: https://github.com/mafintosh/nanoresource