This file contains 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
/** | |
* Rejects any promise after the specified amount of time (in ms). Useful for | |
* timing out long-running operations that didn't resolve in time. | |
* @param promise Promise to race against. | |
* @param timeout Time in ms to wait until rejecting the promise unless it | |
* resolved in time. | |
* @return A new promise that either behaves like the original promise or | |
* rejects after the specified amount of time. | |
*/ | |
export const racePromise = async <T>(promise: Promise<T>, timeout: number) => { |
This file contains 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 TcpConnection : public std::enable_shared_from_this<TcpConnection> { | |
public: | |
auto start() -> void { | |
// (1) Redudant declaration of paramters and types | |
asio::async_write( | |
Socket, asio::buffer(Response), | |
[This = shared_from_this()](const asio::error_code &ErrorCode, | |
size_t TransferredBytes) -> void { | |
This->handleWrite(ErrorCode, TransferredBytes); | |
}); |
This file contains 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
type Class<T = unknown, Arguments extends unknown[] = unknown[]> = new ( | |
...args: Arguments | |
) => T; | |
const nameof = <T>(name: keyof T) => name; | |
type Builder<T> = { | |
[K in keyof Omit< | |
T, | |
{ |
This file contains 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
/* eslint-disable no-console */ | |
import {isEqual, isPlainObject} from 'lodash'; | |
import {useEffect, useRef} from 'react'; | |
type Options = Partial<{ | |
/** | |
* String prefix used to distinguish multiple groups. | |
*/ | |
groupName: string; | |
/** |