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
/** | |
* @template {(...args: any[]) => Promise<any>} T | |
* @param {T} fn | |
* @returns {(...args: Parameters<T>) => Promise<ReturnType<T>|void>} | |
*/ | |
export const wrap = (fn) => (...args) => fn(...args).catch(args[2]); |
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
/*! | |
* Destroy all open connections so a server can close. | |
* Inspired by https://github.com/marten-de-vries/killable | |
*/ | |
import http from 'http'; | |
import { Socket } from 'net'; | |
// Set of open sockets | |
const sockets: Set<Socket> = new Set(); |
NewerOlder