{"id":17398485,"url":"https://github.com/vweevers/nanoresource-collection","last_synced_at":"2025-04-30T05:21:31.964Z","repository":{"id":57308007,"uuid":"282416965","full_name":"vweevers/nanoresource-collection","owner":"vweevers","description":"Open and close multiple nanoresources as one.","archived":false,"fork":false,"pushed_at":"2020-07-25T10:02:36.000Z","size":5,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T01:58:21.413Z","etag":null,"topics":["collection","nano","nanoresource","nodejs","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-25T09:58:37.000Z","updated_at":"2021-01-13T20:00:25.000Z","dependencies_parsed_at":"2022-08-31T05:04:33.328Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/nanoresource-collection","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fnanoresource-collection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fnanoresource-collection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fnanoresource-collection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fnanoresource-collection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/nanoresource-collection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645982,"owners_count":21620846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collection","nano","nanoresource","nodejs","npm-package"],"created_at":"2024-10-16T14:57:18.831Z","updated_at":"2025-04-30T05:21:31.929Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nanoresource-collection\n\n**Open and close multiple [nanoresources](https://github.com/mafintosh/nanoresource) as one.**\n\n[![npm status](http://img.shields.io/npm/v/nanoresource-collection.svg)](https://www.npmjs.org/package/nanoresource-collection)\n[![node](https://img.shields.io/node/v/nanoresource-collection.svg)](https://www.npmjs.org/package/nanoresource-collection)\n[![Travis build status](https://img.shields.io/travis/com/vweevers/nanoresource-collection.svg?label=travis)](http://travis-ci.com/vweevers/nanoresource-collection)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Usage\n\n```js\nconst Collection = require('nanoresource-collection')\nconst collection = new Collection([resource1, resource2])\n\ncollection.open(function (err) {\n  // All resources have been opened\n})\n\ncollection.close(function (err) {\n  // All resources have been closed\n})\n```\n\n## API\n\n### `new Collection([options, ][resources])`\n\nBoth arguments are optional. The `resources` argument can be an array and should contain `nanoresource` instances. Alternatively use `collection.push(...resources)`.\n\nResources 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.\n\nOptions:\n\n- `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.\n\nBecause `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:\n\n```js\nconst Collection = require('nanoresource-collection').promises\nconst collection = new Collection()\n\nawait collection.open()\nawait collection.close()\n```\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install nanoresource-collection\n```\n\n## License\n\n[MIT](LICENSE.md) © 2020-present Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fnanoresource-collection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fnanoresource-collection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fnanoresource-collection/lists"}