mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
refactor(cli/js/net): Cleanup iterable APIs (#4236)
Listener and UDPConn are AsyncIterables instead of AsyncIterators. The [Symbol.asyncIterator]()s are defined as generators and the next() methods are gone. "Listener/Socket has been closed" errors are now BadResource.
This commit is contained in:
parent
8078d976d2
commit
55119aaee2
5 changed files with 44 additions and 56 deletions
4
cli/js/lib.deno.ns.d.ts
vendored
4
cli/js/lib.deno.ns.d.ts
vendored
|
@ -1522,7 +1522,7 @@ declare namespace Deno {
|
|||
/** **UNSTABLE**: new API, yet to be vetted.
|
||||
*
|
||||
* A generic transport listener for message-oriented protocols. */
|
||||
export interface UDPConn extends AsyncIterator<[Uint8Array, Addr]> {
|
||||
export interface UDPConn extends AsyncIterable<[Uint8Array, Addr]> {
|
||||
/** **UNSTABLE**: new API, yet to be vetted.
|
||||
*
|
||||
* Waits for and resolves to the next message to the `UDPConn`. */
|
||||
|
@ -1542,7 +1542,7 @@ declare namespace Deno {
|
|||
}
|
||||
|
||||
/** A generic network listener for stream-oriented protocols. */
|
||||
export interface Listener extends AsyncIterator<Conn> {
|
||||
export interface Listener extends AsyncIterable<Conn> {
|
||||
/** Waits for and resolves to the next connection to the `Listener`. */
|
||||
accept(): Promise<Conn>;
|
||||
/** Close closes the listener. Any pending accept promises will be rejected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue