package
Dispose a resource when p-using resolves.
npm install p-usingGitHub-flavored package documentation.
Across all versions, last 30 days.
31 in 30 days
Runtime metadata.
Tagged topics.
Dispose a resource when p-using resolves.
Inspired from Bluebird, p-using makes sure that the specifed dispose function is called on a resource.
$ npm install --save p-usingimport using from 'p-using'
// call `db.dispose` method
using(db, () => { db.query('...') })
// call `db.close` method
using(db, () => { db.query('...') }, 'close')
// call the provided dispose function
using(db, () => { db.query('...') }, db => { db.finalize() })Parameters
resource (Object | Promise) Resource to be disposed.callback Function Function to be invoked before disposal.disposeFunction (String | Function) Name of the method or function called for disposal.Returns Promise Promise resolved when the resource has been disposed.
MIT © Nicolas Gryman