mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: add std/signal/mod.ts (#3913)
This commit is contained in:
parent
d9c84eb91e
commit
5a8ba3b114
4 changed files with 87 additions and 4 deletions
5
cli/js/lib.deno.ns.d.ts
vendored
5
cli/js/lib.deno.ns.d.ts
vendored
|
@ -2146,14 +2146,15 @@ declare namespace Deno {
|
|||
* SignalStream represents the stream of signals, implements both
|
||||
* AsyncIterator and PromiseLike
|
||||
*/
|
||||
export class SignalStream implements AsyncIterator<void>, PromiseLike<void> {
|
||||
export class SignalStream
|
||||
implements AsyncIterableIterator<void>, PromiseLike<void> {
|
||||
constructor(signal: typeof Deno.Signal);
|
||||
then<T, S>(
|
||||
f: (v: void) => T | Promise<T>,
|
||||
g?: (v: void) => S | Promise<S>
|
||||
): Promise<T | S>;
|
||||
next(): Promise<IteratorResult<void>>;
|
||||
[Symbol.asyncIterator](): AsyncIterator<void>;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<void>;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,8 @@ export const signals = {
|
|||
|
||||
/** SignalStream represents the stream of signals, implements both
|
||||
* AsyncIterator and PromiseLike */
|
||||
export class SignalStream implements AsyncIterator<void>, PromiseLike<void> {
|
||||
export class SignalStream
|
||||
implements AsyncIterableIterator<void>, PromiseLike<void> {
|
||||
private rid: number;
|
||||
/** The promise of polling the signal,
|
||||
* resolves with false when it receives signal,
|
||||
|
@ -134,7 +135,7 @@ export class SignalStream implements AsyncIterator<void>, PromiseLike<void> {
|
|||
return { done: await this.pollingPromise, value: undefined };
|
||||
}
|
||||
|
||||
[Symbol.asyncIterator](): AsyncIterator<void> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<void> {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue