1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

feat: deprecate Deno.seek() and Deno.seekSync() (#22065)

For removal in Deno v2.
This commit is contained in:
Asher Gomez 2024-01-24 15:09:56 +11:00 committed by GitHub
parent 4c5ce90883
commit ea48bee3f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View file

@ -2100,6 +2100,9 @@ declare namespace Deno {
* console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2) * console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2)
* ``` * ```
* *
* @deprecated Use `file.seek()` instead. {@linkcode Deno.seek} will be
* removed in Deno 2.0.
*
* @category I/O * @category I/O
*/ */
export function seek( export function seek(
@ -2145,6 +2148,9 @@ declare namespace Deno {
* console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2) * console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2)
* ``` * ```
* *
* @deprecated Use `file.seekSync()` instead. {@linkcode Deno.seekSync}
* will be removed in Deno 2.0.
*
* @category I/O * @category I/O
*/ */
export function seekSync( export function seekSync(

View file

@ -109,8 +109,22 @@ const denoNs = {
stdin: io.stdin, stdin: io.stdin,
stdout: io.stdout, stdout: io.stdout,
stderr: io.stderr, stderr: io.stderr,
seek: fs.seek, seek(rid, offset, whence) {
seekSync: fs.seekSync, internals.warnOnDeprecatedApi(
"Deno.seek()",
new Error().stack,
"Use `file.seek()` instead.",
);
return fs.seek(rid, offset, whence);
},
seekSync(rid, offset, whence) {
internals.warnOnDeprecatedApi(
"Deno.seekSync()",
new Error().stack,
"Use `file.seekSync()` instead.",
);
return fs.seekSync(rid, offset, whence);
},
connect: net.connect, connect: net.connect,
listen: net.listen, listen: net.listen,
loadavg: os.loadavg, loadavg: os.loadavg,