@antoniovdlc/await-on
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
declare function on<T, U = Error>(fn: Promise<T> | Function | Array<Promise<T> | Function>): Promise<[T, null] | [null, U]>; | ||
declare function on<T, Error>(fn: Promise<T> | Function | Array<Promise<T> | Function>): Promise<[T, null] | [null, Error]>; | ||
export default on; |
@@ -1,1 +0,1 @@ | ||
function n(n,e,t,r){return new(t||(t=Promise))((function(o,a){function u(n){try{i(r.next(n))}catch(n){a(n)}}function c(n){try{i(r.throw(n))}catch(n){a(n)}}function i(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(u,c)}i((r=r.apply(n,e||[])).next())}))}function e(n,e){var t,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(n,u)}catch(n){a=[6,n],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function t(t){return n(this,void 0,void 0,(function(){var n;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,8,,9]),t instanceof Error)throw t;return n=void 0,t instanceof Promise?[4,t]:[3,2];case 1:return n=e.sent(),[3,7];case 2:return t instanceof Function?[4,t()]:[3,4];case 3:return n=e.sent(),[3,7];case 4:return t instanceof Array?[4,Promise.all(t.map((function(n){if(n instanceof Error)throw n;return n instanceof Function?n():n})))]:[3,6];case 5:return n=e.sent(),[3,7];case 6:n=t,e.label=7;case 7:return[2,[n,null]];case 8:return[2,[null,e.sent()]];case 9:return[2]}}))}))}export default t; | ||
function n(n,e,t,r){return new(t||(t=Promise))((function(o,a){function u(n){try{i(r.next(n))}catch(n){a(n)}}function c(n){try{i(r.throw(n))}catch(n){a(n)}}function i(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(u,c)}i((r=r.apply(n,e||[])).next())}))}function e(n,e){var t,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(n,u)}catch(n){a=[6,n],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function t(t){return n(this,void 0,void 0,(function(){var n;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,8,,9]),t instanceof Error)throw t;return n=void 0,t instanceof Promise?[4,t]:[3,2];case 1:return n=e.sent(),[3,7];case 2:return t instanceof Function?[4,t()]:[3,4];case 3:return n=e.sent(),[3,7];case 4:return t instanceof Array?[4,Promise.all(t.map((function(n){if(n instanceof Error)throw n;return n instanceof Function?n():n})))]:[3,6];case 5:return n=e.sent(),[3,7];case 6:n=t,e.label=7;case 7:return[2,[n,null]];case 8:return[2,[null,e.sent()]];case 9:return[2]}}))}))}export{t as default}; |
{ | ||
"name": "@antoniovdlc/await-on", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Go-like error handling for async JavaScript functions (and more).", | ||
@@ -49,3 +49,3 @@ "main": "dist/index.cjs.js", | ||
"@rollup/plugin-typescript": "^8.2.1", | ||
"@types/jest": "^26.0.23", | ||
"@types/jest": "^27.0.1", | ||
"babel-jest": "^27.0.2", | ||
@@ -52,0 +52,0 @@ "eslint": "^7.29.0", |
11487
0.03%