mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -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:
parent
e60cbfadc0
commit
2046aeed70
2 changed files with 23 additions and 0 deletions
|
@ -99,3 +99,14 @@ Deno.test(function fileUsingNumberFileName() {
|
|||
Deno.test(function fileUsingEmptyStringFileName() {
|
||||
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" }`,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -535,6 +535,18 @@ class File extends Blob {
|
|||
webidl.assertBranded(this, FilePrototype);
|
||||
return this[_LastModified];
|
||||
}
|
||||
|
||||
[SymbolFor("Deno.customInspect")](inspect) {
|
||||
return inspect(createFilteredInspectProxy({
|
||||
object: this,
|
||||
evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this),
|
||||
keys: [
|
||||
"name",
|
||||
"size",
|
||||
"type",
|
||||
],
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
webidl.configurePrototype(File);
|
||||
|
|
Loading…
Reference in a new issue