Open and close multiple nanoresources as one.
const Collection =const collection = resource1 resource2collectioncollection
new Collection([options, ][resources])
Both arguments are optional. The
resources argument can be an array and should contain
nanoresource instances. Alternatively use
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.
true, assume the resources are already open and adjust collection state accordingly. Useful for partially compliant resources (like servers) that only have a
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 = promisesconst collection =await collectionawait collection
With npm do:
npm install nanoresource-collection
MIT © 2020-present Vincent Weevers