Created
March 29, 2020 01:56
-
-
Save mattpodwysocki/7333d774dab3a3278805b4b3b2ed7d5d to your computer and use it in GitHub Desktop.
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
import { AsyncIterableX } from './asynciterablex'; | |
import { throwIfAborted, AbortError } from '../aborterror'; | |
export class NeverAsyncIterable extends AsyncIterableX<never> { | |
constructor() { | |
super(); | |
} | |
async *[Symbol.asyncIterator](signal?: AbortSignal) { | |
throwIfAborted(signal); | |
await new Promise<never>((_, reject) => { | |
if (signal) { | |
signal.addEventListener('abort', () => reject(new AbortError()), { once: true }); | |
} | |
}); | |
} | |
} | |
export function never(): AsyncIterableX<never> { | |
return new NeverAsyncIterable(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment