mirror of
https://github.com/denoland/deno.git
synced 2025-07-23 05:05:08 +00:00
refactor: rename SeekMode variants to camelCase and stabilize (#4946)
This commit is contained in:
parent
30dc9bb748
commit
dea3ca39ba
3 changed files with 27 additions and 40 deletions
35
cli/js/lib.deno.ns.d.ts
vendored
35
cli/js/lib.deno.ns.d.ts
vendored
|
@ -383,11 +383,10 @@ declare namespace Deno {
|
|||
export const EOF: unique symbol;
|
||||
export type EOF = typeof EOF;
|
||||
|
||||
/** **UNSTABLE**: might remove `"SEEK_"` prefix. Might not use all-caps. */
|
||||
export enum SeekMode {
|
||||
SEEK_START = 0,
|
||||
SEEK_CURRENT = 1,
|
||||
SEEK_END = 2,
|
||||
Start = 0,
|
||||
Current = 1,
|
||||
End = 2,
|
||||
}
|
||||
|
||||
export interface Reader {
|
||||
|
@ -470,9 +469,9 @@ declare namespace Deno {
|
|||
|
||||
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. Seek resolves to the new offset
|
||||
* interpreted according to `whence`: `Start` means relative to the
|
||||
* start of the file, `Current` means relative to the current offset,
|
||||
* and `End` means relative to the end. Seek resolves to the new offset
|
||||
* relative to the start of the file.
|
||||
*
|
||||
* Seeking to an offset before the start of the file is an error. Seeking to
|
||||
|
@ -485,9 +484,9 @@ declare namespace Deno {
|
|||
|
||||
export interface SyncSeeker {
|
||||
/** Seek sets the offset for the next `readSync()` or `writeSync()` 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.
|
||||
* offset, interpreted according to `whence`: `Start` means relative
|
||||
* to the start of the file, `Current` means relative to the current
|
||||
* offset, and `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
|
||||
|
@ -695,7 +694,7 @@ declare namespace Deno {
|
|||
* const file = Deno.openSync('hello.txt', {read: true, write: true, truncate: true, create: true});
|
||||
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello world"));
|
||||
* // advance cursor 6 bytes
|
||||
* const cursorPosition = Deno.seekSync(file.rid, 6, Deno.SeekMode.SEEK_START);
|
||||
* const cursorPosition = Deno.seekSync(file.rid, 6, Deno.SeekMode.Start);
|
||||
* console.log(cursorPosition); // 6
|
||||
* const buf = new Uint8Array(100);
|
||||
* file.readSync(buf);
|
||||
|
@ -705,11 +704,11 @@ declare namespace Deno {
|
|||
*
|
||||
* // Given file.rid pointing to file with "Hello world", which is 11 bytes long:
|
||||
* // Seek 6 bytes from the start of the file
|
||||
* console.log(Deno.seekSync(file.rid, 6, Deno.SeekMode.SEEK_START)); // "6"
|
||||
* console.log(Deno.seekSync(file.rid, 6, Deno.SeekMode.Start)); // "6"
|
||||
* // Seek 2 more bytes from the current position
|
||||
* console.log(Deno.seekSync(file.rid, 2, Deno.SeekMode.SEEK_CURRENT)); // "8"
|
||||
* console.log(Deno.seekSync(file.rid, 2, Deno.SeekMode.Current)); // "8"
|
||||
* // Seek backwards 2 bytes from the end of the file
|
||||
* console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.SEEK_END)); // "9" (e.g. 11-2)
|
||||
* console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2)
|
||||
*/
|
||||
export function seekSync(
|
||||
rid: number,
|
||||
|
@ -723,7 +722,7 @@ declare namespace Deno {
|
|||
* const file = await Deno.open('hello.txt', {read: true, write: true, truncate: true, create: true});
|
||||
* await Deno.write(file.rid, new TextEncoder().encode("Hello world"));
|
||||
* // advance cursor 6 bytes
|
||||
* const cursorPosition = await Deno.seek(file.rid, 6, Deno.SeekMode.SEEK_START);
|
||||
* const cursorPosition = await Deno.seek(file.rid, 6, Deno.SeekMode.Start);
|
||||
* console.log(cursorPosition); // 6
|
||||
* const buf = new Uint8Array(100);
|
||||
* await file.read(buf);
|
||||
|
@ -733,11 +732,11 @@ declare namespace Deno {
|
|||
*
|
||||
* // Given file.rid pointing to file with "Hello world", which is 11 bytes long:
|
||||
* // Seek 6 bytes from the start of the file
|
||||
* console.log(await Deno.seek(file.rid, 6, Deno.SeekMode.SEEK_START)); // "6"
|
||||
* console.log(await Deno.seek(file.rid, 6, Deno.SeekMode.Start)); // "6"
|
||||
* // Seek 2 more bytes from the current position
|
||||
* console.log(await Deno.seek(file.rid, 2, Deno.SeekMode.SEEK_CURRENT)); // "8"
|
||||
* console.log(await Deno.seek(file.rid, 2, Deno.SeekMode.Current)); // "8"
|
||||
* // Seek backwards 2 bytes from the end of the file
|
||||
* console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.SEEK_END)); // "9" (e.g. 11-2)
|
||||
* console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2)
|
||||
*/
|
||||
export function seek(
|
||||
rid: number,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue