MCPcopy Create free account
hub / github.com/coopernurse/node-pool / use

Method use

lib/Pool.js:478–491  ·  view source on GitHub ↗

* [use method, aquires a resource, passes the resource to a user supplied function and releases it] * @param {Function} fn [a function that accepts a resource and returns a promise that resolves/rejects once it has finished using the resource] * @return {Promise} [resolves once the resou

(fn, priority)

Source from the content-addressed store, hash-verified

476 * @return {Promise} [resolves once the resource is released to the pool]
477 */
478 use(fn, priority) {
479 return this.acquire(priority).then(resource => {
480 return fn(resource).then(
481 result => {
482 this.release(resource);
483 return result;
484 },
485 err => {
486 this.destroy(resource);
487 throw err;
488 }
489 );
490 });
491 }
492
493 /**
494 * Check if resource is currently on loan from the pool

Callers 1

Calls 3

acquireMethod · 0.95
releaseMethod · 0.95
destroyMethod · 0.95

Tested by

no test coverage detected