@c4312/matcha
Version:
A caffeine driven, simple command line for benchmarking
24 lines • 633 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const noop = () => { };
exports.returnsPromiseLike = (fn) => {
var _a;
try {
return typeof ((_a = fn(noop)) === null || _a === void 0 ? void 0 : _a.then) === 'function';
}
catch (_b) {
return false;
}
};
/**
* Runs a possibly async function and returns a promise when it completes.
*/
exports.runMaybeAsync = (fn) => new Promise((resolve, reject) => {
if (fn.length === 0) {
resolve(fn(noop));
}
else {
fn(err => (err ? reject(err) : resolve()));
}
});
//# sourceMappingURL=async.js.map