MCPcopy Create free account
hub / github.com/SparkPost/node-sparkpost / withCallback

Function withCallback

lib/withCallback.js:17–29  ·  view source on GitHub ↗

* withCallback handles an optional nodeback * and return the promise object * * @param promise {Promise} * @param cb {Function} * @return Promise * * @example * function eitherOr(options, callback) { * return withCallback(promiseThingy(options), callback); * }

(promise, cb)

Source from the content-addressed store, hash-verified

15 */
16
17function withCallback(promise, cb) {
18 if (typeof cb !== 'function') {
19 cb = noop;
20 }
21
22 promise.then((result) => {
23 cb(null, result);
24 }).catch((err) => {
25 cb(err);
26 });
27
28 return promise;
29}
30
31function noop() {}
32

Callers 1

sparkpost.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected