UNPKG

async-pond

Version:

一个使用 promise 来解决并发异步控制的方案,无任何依赖

24 lines 698 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.to = exports.isObject = void 0; function isObject(obj) { return Object.prototype.toString.call(obj) === "[object Object]"; } exports.isObject = isObject; /** * @param { Promise } promise * @param { Object= } errorExt - Additional Information you can pass to the err object * @return { Promise } */ function to(promise, errorExt) { return promise .then(function (data) { return [null, data]; }) .catch(function (err) { if (errorExt) { Object.assign(err, errorExt); } return [err, undefined]; }); } exports.to = to; //# sourceMappingURL=lib.js.map