diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-25 00:05:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 00:05:48 +0200 |
commit | e9fa6b87cea7f564d69f2918b4811a570a770f73 (patch) | |
tree | 9e64954b29a53bc2de1d7f95f8ba6afc7c327155 /cli/js/lib.deno.ns.d.ts | |
parent | 824329f0daa4dfada11ccc4c15a7db6c1886c45f (diff) |
stabilize Deno.iter() and Deno.iterSync() (#4890)
Diffstat (limited to 'cli/js/lib.deno.ns.d.ts')
-rw-r--r-- | cli/js/lib.deno.ns.d.ts | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 696844f94..c40e42b8c 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -576,60 +576,68 @@ declare namespace Deno { */ export function copy(dst: Writer, src: Reader): Promise<number>; - /** **UNSTABLE**: new API, yet to be vetted - * Turns a Reader, `r`, into an async iterator. + /** Turns a Reader, `r`, into an async iterator. * - * let f = await open("/etc/passwd"); - * for await (const chunk of iter(f)) { + * let f = await Deno.open("/etc/passwd"); + * for await (const chunk of Deno.iter(f)) { * console.log(chunk); * } * f.close(); * * Second argument can be used to tune size of a buffer. - * Default size of the buffer is 1024 bytes. + * Default size of the buffer is 32kB. * - * let f = await open("/etc/passwd"); - * for await (const chunk of iter(f, 1024 * 1024)) { + * let f = await Deno.open("/etc/passwd"); + * const iter = Deno.iter(f, { + * bufSize: 1024 * 1024 + * }); + * for await (const chunk of iter) { * console.log(chunk); * } * f.close(); * - * Iterator uses internal buffer of fixed size for efficiency returning - * a view on that buffer on each iteration. It it therefore callers - * responsibility to copy contents of the buffer if needed; otherwise + * Iterator uses an internal buffer of fixed size for efficiency; it returns + * a view on that buffer on each iteration. It is therefore caller's + * responsibility to copy contents of the buffer if needed; otherwise the * next iteration will overwrite contents of previously returned chunk. */ export function iter( r: Reader, - bufSize?: number + options?: { + bufSize?: number; + } ): AsyncIterableIterator<Uint8Array>; - /** **UNSTABLE**: new API, yet to be vetted - * Turns a SyncReader, `r`, into an iterator. + /** Turns a SyncReader, `r`, into an iterator. * - * let f = openSync("/etc/passwd"); - * for (const chunk of iterSync(reader)) { + * let f = Deno.openSync("/etc/passwd"); + * for (const chunk of Deno.iterSync(reader)) { * console.log(chunk); * } * f.close(); * * Second argument can be used to tune size of a buffer. - * Default size of the buffer is 1024 bytes. + * Default size of the buffer is 32kB. * - * let f = openSync("/etc/passwd"); - * for (const chunk of iterSync(reader, 1024 * 1024)) { + * let f = await Deno.open("/etc/passwd"); + * const iter = Deno.iterSync(f, { + * bufSize: 1024 * 1024 + * }); + * for (const chunk of iter) { * console.log(chunk); * } - * f.close() + * f.close(); * - * Iterator uses internal buffer of fixed size for efficiency returning - * a view on that buffer on each iteration. It it therefore callers - * responsibility to copy contents of the buffer if needed; otherwise + * Iterator uses an internal buffer of fixed size for efficiency; it returns + * a view on that buffer on each iteration. It is therefore caller's + * responsibility to copy contents of the buffer if needed; otherwise the * next iteration will overwrite contents of previously returned chunk. */ export function iterSync( r: SyncReader, - bufSize?: number + options?: { + bufSize?: number; + } ): IterableIterator<Uint8Array>; /** Synchronously open a file and return an instance of `Deno.File`. The |