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

feat(ext/web): Add name to Deno.customInspect of File objects (#20415)

Fixes https://github.com/denoland/deno/issues/20414
This commit is contained in:
lionel-rowe 2023-09-14 13:06:58 +08:00 committed by GitHub
parent e60cbfadc0
commit 2046aeed70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -99,3 +99,14 @@ Deno.test(function fileUsingNumberFileName() {
Deno.test(function fileUsingEmptyStringFileName() { Deno.test(function fileUsingEmptyStringFileName() {
testSecondArgument("", ""); testSecondArgument("", "");
}); });
Deno.test(function inspectFile() {
assertEquals(
Deno.inspect(new File([], "file-name.txt")),
`File { name: "file-name.txt", size: 0, type: "" }`,
);
assertEquals(
Deno.inspect(new File([], "file-name.txt", { type: "text/plain" })),
`File { name: "file-name.txt", size: 0, type: "text/plain" }`,
);
});

View file

@ -535,6 +535,18 @@ class File extends Blob {
webidl.assertBranded(this, FilePrototype); webidl.assertBranded(this, FilePrototype);
return this[_LastModified]; return this[_LastModified];
} }
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this),
keys: [
"name",
"size",
"type",
],
}));
}
} }
webidl.configurePrototype(File); webidl.configurePrototype(File);