{"ast":null,"code":"'use strict';\n\nconst kDone = Symbol('kDone');\nconst kRun = Symbol('kRun');\n\n/**\n * A very simple job queue with adjustable concurrency. Adapted from\n * https://github.com/STRML/async-limiter\n */\nclass Limiter {\n /**\n * Creates a new `Limiter`.\n *\n * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed\n * to run concurrently\n */\n constructor(concurrency) {\n this[kDone] = () => {\n this.pending--;\n this[kRun]();\n };\n this.concurrency = concurrency || Infinity;\n this.jobs = [];\n this.pending = 0;\n }\n\n /**\n * Adds a job to the queue.\n *\n * @param {Function} job The job to run\n * @public\n */\n add(job) {\n this.jobs.push(job);\n this[kRun]();\n }\n\n /**\n * Removes a job from the queue and runs it if possible.\n *\n * @private\n */\n [kRun]() {\n if (this.pending === this.concurrency) return;\n if (this.jobs.length) {\n const job = this.jobs.shift();\n this.pending++;\n job(this[kDone]);\n }\n }\n}\nmodule.exports = Limiter;","map":{"version":3,"names":["kDone","Symbol","kRun","Limiter","constructor","concurrency","pending","Infinity","jobs","add","job","push","length","shift","module","exports"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/isomorphic-ws/node_modules/ws/lib/limiter.js"],"sourcesContent":["'use strict';\n\nconst kDone = Symbol('kDone');\nconst kRun = Symbol('kRun');\n\n/**\n * A very simple job queue with adjustable concurrency. Adapted from\n * https://github.com/STRML/async-limiter\n */\nclass Limiter {\n /**\n * Creates a new `Limiter`.\n *\n * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed\n * to run concurrently\n */\n constructor(concurrency) {\n this[kDone] = () => {\n this.pending--;\n this[kRun]();\n };\n this.concurrency = concurrency || Infinity;\n this.jobs = [];\n this.pending = 0;\n }\n\n /**\n * Adds a job to the queue.\n *\n * @param {Function} job The job to run\n * @public\n */\n add(job) {\n this.jobs.push(job);\n this[kRun]();\n }\n\n /**\n * Removes a job from the queue and runs it if possible.\n *\n * @private\n */\n [kRun]() {\n if (this.pending === this.concurrency) return;\n\n if (this.jobs.length) {\n const job = this.jobs.shift();\n\n this.pending++;\n job(this[kDone]);\n }\n }\n}\n\nmodule.exports = Limiter;\n"],"mappings":"AAAA,YAAY;;AAEZ,MAAMA,KAAK,GAAGC,MAAM,CAAC,OAAO,CAAC;AAC7B,MAAMC,IAAI,GAAGD,MAAM,CAAC,MAAM,CAAC;;AAE3B;AACA;AACA;AACA;AACA,MAAME,OAAO,CAAC;EACZ;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,WAAW,EAAE;IACvB,IAAI,CAACL,KAAK,CAAC,GAAG,MAAM;MAClB,IAAI,CAACM,OAAO,EAAE;MACd,IAAI,CAACJ,IAAI,CAAC,CAAC,CAAC;IACd,CAAC;IACD,IAAI,CAACG,WAAW,GAAGA,WAAW,IAAIE,QAAQ;IAC1C,IAAI,CAACC,IAAI,GAAG,EAAE;IACd,IAAI,CAACF,OAAO,GAAG,CAAC;EAClB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEG,GAAGA,CAACC,GAAG,EAAE;IACP,IAAI,CAACF,IAAI,CAACG,IAAI,CAACD,GAAG,CAAC;IACnB,IAAI,CAACR,IAAI,CAAC,CAAC,CAAC;EACd;;EAEA;AACF;AACA;AACA;AACA;EACE,CAACA,IAAI,IAAI;IACP,IAAI,IAAI,CAACI,OAAO,KAAK,IAAI,CAACD,WAAW,EAAE;IAEvC,IAAI,IAAI,CAACG,IAAI,CAACI,MAAM,EAAE;MACpB,MAAMF,GAAG,GAAG,IAAI,CAACF,IAAI,CAACK,KAAK,CAAC,CAAC;MAE7B,IAAI,CAACP,OAAO,EAAE;MACdI,GAAG,CAAC,IAAI,CAACV,KAAK,CAAC,CAAC;IAClB;EACF;AACF;AAEAc,MAAM,CAACC,OAAO,GAAGZ,OAAO","ignoreList":[]},"metadata":{},"sourceType":"script","externalDependencies":[]}