Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate Deno.FsWatcher.rid #22074

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4084,14 +4084,19 @@ declare namespace Deno {
* @category File System
*/
export interface FsWatcher extends AsyncIterable<FsEvent>, Disposable {
/** The resource id. */
/**
* The resource id.
*
* @deprecated Use {@linkcode Deno.FsWatcher} instance methods instead.
* {@linkcode Deno.FsWatcher.rid} will be removed in Deno 2.0.
*/
readonly rid: number;
/** Stops watching the file system and closes the watcher resource. */
close(): void;
/**
* Stops watching the file system and closes the watcher resource.
*
* @deprecated {@linkcode Deno.FsWatcher.return} will be removed in v2.0.0.
* @deprecated {@linkcode Deno.FsWatcher.return} will be removed in Deno 2.0.
*/
return?(value?: any): Promise<IteratorResult<FsEvent>>;
[Symbol.asyncIterator](): AsyncIterableIterator<FsEvent>;
Expand Down
14 changes: 8 additions & 6 deletions runtime/js/40_fs_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ class FsWatcher {
}

get rid() {
internals.warnOnDeprecatedApi(
"Deno.FsWatcher.rid",
new Error().stack,
"Use `Deno.FsWatcher` instance methods instead.",
);
return this.#rid;
}

async next() {
try {
const value = await op_fs_events_poll(this.rid);
const value = await op_fs_events_poll(this.#rid);
return value ? { value, done: false } : { value: undefined, done: true };
} catch (error) {
if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error)) {
Expand All @@ -49,11 +54,8 @@ class FsWatcher {
// TODO(kt3k): This is deprecated. Will be removed in v2.0.
// See https://github.com/denoland/deno/issues/10577 for details
return(value) {
internals.warnOnDeprecatedApi(
"Deno.FsWatcher.return()",
new Error().stack,
);
core.close(this.rid);
internals.warnOnDeprecatedApi("Deno.FsWatcher.return()", new Error().stack);
core.close(this.#rid);
return PromiseResolve({ value, done: true });
}

Expand Down
Loading