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
export class LighweightCache { | |
entries: CacheEntry[]; | |
size: number; | |
ttl: number; | |
constructor(size: number, ttl: number) { | |
this.entries = []; | |
this.size = size; | |
this.ttl = ttl; | |
} |
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
class pausableInterval { | |
constructor(callback, intervalMS, instantStart = true) { | |
this.callback = callback; | |
this.intervalMS = intervalMS; | |
this.lastInterval = -Infinity; | |
this.remainingMS = 0; | |
this.paused = false; | |
this.intervalId = null; | |
if (instantStart) { |
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 EventEmitter = require('events'); | |
const { randomUUID } = require('crypto'); | |
class AsyncQueueManager { | |
constructor(maxSimultaneousCalls = 1) { | |
this.maxSimultaneousCalls = maxSimultaneousCalls; | |
this.currentSimultaneousCalls = 0; | |
this.queue = []; | |
this.eventEmitter = new EventEmitter(); | |
} |
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 hexToHashtagNotation = (hexColor) => { | |
let splittedColor = { | |
red : (hexColor >> 16) & 0xFF, | |
green : (hexColor >> 8) & 0xFF, | |
blue : hexColor & 0xFF, | |
} | |
return Object.values(splittedColor).reduce((hexString, channelValue) => { | |
const colorValueString = channelValue.toString(16).toUpperCase(); | |
hexString += colorValueString.length === 1 ? `0${colorValueString}` : `${colorValueString}`; |