UNPKG

@klodianimeri/channeljs

Version:

Javascript channel like communication.

3 lines (2 loc) 1.96 kB
function e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function r(e,r){if(!{}.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}var t=0;function n(e){return"__private_"+t+++"_"+e}function o(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(n)return(n=n.call(r)).next.bind(n);if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r)return e(r,t);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){n&&(r=n);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}void 0===Promise.withResolvers&&(Promise.withResolvers=function(){var e,r;return{promise:new Promise(function(t,n){e=t,r=n}),resolve:e,reject:r}});var i=/*#__PURE__*/n("items"),a=/*#__PURE__*/function(){function e(){Object.defineProperty(this,i,{writable:!0,value:new Set})}var t=e.prototype;return t.send=function(e){for(var t,n=o(r(this,i)[i]);!(t=n()).done;){var a=t.value;a.push(Promise.withResolvers()),a[a.length-2].resolve({done:!1,value:e})}},t.close=function(){for(var e,t=o(r(this,i)[i]);!(e=t()).done;){var n=e.value;n[n.length-1].resolve({done:!0,value:void 0}),r(this,i)[i].delete(n)}},t[Symbol.asyncIterator]=function(){var e=new Array(Promise.withResolvers()),t=this;return r(t,i)[i].add(e),{next:function(){try{return e.length>1&&e.shift(),Promise.resolve(e[0].promise)}catch(e){return Promise.reject(e)}},return:function(n){return r(t,i)[i].delete(e),Promise.resolve({done:!0,value:n})}}},e}();export{a as Channel}; //# sourceMappingURL=index.module.js.map