summaryrefslogtreecommitdiff
path: root/ext/webidl/benches/dict.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/webidl/benches/dict.js')
-rw-r--r--ext/webidl/benches/dict.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/webidl/benches/dict.js b/ext/webidl/benches/dict.js
new file mode 100644
index 000000000..353a630eb
--- /dev/null
+++ b/ext/webidl/benches/dict.js
@@ -0,0 +1,35 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+// deno-lint-ignore-file
+
+const { createDictionaryConverter, converters } = globalThis.__bootstrap.webidl;
+
+const TextDecodeOptions = createDictionaryConverter(
+ "TextDecodeOptions",
+ [
+ {
+ key: "stream",
+ converter: converters.boolean,
+ defaultValue: false,
+ },
+ ],
+);
+
+// Sanity check
+{
+ const o = TextDecodeOptions(undefined);
+ if (o.stream !== false) {
+ throw new Error("Unexpected stream value");
+ }
+}
+
+function handwrittenConverter(V) {
+ const defaultValue = { stream: false };
+ if (V === undefined || V === null) {
+ return defaultValue;
+ }
+ if (V.stream !== undefined) {
+ defaultValue.stream = !!V.stream;
+ }
+ return defaultValue;
+}