🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

nanoresource-collection

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoresource-collection

Open and close multiple nanoresources as one

1.0.0
latest
Source
npm
Version published
Weekly downloads
8K
-25.05%
Maintainers
1
Weekly downloads
 
Created
Source

nanoresource-collection

Open and close multiple nanoresources as one.

npm status node Travis build status JavaScript Style Guide

Usage

const Collection = require('nanoresource-collection')
const collection = new Collection([resource1, resource2])

collection.open(function (err) {
  // All resources have been opened
})

collection.close(function (err) {
  // All resources have been closed
})

API

new Collection([options, ][resources])

Both arguments are optional. The resources argument can be an array and should contain nanoresource instances. Alternatively use collection.push(...resources).

Resources in the collection are opened sequentially. If one of the resources fails to open, other resources that did open successfully will be closed again. Resources are closed in reverse order: the last to be opened is the first to be closed.

Options:

  • opened (boolean): default false. If true, assume the resources are already open and adjust collection state accordingly. Useful for partially compliant resources (like servers) that only have a .close() method.

Because nanoresource-collection is itself a nanoresource, the API is the same and collections are composable. In addition nanoresource-collection ships a variant that (also) supports promises:

const Collection = require('nanoresource-collection').promises
const collection = new Collection()

await collection.open()
await collection.close()

Install

With npm do:

npm install nanoresource-collection

License

MIT © 2020-present Vincent Weevers

Keywords

close

FAQs

Package last updated on 25 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts