scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
19 lines (15 loc) • 383 B
text/typescript
type AsyncCallback<T> = () => Promise<T>;
export const createAsyncProxy = <T>(asyncCallback: AsyncCallback<T>): AsyncCallback<T> => {
let promise: Promise<T> | null = null;
return async (): Promise<T> => {
if (promise) {
return promise;
}
try {
promise = asyncCallback();
return await promise;
} finally {
promise = null;
}
};
};