Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua committed Jan 24, 2024
1 parent 8685e6c commit 26195cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions docs/rules/no_deprecated_deno_api.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
Warns the usage of the deprecated Deno APIs

The following APIs in `Deno` namespace are now marked as deprecated and will get removed from the namespace in Deno 2.0
The following APIs in `Deno` namespace are now marked as deprecated and will get
removed from the namespace in Deno 2.0

**IO APIs**

- `Deno.Buffer`
- `Deno.copy`
- `Deno.iter`
- `Deno.iterSync`
- `Deno.read`
- `Deno.readSync`
- `Deno.readAll`
- `Deno.readAllSync`
- `Deno.writeAll`
- `Deno.writeAllSync`

The IO APIs are already available in `std/io` or `std/streams`, so replace these
deprecated ones with alternatives from `std`. For more detail, see
The IO APIs are already available in `std/io`, so replace these deprecated ones
with alternatives from `std`. For more detail, see
[the tracking issue](https://github.com/denoland/deno/issues/9795).

**Sub Process API**
Expand Down
2 changes: 1 addition & 1 deletion www/static/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
},
{
"code": "no-deprecated-deno-api",
"docs": "Warns the usage of the deprecated Deno APIs\n\nThe following APIs in `Deno` namespace are now marked as deprecated and will get\nremoved from the namespace in the future.\n\n**IO APIs**\n\n- `Deno.Buffer`\n- `Deno.copy`\n- `Deno.iter`\n- `Deno.iterSync`\n- `Deno.readAll`\n- `Deno.readAllSync`\n- `Deno.writeAll`\n- `Deno.writeAllSync`\n\nThe IO APIs are already available in `std/io` or `std/streams`, so replace these\ndeprecated ones with alternatives from `std`. For more detail, see\n[the tracking issue](https://github.com/denoland/deno/issues/9795).\n\n**Sub Process API**\n\n- `Deno.run`\n\n`Deno.run` was deprecated in favor of `Deno.Command`. See\n[deno#9435](https://github.com/denoland/deno/discussions/9435) for more details.\n\n**Custom Inspector API**\n\n- `Deno.customInspect`\n\n`Deno.customInspect` was deprecated in favor of\n`Symbol.for(\"Deno.customInspect\")`. Replace the usages with this symbol\nexpression. See [deno#9294](https://github.com/denoland/deno/issues/9294) for\nmore details.\n\n**File system API**\n\n- `Deno.File`\n\n`Deno.File` was deprecated in favor of `Deno.FsFile`. Replace the usages with\nnew class name.\n\n**HTTP server API**\n\n- `Deno.serveHttp`\n\n`Deno.serveHttp` was deprecated in favor of `Deno.serve`.\n\n### Invalid:\n\n```typescript\n// buffer\nconst a = Deno.Buffer();\n\n// read\nconst b = await Deno.readAll(reader);\nconst c = Deno.readAllSync(reader);\n\n// write\nawait Deno.writeAll(writer, data);\nDeno.writeAllSync(writer, data);\n\n// iter\nfor await (const x of Deno.iter(xs)) {}\nfor (const y of Deno.iterSync(ys)) {}\n\n// copy\nawait Deno.copy(reader, writer);\n\n// custom inspector\nclass A {\n [Deno.customInspect]() {\n return \"This is A\";\n }\n}\n\nfunction foo(file: Deno.File) {\n // ...\n}\n```\n\n### Valid:\n\n```typescript\n// readAll\nimport { toArrayBuffer } from \"https://deno.land/std/streams/to_array_buffer.ts\";\nconst b = await toArrayBuffer(reader); // `b` is ArrayBuffer\nconst c = new Uint8Array(b); // You can convert ArrayBuffer to Uint8Array\n\n// writeAll\n// reader is `ReadableStream` and writer is `WritableStream`\nconst reader = ReadableStream.from([1, 2, 3]);\nawait reader.pipeTo(writer);\n\n// iter\n// reader is `ReadableStream`\nfor await (const chunk of reader) {\n // do something\n}\n\n// copy\n// reader is `ReadableStream` and writer is `WritableStream`\nawait reader.pipeTo(writer);\n\n// custom inspector\nclass A {\n [Symbol.for(\"Deno.customInspect\")]() {\n return \"This is A\";\n }\n}\n\nfunction foo(file: Deno.FsFile) {\n // ...\n}\n```\n",
"docs": "Warns the usage of the deprecated Deno APIs\n\nThe following APIs in `Deno` namespace are now marked as deprecated and will get\nremoved from the namespace in Deno 2.0\n\n**IO APIs**\n\n- `Deno.Buffer`\n- `Deno.copy`\n- `Deno.iter`\n- `Deno.iterSync`\n- `Deno.read`\n- `Deno.readSync`\n- `Deno.readAll`\n- `Deno.readAllSync`\n- `Deno.writeAll`\n- `Deno.writeAllSync`\n\nThe IO APIs are already available in `std/io`, so replace these deprecated ones\nwith alternatives from `std`. For more detail, see\n[the tracking issue](https://github.com/denoland/deno/issues/9795).\n\n**Sub Process API**\n\n- `Deno.run`\n\n`Deno.run` was deprecated in favor of `Deno.Command`. See\n[deno#9435](https://github.com/denoland/deno/discussions/9435) for more details.\n\n**Custom Inspector API**\n\n- `Deno.customInspect`\n\n`Deno.customInspect` was deprecated in favor of\n`Symbol.for(\"Deno.customInspect\")`. Replace the usages with this symbol\nexpression. See [deno#9294](https://github.com/denoland/deno/issues/9294) for\nmore details.\n\n**File system API**\n\n- `Deno.File`\n\n`Deno.File` was deprecated in favor of `Deno.FsFile`. Replace the usages with\nnew class name.\n\n**HTTP server API**\n\n- `Deno.serveHttp`\n\n`Deno.serveHttp` was deprecated in favor of `Deno.serve`.\n\n### Invalid:\n\n```typescript\n// buffer\nconst a = Deno.Buffer();\n\n// read\nconst b = await Deno.readAll(reader);\nconst c = Deno.readAllSync(reader);\n\n// write\nawait Deno.writeAll(writer, data);\nDeno.writeAllSync(writer, data);\n\n// iter\nfor await (const x of Deno.iter(xs)) {}\nfor (const y of Deno.iterSync(ys)) {}\n\n// copy\nawait Deno.copy(reader, writer);\n\n// custom inspector\nclass A {\n [Deno.customInspect]() {\n return \"This is A\";\n }\n}\n\nfunction foo(file: Deno.File) {\n // ...\n}\n```\n\n### Valid:\n\n```typescript\n// readAll\nimport { toArrayBuffer } from \"https://deno.land/std/streams/to_array_buffer.ts\";\nconst b = await toArrayBuffer(reader); // `b` is ArrayBuffer\nconst c = new Uint8Array(b); // You can convert ArrayBuffer to Uint8Array\n\n// writeAll\n// reader is `ReadableStream` and writer is `WritableStream`\nconst reader = ReadableStream.from([1, 2, 3]);\nawait reader.pipeTo(writer);\n\n// iter\n// reader is `ReadableStream`\nfor await (const chunk of reader) {\n // do something\n}\n\n// copy\n// reader is `ReadableStream` and writer is `WritableStream`\nawait reader.pipeTo(writer);\n\n// custom inspector\nclass A {\n [Symbol.for(\"Deno.customInspect\")]() {\n return \"This is A\";\n }\n}\n\nfunction foo(file: Deno.FsFile) {\n // ...\n}\n```\n",
"tags": [
"recommended"
]
Expand Down

0 comments on commit 26195cc

Please sign in to comment.