🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@n1ru4l/push-pull-async-iterable-iterator

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n1ru4l/push-pull-async-iterable-iterator - npm Package Compare versions

Comparing version

to
2.0.1

29

dist/push-pull-async-iterable-iterator.cjs.development.js

@@ -930,2 +930,5 @@ 'use strict';

}
var SYMBOL_FINISHED = /*#__PURE__*/Symbol();
var SYMBOL_NEW_VALUE = /*#__PURE__*/Symbol();
/**

@@ -939,3 +942,2 @@ * makePushPullAsyncIterableIterator

function makePushPullAsyncIterableIterator() {

@@ -946,7 +948,8 @@ var _asyncIterableIterato, _asyncIterableIterato2;

var values = [];
var d = createDeferred();
var newValueD = createDeferred();
var finishedD = createDeferred();
var asyncIterableIterator = function () {
var _PushPullAsyncIterableIterator = _wrapAsyncGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
var res;
var result;
return runtime_1.wrap(function _callee$(_context) {

@@ -956,6 +959,2 @@ while (1) {

case 0:
if (!isRunning) {
_context.next = 13;
break;
}

@@ -976,8 +975,8 @@ if (!(values.length > 0)) {

_context.next = 8;
return _awaitAsyncGenerator(d.promise);
return _awaitAsyncGenerator(Promise.race([newValueD.promise, finishedD.promise]));
case 8:
res = _context.sent;
result = _context.sent;
if (!(res === "finished")) {
if (!(result === SYMBOL_FINISHED)) {
_context.next = 11;

@@ -987,3 +986,3 @@ break;

return _context.abrupt("return");
return _context.abrupt("break", 13);

@@ -1016,4 +1015,4 @@ case 11:

values.push(value);
d.resolve("newValue");
d = createDeferred();
newValueD.resolve(SYMBOL_NEW_VALUE);
newValueD = createDeferred();
} // We monkey patch the original generator for clean-up

@@ -1028,3 +1027,3 @@

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);

@@ -1047,3 +1046,3 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);

@@ -1050,0 +1049,0 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

@@ -1,2 +0,2 @@

"use strict";function t(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.call(t)}throw new TypeError("Object is not async iterable")}function r(t){this.wrapped=t}function e(t){var e,n;function o(e,n){try{var a=t[e](n),u=a.value,c=u instanceof r;Promise.resolve(c?u.wrapped:u).then((function(t){c?o("return"===e?"return":"next",t):i(a.done?"return":"normal",t)}),(function(t){o("throw",t)}))}catch(t){i("throw",t)}}function i(t,r){switch(t){case"return":e.resolve({value:r,done:!0});break;case"throw":e.reject(r);break;default:e.resolve({value:r,done:!1})}(e=e.next)?o(e.key,e.arg):n=null}this._invoke=function(t,r){return new Promise((function(i,a){var u={key:t,arg:r,resolve:i,reject:a,next:null};n?n=n.next=u:(e=n=u,o(t,r))}))},"function"!=typeof t.return&&(this.return=void 0)}function n(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)};var o,i=(function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof f?r:f).prototype),i=new L(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=x(a,e);if(u){if(u===l)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function p(){}var v={};v[o]=function(){return this};var y=Object.getPrototypeOf,d=y&&y(y(E([])));d&&d!==r&&e.call(d,o)&&(v=d);var m=p.prototype=f.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function g(t,r){var n;this._invoke=function(o,i){function a(){return new r((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&e.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,x(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=m.constructor=p,p.constructor=h,h.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new g(c(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=E,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=e.call(i,"catchLoc"),c=e.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),l},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),l}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:E(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}(o={exports:{}}),o.exports);function a(){var t={};return t.promise=new Promise((function(r,e){t.resolve=r,t.reject=e})),t}function u(){var t,n,o,u,c=!0,s=[],l=a(),f=(o=i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!c){t.next=13;break}if(!(s.length>0)){t.next=6;break}return t.next=4,s.shift();case 4:t.next=11;break;case 6:return t.next=8,new r(l.promise);case 8:if("finished"!==t.sent){t.next=11;break}return t.abrupt("return");case 11:t.next=0;break;case 13:case"end":return t.stop()}}),t)})),u=function(){return new e(o.apply(this,arguments))},function(){return u.apply(this,arguments)})(),h=null==(t=f.return)?void 0:t.bind(f);f.return=function(){var t;c=!1,l.resolve("finished");for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return null!=(t=null==h?void 0:h.apply(void 0,e))?t:Promise.resolve({done:!0,value:void 0})};var p=null==(n=f.throw)?void 0:n.bind(f);return f.throw=function(){var t;c=!1,l.resolve("finished");for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return null!=(t=null==p?void 0:p.apply(void 0,e))?t:Promise.resolve({done:!0,value:void 0})},{pushValue:function(t){!1!==c&&(s.push(t),l.resolve("newValue"),l=a())},asyncIterableIterator:f}}exports.applyAsyncIterableIteratorToSink=function(r,e){return function(){var o,a=(o=i.mark((function n(){var o,a,u,c,s,l;return i.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,o=!0,a=!1,n.prev=3,c=t(r);case 5:return n.next=7,c.next();case 7:return o=(s=n.sent).done,n.next=11,s.value;case 11:if(l=n.sent,o){n.next=18;break}e.next(l);case 15:o=!0,n.next=5;break;case 18:n.next=24;break;case 20:n.prev=20,n.t0=n.catch(3),a=!0,u=n.t0;case 24:if(n.prev=24,n.prev=25,o||null==c.return){n.next=29;break}return n.next=29,c.return();case 29:if(n.prev=29,!a){n.next=32;break}throw u;case 32:return n.finish(29);case 33:return n.finish(24);case 34:e.complete(),n.next=40;break;case 37:n.prev=37,n.t1=n.catch(0),e.error(n.t1);case 40:case"end":return n.stop()}}),n,null,[[0,37],[3,20,24,34],[25,,29,33]])})),function(){var t=this,r=arguments;return new Promise((function(e,i){var a=o.apply(t,r);function u(t){n(a,e,i,u,c,"next",t)}function c(t){n(a,e,i,u,c,"throw",t)}u(void 0)}))});return function(){return a.apply(this,arguments)}}()(),function(){null==r.return||r.return()}},exports.isAsyncIterable=function(t){return"object"==typeof t&&null!==t&&("AsyncGenerator"===t[Symbol.toStringTag]||Symbol.asyncIterator&&Symbol.asyncIterator in t)},exports.makeAsyncIterableIteratorFromSink=function(t){var r=u(),e=r.pushValue,n=r.asyncIterableIterator,o=function(){},i={next:function(t){e(t)},complete:function(){o(),null==n.return||n.return()},error:function(t){null==n.throw||n.throw(t)}};return o=t(i),n},exports.makePushPullAsyncIterableIterator=u;
"use strict";function t(t){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=t[Symbol.asyncIterator]))return r.call(t);if(Symbol.iterator&&null!=(r=t[Symbol.iterator]))return r.call(t)}throw new TypeError("Object is not async iterable")}function r(t){this.wrapped=t}function e(t){var e,n;function o(e,n){try{var a=t[e](n),u=a.value,c=u instanceof r;Promise.resolve(c?u.wrapped:u).then((function(t){c?o("return"===e?"return":"next",t):i(a.done?"return":"normal",t)}),(function(t){o("throw",t)}))}catch(t){i("throw",t)}}function i(t,r){switch(t){case"return":e.resolve({value:r,done:!0});break;case"throw":e.reject(r);break;default:e.resolve({value:r,done:!1})}(e=e.next)?o(e.key,e.arg):n=null}this._invoke=function(t,r){return new Promise((function(i,a){var u={key:t,arg:r,resolve:i,reject:a,next:null};n?n=n.next=u:(e=n=u,o(t,r))}))},"function"!=typeof t.return&&(this.return=void 0)}function n(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)};var o,i=(function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof f?r:f).prototype),i=new L(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=x(a,e);if(u){if(u===l)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function p(){}var v={};v[o]=function(){return this};var y=Object.getPrototypeOf,d=y&&y(y(E([])));d&&d!==r&&e.call(d,o)&&(v=d);var m=p.prototype=f.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function g(t,r){var n;this._invoke=function(o,i){function a(){return new r((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&e.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,x(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=m.constructor=p,p.constructor=h,h.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new g(c(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=E,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=e.call(i,"catchLoc"),c=e.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),l},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),l}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:E(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}(o={exports:{}}),o.exports);function a(){var t={};return t.promise=new Promise((function(r,e){t.resolve=r,t.reject=e})),t}var u=Symbol(),c=Symbol();function s(){var t,n,o,s,l=!0,f=[],h=a(),p=a(),v=(o=i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(f.length>0)){t.next=6;break}return t.next=4,f.shift();case 4:t.next=11;break;case 6:return t.next=8,new r(Promise.race([h.promise,p.promise]));case 8:if(t.sent!==u){t.next=11;break}return t.abrupt("break",13);case 11:t.next=0;break;case 13:case"end":return t.stop()}}),t)})),s=function(){return new e(o.apply(this,arguments))},function(){return s.apply(this,arguments)})(),y=null==(t=v.return)?void 0:t.bind(v);v.return=function(){var t;l=!1,p.resolve(u);for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return null!=(t=null==y?void 0:y.apply(void 0,e))?t:Promise.resolve({done:!0,value:void 0})};var d=null==(n=v.throw)?void 0:n.bind(v);return v.throw=function(){var t;l=!1,p.resolve(u);for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return null!=(t=null==d?void 0:d.apply(void 0,e))?t:Promise.resolve({done:!0,value:void 0})},{pushValue:function(t){!1!==l&&(f.push(t),h.resolve(c),h=a())},asyncIterableIterator:v}}exports.applyAsyncIterableIteratorToSink=function(r,e){return function(){var o,a=(o=i.mark((function n(){var o,a,u,c,s,l;return i.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,o=!0,a=!1,n.prev=3,c=t(r);case 5:return n.next=7,c.next();case 7:return o=(s=n.sent).done,n.next=11,s.value;case 11:if(l=n.sent,o){n.next=18;break}e.next(l);case 15:o=!0,n.next=5;break;case 18:n.next=24;break;case 20:n.prev=20,n.t0=n.catch(3),a=!0,u=n.t0;case 24:if(n.prev=24,n.prev=25,o||null==c.return){n.next=29;break}return n.next=29,c.return();case 29:if(n.prev=29,!a){n.next=32;break}throw u;case 32:return n.finish(29);case 33:return n.finish(24);case 34:e.complete(),n.next=40;break;case 37:n.prev=37,n.t1=n.catch(0),e.error(n.t1);case 40:case"end":return n.stop()}}),n,null,[[0,37],[3,20,24,34],[25,,29,33]])})),function(){var t=this,r=arguments;return new Promise((function(e,i){var a=o.apply(t,r);function u(t){n(a,e,i,u,c,"next",t)}function c(t){n(a,e,i,u,c,"throw",t)}u(void 0)}))});return function(){return a.apply(this,arguments)}}()(),function(){null==r.return||r.return()}},exports.isAsyncIterable=function(t){return"object"==typeof t&&null!==t&&("AsyncGenerator"===t[Symbol.toStringTag]||Symbol.asyncIterator&&Symbol.asyncIterator in t)},exports.makeAsyncIterableIteratorFromSink=function(t){var r=s(),e=r.pushValue,n=r.asyncIterableIterator,o=function(){},i={next:function(t){e(t)},complete:function(){o(),null==n.return||n.return()},error:function(t){null==n.throw||n.throw(t)}};return o=t(i),n},exports.makePushPullAsyncIterableIterator=s;
//# sourceMappingURL=push-pull-async-iterable-iterator.cjs.production.min.js.map

@@ -928,2 +928,5 @@ function _asyncIterator(iterable) {

}
var SYMBOL_FINISHED = /*#__PURE__*/Symbol();
var SYMBOL_NEW_VALUE = /*#__PURE__*/Symbol();
/**

@@ -937,3 +940,2 @@ * makePushPullAsyncIterableIterator

function makePushPullAsyncIterableIterator() {

@@ -944,7 +946,8 @@ var _asyncIterableIterato, _asyncIterableIterato2;

var values = [];
var d = createDeferred();
var newValueD = createDeferred();
var finishedD = createDeferred();
var asyncIterableIterator = function () {
var _PushPullAsyncIterableIterator = _wrapAsyncGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
var res;
var result;
return runtime_1.wrap(function _callee$(_context) {

@@ -954,6 +957,2 @@ while (1) {

case 0:
if (!isRunning) {
_context.next = 13;
break;
}

@@ -974,8 +973,8 @@ if (!(values.length > 0)) {

_context.next = 8;
return _awaitAsyncGenerator(d.promise);
return _awaitAsyncGenerator(Promise.race([newValueD.promise, finishedD.promise]));
case 8:
res = _context.sent;
result = _context.sent;
if (!(res === "finished")) {
if (!(result === SYMBOL_FINISHED)) {
_context.next = 11;

@@ -985,3 +984,3 @@ break;

return _context.abrupt("return");
return _context.abrupt("break", 13);

@@ -1014,4 +1013,4 @@ case 11:

values.push(value);
d.resolve("newValue");
d = createDeferred();
newValueD.resolve(SYMBOL_NEW_VALUE);
newValueD = createDeferred();
} // We monkey patch the original generator for clean-up

@@ -1026,3 +1025,3 @@

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);

@@ -1045,3 +1044,3 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);

@@ -1048,0 +1047,0 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

{
"version": "2.0.0",
"version": "2.0.1",
"license": "MIT",

@@ -44,4 +44,4 @@ "main": "dist/index.js",

"@size-limit/preset-small-lib": "4.9.1",
"@types/zen-observable": "0.8.1",
"husky": "4.3.5",
"@types/zen-observable": "0.8.2",
"husky": "4.3.6",
"size-limit": "4.9.1",

@@ -55,5 +55,5 @@ "tsdx": "0.14.1",

"**/typescript": "4.1.3",
"**/@typescript-eslint/eslint-plugin": "4.9.1",
"**/@typescript-eslint/parser": "4.9.1"
"**/@typescript-eslint/eslint-plugin": "4.11.1",
"**/@typescript-eslint/parser": "4.11.1"
}
}

@@ -23,2 +23,5 @@ type Deferred<T> = {

const SYMBOL_FINISHED = Symbol();
const SYMBOL_NEW_VALUE = Symbol();
/**

@@ -37,3 +40,4 @@ * makePushPullAsyncIterableIterator

let d = createDeferred<"finished" | "newValue">();
let newValueD = createDeferred<typeof SYMBOL_NEW_VALUE>();
let finishedD = createDeferred<typeof SYMBOL_FINISHED>();

@@ -43,9 +47,13 @@ const asyncIterableIterator = (async function* PushPullAsyncIterableIterator(): AsyncIterableIterator<

> {
while (isRunning) {
while (true) {
if (values.length > 0) {
yield values.shift()!;
} else {
const res = await d.promise;
if (res === "finished") {
return;
const result = await Promise.race([
newValueD.promise,
finishedD.promise
]);
if (result === SYMBOL_FINISHED) {
break;
}

@@ -63,4 +71,4 @@ }

values.push(value);
d.resolve("newValue");
d = createDeferred();
newValueD.resolve(SYMBOL_NEW_VALUE);
newValueD = createDeferred();
}

@@ -76,3 +84,3 @@

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);
return (

@@ -90,3 +98,3 @@ originalReturn?.(...args) ??

isRunning = false;
d.resolve("finished");
finishedD.resolve(SYMBOL_FINISHED);
return (

@@ -93,0 +101,0 @@ originalThrow?.(...args) ??

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet