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 { createServer, Socket } from "net"; | |
| // Promisified socket.write(). | |
| const write = (socket: Socket, data: Buffer | string) => | |
| new Promise((resolve, reject) => | |
| socket.write(data as Buffer, (error: Error | undefined) => { | |
| if (error) { | |
| reject(); | |
| } else { | |
| resolve(); |
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
| var trimCanvas = (function() { | |
| function rowBlank(imageData, width, y) { | |
| for (var x = 0; x < width; ++x) { | |
| if (imageData.data[y * width * 4 + x * 4 + 3] !== 0) return false; | |
| } | |
| return true; | |
| } | |
| function columnBlank(imageData, width, x, top, bottom) { | |
| for (var y = top; y < bottom; ++y) { |