blob: 57de2b0ae8e0e83e8c2a8c08634340bb68611b31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import delegate from './delegate.js';
// This type isn't exported as a declaration, so it needs to be duplicated above
async function oneEvent(selector, type, options = {}) {
return new Promise(resolve => {
options.once = true;
if (options.signal?.aborted) {
resolve(undefined);
}
options.signal?.addEventListener('abort', () => {
resolve(undefined);
});
delegate(selector, type, resolve, options);
});
}
export default oneEvent;
|