Skip to content

Instantly share code, notes, and snippets.

@alex-taxiera
alex-taxiera / sendTyping.js
Created August 26, 2019 18:09
Simple typing management for d.js v12
const {
TextChannel,
DMChannel
} = require('discord.js')
function isTextBasedChannel (channel) {
return channel instanceof TextChannel || channel instanceof DMChannel
}
module.exports = function (channel, limit) {
@alex-taxiera
alex-taxiera / child.js
Created June 4, 2019 01:19
Simple Node Child Process Broadcasting
process.on('message', (message) => {
console.log('child received:', message)
process.send(message) // echo the message back to parent
})
@alex-taxiera
alex-taxiera / ExtendedMap.js
Last active May 15, 2019 02:07
A Map class with some extra features for iterating.
class ExtendedMap extends Map {
constructor (iter) {
super(iter)
this._array = null
}
set (key, val) {
this._array = null
return super.set(key, val)
}
@alex-taxiera
alex-taxiera / job-queue.ts
Last active April 11, 2021 04:52
Promise Queue classes for async jobs
export type JobFunction<T> = (...args: Array<any>) => Promise<T> // eslint-disable-line @typescript-eslint/no-explicit-any
export type JobResult<T> = {
id: number
priority?: number
data: T
}
export type Job<T> = {
id: number
priority?: number
handlePromise: {