This file contains hidden or 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 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: { |
This file contains hidden or 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 ExtendedMap extends Map { | |
| constructor (iter) { | |
| super(iter) | |
| this._array = null | |
| } | |
| set (key, val) { | |
| this._array = null | |
| return super.set(key, val) | |
| } |
This file contains hidden or 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
| process.on('message', (message) => { | |
| console.log('child received:', message) | |
| process.send(message) // echo the message back to parent | |
| }) |
This file contains hidden or 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 { | |
| TextChannel, | |
| DMChannel | |
| } = require('discord.js') | |
| function isTextBasedChannel (channel) { | |
| return channel instanceof TextChannel || channel instanceof DMChannel | |
| } | |
| module.exports = function (channel, limit) { |
This file contains hidden or 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
| // request('https://www.google.com').then(console.log) | |
| const https = require('https') | |
| const http = require('http') | |
| const { URL } = require('url') | |
| const requesters = { | |
| 'http:': http, | |
| 'https:': https | |
| } |
This file contains hidden or 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
| import Upload from './Upload.js' | |
| export default class Artist { | |
| constructor (canvas) { | |
| this.canvas = canvas | |
| this.ctx = canvas.getContext('2d') | |
| } | |
| getLink () { | |
| return this.canvas.toDataURL() |
This file contains hidden or 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') | |
| class PriorityJobQueue extends EventEmitter { | |
| constructor (levels, ...rest) { | |
| super(...rest) | |
| this.queues = new Array(levels).fill([]) | |
| this.currentJob = null | |
| this.totalJobs = 0 | |
| } |
This file contains hidden or 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 Project { | |
| private _workItems: WorkItem[] = []; | |
| public get workItems(): WorkItem[] { | |
| return this._workItems; | |
| } | |
| public addWorkItem(item: WorkItem): number { | |
| const id = this._workItems.push(item); | |
| item.id = id; |
This file contains hidden or 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
| import express, { RequestHandler, Response } from 'express' | |
| import bodyParser from 'body-parser' | |
| import cors from 'cors' | |
| interface Client { | |
| id: string | |
| res: Response | |
| } | |
| interface Item { |
This file contains hidden or 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
| function groupBy <T = unknown> ( | |
| list: Array<T>, | |
| keyGen: (item: T) => string | number, | |
| ): {[k: string]: Array<T>} { | |
| return list.reduce<{[k: string]: Array<T>}>((ax, dx) => { | |
| const key = keyGen(dx) | |
| if (ax[key]) { | |
| ax[key].push(dx) | |
| } else { |
OlderNewer