{"id":13547857,"url":"https://github.com/ngryman/p-using","last_synced_at":"2025-08-08T20:23:12.608Z","repository":{"id":25939414,"uuid":"106936759","full_name":"ngryman/p-using","owner":"ngryman","description":"Dispose a resource when p-using promise resolves.","archived":false,"fork":false,"pushed_at":"2022-12-29T03:52:59.000Z","size":1198,"stargazers_count":1,"open_issues_count":18,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T15:12:17.225Z","etag":null,"topics":[],"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/ngryman.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-14T14:56:56.000Z","updated_at":"2023-07-06T10:24:59.000Z","dependencies_parsed_at":"2023-01-14T03:43:18.397Z","dependency_job_id":null,"html_url":"https://github.com/ngryman/p-using","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fp-using","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fp-using/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fp-using/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Fp-using/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngryman","download_url":"https://codeload.github.com/ngryman/p-using/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586245,"owners_count":21128998,"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":[],"created_at":"2024-08-01T12:01:02.145Z","updated_at":"2025-04-12T15:12:21.109Z","avatar_url":"https://github.com/ngryman.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# p-using [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![size][size-image]][size-url]\n\n\u003e Dispose a resource when p-using resolves.\n\n[travis-image]: https://img.shields.io/travis/ngryman/p-using.svg?style=flat\n\n[travis-url]: https://travis-ci.org/ngryman/p-using\n\n[codecov-image]: https://img.shields.io/codecov/c/github/ngryman/p-using.svg\n\n[codecov-url]: https://codecov.io/github/ngryman/p-using\n\n[size-image]: http://img.badgesize.io/https://unpkg.com/p-using@1.0.0/dist/p-using.min.js?compression=gzip\n\n[size-url]: https://unpkg.com/p-using@1.0.0/dist/p-using.min.js\n\nInspired from [Bluebird](http://bluebirdjs.com/docs/api/promise.using.html), `p-using` makes sure that the specifed `dispose` function is called on a `resource`.\n\n## Installation\n\n```sh\n$ npm install --save p-using\n```\n\n## Usage\n\n```js\nimport using from 'p-using'\n\n// call `db.dispose` method\nusing(db, db =\u003e { db.query('...') })\n\n// call `db.close` method\nusing(db, db =\u003e { db.query('...') }, 'close')\n\n// call the provided dispose function\nusing(db, db =\u003e { db.query('...') }, db =\u003e { db.finalize() })\n\n// accept a resource promise\nusing(createDb(), db =\u003e { db.query('...') })\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### using\n\n**Parameters**\n\n-   `resource` **([Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) \\| [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise))** Resource to be disposed.\n-   `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function to be invoked before disposal.\n-   `disposeFunction` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function))** Name of the method or function called for disposal.\n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise resolved when the resource has been disposed.\n\n## License\n\nMIT © [Nicolas Gryman](http://ngryman.sh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Fp-using","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngryman%2Fp-using","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Fp-using/lists"}