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 degreesToRadians = (degrees: number) => ((Math.PI / 180) * degrees); | |
| const percentToRadians = (percent: number) => degreesToRadians(percent * 360 / 100 + 270); | |
| const copy = <T>(array: T[]) => [...array]; | |
| // referencial transparent law corruption | |
| const aument = (f: number[], v: number) => () => f[0] += v; | |
| // tslint:disable-next-line:no-console | |
| const log = <T>(...m: T[]) => console.log(...m); | |
| type ArcDescription = { | |
| context: CanvasRenderingContext2D |
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 fs = require('fs') | |
| const server = require('http').createServer() | |
| const io = require('socket.io')(server) | |
| const EventEmitter = require('events') | |
| const serial = (time) => { | |
| const emitter = new EventEmitter() | |
| const dummy = () => { | |
| const stop = setInterval(() => { | |
| emitter.emit('data', (Math.random() * 1e32).toString(36) + '\r') |
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 socket = require('socket.io-client')('http://localhost:3000') | |
| const readline = require('readline') | |
| const rl = readline.createInterface({ | |
| input: process.stdin | |
| , output: process.stdout | |
| , terminal: false | |
| }) | |
| socket.on('connect', () => console.log('connect')) |
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
| interface MongoClientError extends Error { | |
| kind: string | |
| } | |
| export const mongooseErrorHandler = (error: MongoClientError, req: Request, res: Response, next: NextFunction): void => { | |
| if (error.kind === 'ObjectId') { | |
| res | |
| .status(400) | |
| .json({ | |
| errors: [{ |
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 packageLength = (args, padding) => args.reduce((len, arg) => { | |
| let l = len | |
| l += padding + arg.length | |
| return l | |
| }, 1) | |
| const convertArgsToBuffer = (args) => args.map((arg) => Buffer.from(arg)) | |
| const createPackage = (plen, padding, bargs) => { | |
| const pack = Buffer.allocUnsafe(plen) |
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 encode = require('./encode') | |
| const decode = require('./decode') | |
| const createSerializer = (padding) => ({ | |
| encode: encode(padding) | |
| , decode: decode(padding) | |
| }) | |
| module.exports = createSerializer(4) |