export class Debouncer { static promise < ArgumentsType extends unknown [ ] , ReturnType > ( fn ) { let currentPromise ; return async ( ... arguments_ ) => { if ( currentPromise ) { return currentPromise ; } try { currentPromise = fn . apply ( this , arguments_ ) ; return await currentPromise ; } finally { currentPromise = undefined ; } } ; } }