mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
Remove doc strings from cli/js TS files (#4329)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
This commit is contained in:
parent
3ac642c183
commit
e435c2be15
87 changed files with 0 additions and 2025 deletions
79
cli/js/io.ts
79
cli/js/io.ts
|
@ -8,7 +8,6 @@ export type EOF = typeof EOF;
|
|||
|
||||
// Seek whence values.
|
||||
// https://golang.org/pkg/io/#pkg-constants
|
||||
/** **UNSTABLE**: might remove `"SEEK_"` prefix. Might not use all-caps. */
|
||||
export enum SeekMode {
|
||||
SEEK_START = 0,
|
||||
SEEK_CURRENT = 1,
|
||||
|
@ -17,76 +16,21 @@ export enum SeekMode {
|
|||
|
||||
// Reader is the interface that wraps the basic read() method.
|
||||
// https://golang.org/pkg/io/#Reader
|
||||
/** **UNSTABLE**: might make `Reader` into iterator of some sort. */
|
||||
export interface Reader {
|
||||
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
|
||||
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
|
||||
* encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may
|
||||
* use all of `p` as scratch space during the call. If some data is
|
||||
* available but not `p.byteLength` bytes, `read()` conventionally resolves
|
||||
* to what is available instead of waiting for more.
|
||||
*
|
||||
* When `read()` encounters end-of-file condition, it resolves to
|
||||
* `Deno.EOF` symbol.
|
||||
*
|
||||
* When `read()` encounters an error, it rejects with an error.
|
||||
*
|
||||
* Callers should always process the `n` > `0` bytes returned before
|
||||
* considering the `EOF`. Doing so correctly handles I/O errors that happen
|
||||
* after reading some bytes and also both of the allowed EOF behaviors.
|
||||
*
|
||||
* Implementations should not retain a reference to `p`.
|
||||
*/
|
||||
read(p: Uint8Array): Promise<number | EOF>;
|
||||
}
|
||||
|
||||
export interface SyncReader {
|
||||
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
|
||||
* of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
|
||||
* encountered. Even if `read()` returns `n` < `p.byteLength`, it may use
|
||||
* all of `p` as scratch space during the call. If some data is available
|
||||
* but not `p.byteLength` bytes, `read()` conventionally returns what is
|
||||
* available instead of waiting for more.
|
||||
*
|
||||
* When `readSync()` encounters end-of-file condition, it returns `Deno.EOF`
|
||||
* symbol.
|
||||
*
|
||||
* When `readSync()` encounters an error, it throws with an error.
|
||||
*
|
||||
* Callers should always process the `n` > `0` bytes returned before
|
||||
* considering the `EOF`. Doing so correctly handles I/O errors that happen
|
||||
* after reading some bytes and also both of the allowed EOF behaviors.
|
||||
*
|
||||
* Implementations should not retain a reference to `p`.
|
||||
*/
|
||||
readSync(p: Uint8Array): number | EOF;
|
||||
}
|
||||
|
||||
// Writer is the interface that wraps the basic write() method.
|
||||
// https://golang.org/pkg/io/#Writer
|
||||
export interface Writer {
|
||||
/** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
|
||||
* resolves to the number of bytes written from `p` (`0` <= `n` <=
|
||||
* `p.byteLength`) or reject with the error encountered that caused the
|
||||
* write to stop early. `write()` must reject with a non-null error if
|
||||
* would resolve to `n` < `p.byteLength`. `write()` must not modify the
|
||||
* slice data, even temporarily.
|
||||
*
|
||||
* Implementations should not retain a reference to `p`.
|
||||
*/
|
||||
write(p: Uint8Array): Promise<number>;
|
||||
}
|
||||
|
||||
export interface SyncWriter {
|
||||
/** Writes `p.byteLength` bytes from `p` to the underlying data
|
||||
* stream. It returns the number of bytes written from `p` (`0` <= `n`
|
||||
* <= `p.byteLength`) and any error encountered that caused the write to
|
||||
* stop early. `writeSync()` must throw a non-null error if it returns `n` <
|
||||
* `p.byteLength`. `writeSync()` must not modify the slice data, even
|
||||
* temporarily.
|
||||
*
|
||||
* Implementations should not retain a reference to `p`.
|
||||
*/
|
||||
writeSync(p: Uint8Array): number;
|
||||
}
|
||||
|
||||
|
@ -99,16 +43,6 @@ export interface Closer {
|
|||
|
||||
// https://golang.org/pkg/io/#Seeker
|
||||
export interface Seeker {
|
||||
/** Seek sets the offset for the next `read()` or `write()` to offset,
|
||||
* interpreted according to `whence`: `SEEK_START` means relative to the
|
||||
* start of the file, `SEEK_CURRENT` means relative to the current offset,
|
||||
* and `SEEK_END` means relative to the end.
|
||||
*
|
||||
* Seeking to an offset before the start of the file is an error. Seeking to
|
||||
* any positive offset is legal, but the behavior of subsequent I/O operations
|
||||
* on the underlying object is implementation-dependent. It returns the cursor
|
||||
* position.
|
||||
*/
|
||||
seek(offset: number, whence: SeekMode): Promise<number>;
|
||||
}
|
||||
|
||||
|
@ -134,13 +68,6 @@ export interface ReadWriteCloser extends Reader, Writer, Closer {}
|
|||
// https://golang.org/pkg/io/#ReadWriteSeeker
|
||||
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
|
||||
|
||||
/** Copies from `src` to `dst` until either `EOF` is reached on `src` or an
|
||||
* error occurs. It resolves to the number of bytes copied or rejects with
|
||||
* the first error encountered while copying.
|
||||
*
|
||||
* Because `copy()` is defined to read from `src` until `EOF`, it does not
|
||||
* treat an `EOF` from `read()` as an error to be reported.
|
||||
*/
|
||||
// https://golang.org/pkg/io/#Copy
|
||||
export async function copy(dst: Writer, src: Reader): Promise<number> {
|
||||
let n = 0;
|
||||
|
@ -157,12 +84,6 @@ export async function copy(dst: Writer, src: Reader): Promise<number> {
|
|||
return n;
|
||||
}
|
||||
|
||||
/** Turns `r` into async iterator.
|
||||
*
|
||||
* for await (const chunk of toAsyncIterator(reader)) {
|
||||
* console.log(chunk);
|
||||
* }
|
||||
*/
|
||||
export function toAsyncIterator(r: Reader): AsyncIterableIterator<Uint8Array> {
|
||||
const b = new Uint8Array(1024);
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue