!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).responseIterator=n()}(this,(function(){"use strict";function e(e){var n,r,o,t=e[Symbol.asyncIterator]();return n={next:function(){return t.next()}},r=Symbol.asyncIterator,o=function(){return this},r in n?Object.defineProperty(n,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[r]=o,n}var n="undefined"!=typeof Symbol&&Symbol.asyncIterator;function r(e){var r=function(e){if(!a)return s.length?s.shift()[0]({value:e,done:!1}):void f.push(e)},o=function(e){a=e,s.slice().forEach((function(n){n[1](e)})),!i||i()},t=function(){u=!0,s.slice().forEach((function(e){e[0]({value:void 0,done:!0})})),!i||i()},i=null,a=null,u=!1,f=[],s=[];i=function(){i=null,e.removeListener("data",r),e.removeListener("error",o),e.removeListener("end",t),e.removeListener("finish",t),e.removeListener("close",t)},e.on("data",r),e.on("error",o),e.on("end",t),e.on("finish",t),e.on("close",t);var l={next:function(){return new Promise((function(e,n){return a?n(a):f.length?e({value:f.shift(),done:!1}):u?e({value:void 0,done:!0}):void s.push([e,n])}))}};return n&&(l[Symbol.asyncIterator]=function(){return this}),l}var o="undefined"!=typeof Symbol&&Symbol.asyncIterator;var t="undefined"!=typeof Symbol&&Symbol.asyncIterator;function i(e){var n={next:function(){return e.read()}};return t&&(n[Symbol.asyncIterator]=function(){return this}),n}var a="undefined"!=typeof Symbol&&Symbol.asyncIterator;return function(n){if(void 0===n)throw new Error("Missing response for responseIterator");var t,u,f,s=n;if(n.body?s=n.body:n.data?s=n.data:n._bodyBlob&&(s=n._bodyBlob),a&&s[Symbol.asyncIterator])return e(s);if(s.getReader)return i(s.getReader());if(s.stream)return i(s.stream().getReader());if(s.arrayBuffer)return t=s.arrayBuffer(),u=!1,f={next:function(){return u?Promise.resolve({value:void 0,done:!0}):(u=!0,new Promise((function(e,n){t.then((function(n){e({value:n,done:!1})})).catch(n)})))}},o&&(f[Symbol.asyncIterator]=function(){return this}),f;if(s.pipe)return r(s);throw new Error("Unknown body type for responseIterator. Maybe you are not passing a streamable response")}})); //# sourceMappingURL=response-iterator.min.js.map