This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ( | |
k: infer I | |
) => void | |
? I | |
: never; | |
type UnionToTuple<U> = UnionToIntersection< | |
U extends any ? (u: U) => void : never | |
> extends (v: infer V) => void | |
? [...UnionToTuple<Exclude<U, V>>, V] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createWriteStream } = require('fs'); | |
const { join } = require('path'); | |
const { EOL } = require('os'); | |
const logLevels = { | |
off: -1, | |
debug: 0, | |
info: 1, | |
warn: 2, | |
error: 3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
class Queue { | |
constructor(executor) { | |
this._queue = []; | |
this._commandQueue = []; | |
const enqueue = (item) => { | |
this._queue.push(item); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function mapAsync(iterable, callback, concurrency) { | |
if (!concurrency || !Number.isInteger(concurrency)) { | |
throw new Error('"Concurrency" param must be a positive integer.'); | |
} | |
// Split the iterable into a set of chunks. The execution of chunks is then | |
// done in series to enforce the provided concurrency level. | |
let slices = []; | |
for (const [index, item] of iterable.entries()) { |