it-parallel
Advanced tools
Comparing version
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.ItParallel = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var ItParallel=(()=>{var h=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var l in r)h(t,l,{get:r[l],enumerable:!0})},C=(t,r,l,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of g(r))!A.call(t,n)&&n!==l&&h(t,n,{get:()=>r[n],enumerable:!(c=b(r,n))||c.enumerable});return t};var I=t=>C(h({},"__esModule",{value:!0}),t);var O={};x(O,{default:()=>y});function a(){let t={};return t.promise=new Promise((r,l)=>{t.resolve=r,t.reject=l}),t}var d=globalThis.CustomEvent??Event;async function*y(t,r={}){let l=r.concurrency??1/0;l<1&&(l=1/0);let c=r.ordered??!1,n=new EventTarget,o=[],i=a(),f=a(),m=!1,u,v=!1;n.addEventListener("task-complete",()=>{f.resolve()}),Promise.resolve().then(async()=>{try{for await(let e of t){if(o.length===l&&(i=a(),await i.promise),v)break;let s={done:!1};o.push(s),e().then(p=>{s.done=!0,s.ok=!0,s.value=p,n.dispatchEvent(new d("task-complete"))},p=>{s.done=!0,s.err=p,n.dispatchEvent(new d("task-complete"))})}m=!0,n.dispatchEvent(new d("task-complete"))}catch(e){u=e,n.dispatchEvent(new d("task-complete"))}});function w(){return c?o[0]?.done:!!o.find(e=>e.done)}function*k(){for(;o.length>0&&o[0].done;){let e=o[0];if(o.shift(),e.ok)yield e.value;else throw v=!0,i.resolve(),e.err;i.resolve()}}function*E(){for(;w();)for(let e=0;e<o.length;e++)if(o[e].done){let s=o[e];if(o.splice(e,1),e--,s.ok)yield s.value;else throw v=!0,i.resolve(),s.err;i.resolve()}}for(;;){if(w()||(f=a(),await f.promise),u!=null)throw u;if(c?yield*k():yield*E(),m&&o.length===0)break}}return I(O);})(); | ||
"use strict";var ItParallel=(()=>{var h=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var n in r)h(t,n,{get:r[n],enumerable:!0})},C=(t,r,n,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of g(r))!A.call(t,l)&&l!==n&&h(t,l,{get:()=>r[l],enumerable:!(c=b(r,l))||c.enumerable});return t};var I=t=>C(h({},"__esModule",{value:!0}),t);var O={};x(O,{default:()=>y});function a(){let t={};return t.promise=new Promise((r,n)=>{t.resolve=r,t.reject=n}),t}var f=globalThis.CustomEvent??Event;async function*y(t,r={}){let n=r.concurrency??1/0;n<1&&(n=1/0);let c=r.ordered??!1,l=new EventTarget,o=[],s=a(),u=a(),w=!1,d,v=!1;l.addEventListener("task-complete",()=>{u.resolve()}),Promise.resolve().then(async()=>{try{for await(let e of t){if(o.length===n&&(s=a(),await s.promise),v)break;let i={done:!1};o.push(i),e().then(p=>{i.done=!0,i.ok=!0,i.value=p,l.dispatchEvent(new f("task-complete"))},p=>{i.done=!0,i.err=p,l.dispatchEvent(new f("task-complete"))})}w=!0,l.dispatchEvent(new f("task-complete"))}catch(e){d=e,l.dispatchEvent(new f("task-complete"))}});function m(){return c?o[0]?.done:!!o.find(e=>e.done)}function*k(){for(;o.length>0&&o[0].done;){let e=o[0];if(o.shift(),e.ok)yield e.value;else throw v=!0,s.resolve(),e.err;s.resolve()}}function*E(){for(;m();)for(let e=0;e<o.length;e++)if(o[e].done){let i=o[e];if(o.splice(e,1),e--,i.ok)yield i.value;else throw v=!0,s.resolve(),i.err;s.resolve()}}for(;;){if(m()||(u=a(),await u.promise),d!=null||(c?yield*k():yield*E(),d!=null))throw d;if(w&&o.length===0)break}}return I(O);})(); | ||
return ItParallel})); | ||
//# sourceMappingURL=index.min.js.map |
@@ -188,2 +188,9 @@ /** | ||
} | ||
if (sourceErr != null) { | ||
// if the source yields an array that is `yield *`, it can throw while the | ||
// onward consumer is processing the array contents - make sure we | ||
// propagate the error | ||
// eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw sourceErr; | ||
} | ||
if (sourceFinished && ops.length === 0) { | ||
@@ -190,0 +197,0 @@ // not waiting for any results and no more tasks so we are done |
{ | ||
"name": "it-parallel", | ||
"version": "3.0.9", | ||
"version": "3.0.10", | ||
"description": "Process incoming async(iterable) functions in parallel", | ||
@@ -5,0 +5,0 @@ "author": "Alex Potsides <alex@achingbrain.net>", |
@@ -225,2 +225,10 @@ /** | ||
if (sourceErr != null) { | ||
// if the source yields an array that is `yield *`, it can throw while the | ||
// onward consumer is processing the array contents - make sure we | ||
// propagate the error | ||
// eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw sourceErr | ||
} | ||
if (sourceFinished && ops.length === 0) { | ||
@@ -227,0 +235,0 @@ // not waiting for any results and no more tasks so we are done |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33700
36.19%9
12.5%503
3.07%