1 line
1.5 KiB
JavaScript
1 line
1.5 KiB
JavaScript
(()=>{var e={758:(e,t,i)=>{"use strict";const r=i(738);const pLimit=e=>{if(!((Number.isInteger(e)||e===Infinity)&&e>0)){throw new TypeError("Expected `concurrency` to be a number from 1 and up")}const t=new r;let i=0;const next=()=>{i--;if(t.size>0){t.dequeue()()}};const run=async(e,t,...r)=>{i++;const s=(async()=>e(...r))();t(s);try{await s}catch{}next()};const enqueue=(r,s,...n)=>{t.enqueue(run.bind(null,r,s,...n));(async()=>{await Promise.resolve();if(i<e&&t.size>0){t.dequeue()()}})()};const generator=(e,...t)=>new Promise((i=>{enqueue(e,i,...t)}));Object.defineProperties(generator,{activeCount:{get:()=>i},pendingCount:{get:()=>t.size},clearQueue:{value:()=>{t.clear()}}});return generator};e.exports=pLimit},738:e=>{class Node{constructor(e){this.value=e;this.next=undefined}}class Queue{constructor(){this.clear()}enqueue(e){const t=new Node(e);if(this._head){this._tail.next=t;this._tail=t}else{this._head=t;this._tail=t}this._size++}dequeue(){const e=this._head;if(!e){return}this._head=this._head.next;this._size--;return e.value}clear(){this._head=undefined;this._tail=undefined;this._size=0}get size(){return this._size}*[Symbol.iterator](){let e=this._head;while(e){yield e.value;e=e.next}}}e.exports=Queue}};var t={};function __nccwpck_require__(i){var r=t[i];if(r!==undefined){return r.exports}var s=t[i]={exports:{}};var n=true;try{e[i](s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete t[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(758);module.exports=i})(); |