1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

refactor(ext/webidl): remove object from 'requiredArguments' (#18674)

This should produce a little less garbage and using an object here
wasn't really required.

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
This commit is contained in:
Bartek Iwańczuk 2023-04-12 21:58:57 +02:00 committed by Levente Kurusa
parent ae424ee976
commit 5d2c778765
No known key found for this signature in database
GPG key ID: 9F72F3C05BA137C4
24 changed files with 114 additions and 114 deletions

View file

@ -83,7 +83,7 @@ class BroadcastChannel extends EventTarget {
super(); super();
const prefix = "Failed to construct 'BroadcastChannel'"; const prefix = "Failed to construct 'BroadcastChannel'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
this[_name] = webidl.converters["DOMString"](name, { this[_name] = webidl.converters["DOMString"](name, {
prefix, prefix,
@ -106,7 +106,7 @@ class BroadcastChannel extends EventTarget {
webidl.assertBranded(this, BroadcastChannelPrototype); webidl.assertBranded(this, BroadcastChannelPrototype);
const prefix = "Failed to execute 'postMessage' on 'BroadcastChannel'"; const prefix = "Failed to execute 'postMessage' on 'BroadcastChannel'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
if (this[_closed]) { if (this[_closed]) {
throw new DOMException("Already closed", "InvalidStateError"); throw new DOMException("Already closed", "InvalidStateError");

12
ext/cache/01_cache.js vendored
View file

@ -26,7 +26,7 @@ class CacheStorage {
async open(cacheName) { async open(cacheName) {
webidl.assertBranded(this, CacheStoragePrototype); webidl.assertBranded(this, CacheStoragePrototype);
const prefix = "Failed to execute 'open' on 'CacheStorage'"; const prefix = "Failed to execute 'open' on 'CacheStorage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
cacheName = webidl.converters["DOMString"](cacheName, { cacheName = webidl.converters["DOMString"](cacheName, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -40,7 +40,7 @@ class CacheStorage {
async has(cacheName) { async has(cacheName) {
webidl.assertBranded(this, CacheStoragePrototype); webidl.assertBranded(this, CacheStoragePrototype);
const prefix = "Failed to execute 'has' on 'CacheStorage'"; const prefix = "Failed to execute 'has' on 'CacheStorage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
cacheName = webidl.converters["DOMString"](cacheName, { cacheName = webidl.converters["DOMString"](cacheName, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -51,7 +51,7 @@ class CacheStorage {
async delete(cacheName) { async delete(cacheName) {
webidl.assertBranded(this, CacheStoragePrototype); webidl.assertBranded(this, CacheStoragePrototype);
const prefix = "Failed to execute 'delete' on 'CacheStorage'"; const prefix = "Failed to execute 'delete' on 'CacheStorage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
cacheName = webidl.converters["DOMString"](cacheName, { cacheName = webidl.converters["DOMString"](cacheName, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -75,7 +75,7 @@ class Cache {
async put(request, response) { async put(request, response) {
webidl.assertBranded(this, CachePrototype); webidl.assertBranded(this, CachePrototype);
const prefix = "Failed to execute 'put' on 'Cache'"; const prefix = "Failed to execute 'put' on 'Cache'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
request = webidl.converters["RequestInfo_DOMString"](request, { request = webidl.converters["RequestInfo_DOMString"](request, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -165,7 +165,7 @@ class Cache {
async match(request, options) { async match(request, options) {
webidl.assertBranded(this, CachePrototype); webidl.assertBranded(this, CachePrototype);
const prefix = "Failed to execute 'match' on 'Cache'"; const prefix = "Failed to execute 'match' on 'Cache'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
request = webidl.converters["RequestInfo_DOMString"](request, { request = webidl.converters["RequestInfo_DOMString"](request, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -182,7 +182,7 @@ class Cache {
async delete(request, _options) { async delete(request, _options) {
webidl.assertBranded(this, CachePrototype); webidl.assertBranded(this, CachePrototype);
const prefix = "Failed to execute 'delete' on 'Cache'"; const prefix = "Failed to execute 'delete' on 'Cache'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
request = webidl.converters["RequestInfo_DOMString"](request, { request = webidl.converters["RequestInfo_DOMString"](request, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -468,7 +468,7 @@ class SubtleCrypto {
async digest(algorithm, data) { async digest(algorithm, data) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'digest' on 'SubtleCrypto'"; const prefix = "Failed to execute 'digest' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -500,7 +500,7 @@ class SubtleCrypto {
async encrypt(algorithm, key, data) { async encrypt(algorithm, key, data) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'encrypt' on 'SubtleCrypto'"; const prefix = "Failed to execute 'encrypt' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 3, { prefix }); webidl.requiredArguments(arguments.length, 3, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -548,7 +548,7 @@ class SubtleCrypto {
async decrypt(algorithm, key, data) { async decrypt(algorithm, key, data) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'decrypt' on 'SubtleCrypto'"; const prefix = "Failed to execute 'decrypt' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 3, { prefix }); webidl.requiredArguments(arguments.length, 3, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -756,7 +756,7 @@ class SubtleCrypto {
async sign(algorithm, key, data) { async sign(algorithm, key, data) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'sign' on 'SubtleCrypto'"; const prefix = "Failed to execute 'sign' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 3, { prefix }); webidl.requiredArguments(arguments.length, 3, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -920,7 +920,7 @@ class SubtleCrypto {
async importKey(format, keyData, algorithm, extractable, keyUsages) { async importKey(format, keyData, algorithm, extractable, keyUsages) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'importKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'importKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 4, { prefix }); webidl.requiredArguments(arguments.length, 4, prefix);
format = webidl.converters.KeyFormat(format, { format = webidl.converters.KeyFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1054,7 +1054,7 @@ class SubtleCrypto {
async exportKey(format, key) { async exportKey(format, key) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'exportKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'exportKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
format = webidl.converters.KeyFormat(format, { format = webidl.converters.KeyFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1126,7 +1126,7 @@ class SubtleCrypto {
async deriveBits(algorithm, baseKey, length) { async deriveBits(algorithm, baseKey, length) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'deriveBits' on 'SubtleCrypto'"; const prefix = "Failed to execute 'deriveBits' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 3, { prefix }); webidl.requiredArguments(arguments.length, 3, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1176,7 +1176,7 @@ class SubtleCrypto {
) { ) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'deriveKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'deriveKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 5, { prefix }); webidl.requiredArguments(arguments.length, 5, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1271,7 +1271,7 @@ class SubtleCrypto {
async verify(algorithm, key, signature, data) { async verify(algorithm, key, signature, data) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'verify' on 'SubtleCrypto'"; const prefix = "Failed to execute 'verify' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 4, { prefix }); webidl.requiredArguments(arguments.length, 4, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1411,7 +1411,7 @@ class SubtleCrypto {
async wrapKey(format, key, wrappingKey, wrapAlgorithm) { async wrapKey(format, key, wrappingKey, wrapAlgorithm) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'wrapKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'wrapKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 4, { prefix }); webidl.requiredArguments(arguments.length, 4, prefix);
format = webidl.converters.KeyFormat(format, { format = webidl.converters.KeyFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1547,7 +1547,7 @@ class SubtleCrypto {
) { ) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'unwrapKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'unwrapKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 7, { prefix }); webidl.requiredArguments(arguments.length, 7, prefix);
format = webidl.converters.KeyFormat(format, { format = webidl.converters.KeyFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -1708,7 +1708,7 @@ class SubtleCrypto {
async generateKey(algorithm, extractable, keyUsages) { async generateKey(algorithm, extractable, keyUsages) {
webidl.assertBranded(this, SubtleCryptoPrototype); webidl.assertBranded(this, SubtleCryptoPrototype);
const prefix = "Failed to execute 'generateKey' on 'SubtleCrypto'"; const prefix = "Failed to execute 'generateKey' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 3, { prefix }); webidl.requiredArguments(arguments.length, 3, prefix);
algorithm = webidl.converters.AlgorithmIdentifier(algorithm, { algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -4715,7 +4715,7 @@ class Crypto {
getRandomValues(typedArray) { getRandomValues(typedArray) {
webidl.assertBranded(this, CryptoPrototype); webidl.assertBranded(this, CryptoPrototype);
const prefix = "Failed to execute 'getRandomValues' on 'Crypto'"; const prefix = "Failed to execute 'getRandomValues' on 'Crypto'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
// Fast path for Uint8Array // Fast path for Uint8Array
const tag = TypedArrayPrototypeGetSymbolToStringTag(typedArray); const tag = TypedArrayPrototypeGetSymbolToStringTag(typedArray);
if (tag === "Uint8Array") { if (tag === "Uint8Array") {

View file

@ -271,7 +271,7 @@ class Headers {
append(name, value) { append(name, value) {
webidl.assertBranded(this, HeadersPrototype); webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'append' on 'Headers'"; const prefix = "Failed to execute 'append' on 'Headers'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters["ByteString"](name, { name = webidl.converters["ByteString"](name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -288,7 +288,7 @@ class Headers {
*/ */
delete(name) { delete(name) {
const prefix = "Failed to execute 'delete' on 'Headers'"; const prefix = "Failed to execute 'delete' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, { name = webidl.converters["ByteString"](name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -316,7 +316,7 @@ class Headers {
*/ */
get(name) { get(name) {
const prefix = "Failed to execute 'get' on 'Headers'"; const prefix = "Failed to execute 'get' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, { name = webidl.converters["ByteString"](name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -335,7 +335,7 @@ class Headers {
*/ */
has(name) { has(name) {
const prefix = "Failed to execute 'has' on 'Headers'"; const prefix = "Failed to execute 'has' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, { name = webidl.converters["ByteString"](name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -362,7 +362,7 @@ class Headers {
set(name, value) { set(name, value) {
webidl.assertBranded(this, HeadersPrototype); webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'set' on 'Headers'"; const prefix = "Failed to execute 'set' on 'Headers'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters["ByteString"](name, { name = webidl.converters["ByteString"](name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -101,7 +101,7 @@ class FormData {
append(name, valueOrBlobValue, filename) { append(name, valueOrBlobValue, filename) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'append' on 'FormData'"; const prefix = "Failed to execute 'append' on 'FormData'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,
@ -137,7 +137,7 @@ class FormData {
delete(name) { delete(name) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'name' on 'FormData'"; const prefix = "Failed to execute 'name' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,
@ -160,7 +160,7 @@ class FormData {
get(name) { get(name) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'get' on 'FormData'"; const prefix = "Failed to execute 'get' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,
@ -182,7 +182,7 @@ class FormData {
getAll(name) { getAll(name) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'getAll' on 'FormData'"; const prefix = "Failed to execute 'getAll' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,
@ -205,7 +205,7 @@ class FormData {
has(name) { has(name) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'has' on 'FormData'"; const prefix = "Failed to execute 'has' on 'FormData'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,
@ -229,7 +229,7 @@ class FormData {
set(name, valueOrBlobValue, filename) { set(name, valueOrBlobValue, filename) {
webidl.assertBranded(this, FormDataPrototype); webidl.assertBranded(this, FormDataPrototype);
const prefix = "Failed to execute 'set' on 'FormData'"; const prefix = "Failed to execute 'set' on 'FormData'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters["USVString"](name, { name = webidl.converters["USVString"](name, {
prefix, prefix,

View file

@ -273,7 +273,7 @@ class Request {
*/ */
constructor(input, init = {}) { constructor(input, init = {}) {
const prefix = "Failed to construct 'Request'"; const prefix = "Failed to construct 'Request'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
input = webidl.converters["RequestInfo_DOMString"](input, { input = webidl.converters["RequestInfo_DOMString"](input, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -413,7 +413,7 @@ function fetch(input, init = {}) {
// 1. // 1.
const result = new Promise((resolve, reject) => { const result = new Promise((resolve, reject) => {
const prefix = "Failed to call 'fetch'"; const prefix = "Failed to call 'fetch'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
// 2. // 2.
const requestObject = new Request(input, init); const requestObject = new Request(input, init);
// 3. // 3.

View file

@ -143,7 +143,7 @@ class URLSearchParams {
append(name, value) { append(name, value) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'append' on 'URLSearchParams'"; const prefix = "Failed to execute 'append' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -162,7 +162,7 @@ class URLSearchParams {
delete(name) { delete(name) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'append' on 'URLSearchParams'"; const prefix = "Failed to execute 'append' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -186,7 +186,7 @@ class URLSearchParams {
getAll(name) { getAll(name) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'getAll' on 'URLSearchParams'"; const prefix = "Failed to execute 'getAll' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -209,7 +209,7 @@ class URLSearchParams {
get(name) { get(name) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'get' on 'URLSearchParams'"; const prefix = "Failed to execute 'get' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -231,7 +231,7 @@ class URLSearchParams {
has(name) { has(name) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'has' on 'URLSearchParams'"; const prefix = "Failed to execute 'has' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -246,7 +246,7 @@ class URLSearchParams {
set(name, value) { set(name, value) {
webidl.assertBranded(this, URLSearchParamsPrototype); webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'set' on 'URLSearchParams'"; const prefix = "Failed to execute 'set' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
name = webidl.converters.USVString(name, { name = webidl.converters.USVString(name, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -432,7 +432,7 @@ class URL {
set hash(value) { set hash(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'hash' on 'URL'"; const prefix = "Failed to set 'hash' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -460,7 +460,7 @@ class URL {
set host(value) { set host(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'host' on 'URL'"; const prefix = "Failed to set 'host' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -488,7 +488,7 @@ class URL {
set hostname(value) { set hostname(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'hostname' on 'URL'"; const prefix = "Failed to set 'hostname' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -515,7 +515,7 @@ class URL {
set href(value) { set href(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'href' on 'URL'"; const prefix = "Failed to set 'href' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -570,7 +570,7 @@ class URL {
set password(value) { set password(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'password' on 'URL'"; const prefix = "Failed to set 'password' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -603,7 +603,7 @@ class URL {
set pathname(value) { set pathname(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'pathname' on 'URL'"; const prefix = "Failed to set 'pathname' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -638,7 +638,7 @@ class URL {
set port(value) { set port(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'port' on 'URL'"; const prefix = "Failed to set 'port' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -666,7 +666,7 @@ class URL {
set protocol(value) { set protocol(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'protocol' on 'URL'"; const prefix = "Failed to set 'protocol' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -697,7 +697,7 @@ class URL {
set search(value) { set search(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'search' on 'URL'"; const prefix = "Failed to set 'search' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -737,7 +737,7 @@ class URL {
set username(value) { set username(value) {
webidl.assertBranded(this, URLPrototype); webidl.assertBranded(this, URLPrototype);
const prefix = "Failed to set 'username' on 'URL'"; const prefix = "Failed to set 'username' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
value = webidl.converters.DOMString(value, { value = webidl.converters.DOMString(value, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -55,7 +55,7 @@ class URLPattern {
constructor(input, baseURL = undefined) { constructor(input, baseURL = undefined) {
this[webidl.brand] = webidl.brand; this[webidl.brand] = webidl.brand;
const prefix = "Failed to construct 'URLPattern'"; const prefix = "Failed to construct 'URLPattern'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
input = webidl.converters.URLPatternInput(input, { input = webidl.converters.URLPatternInput(input, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -133,7 +133,7 @@ class URLPattern {
test(input, baseURL = undefined) { test(input, baseURL = undefined) {
webidl.assertBranded(this, URLPatternPrototype); webidl.assertBranded(this, URLPatternPrototype);
const prefix = "Failed to execute 'test' on 'URLPattern'"; const prefix = "Failed to execute 'test' on 'URLPattern'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
input = webidl.converters.URLPatternInput(input, { input = webidl.converters.URLPatternInput(input, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -174,7 +174,7 @@ class URLPattern {
exec(input, baseURL = undefined) { exec(input, baseURL = undefined) {
webidl.assertBranded(this, URLPatternPrototype); webidl.assertBranded(this, URLPatternPrototype);
const prefix = "Failed to execute 'exec' on 'URLPattern'"; const prefix = "Failed to execute 'exec' on 'URLPattern'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
input = webidl.converters.URLPatternInput(input, { input = webidl.converters.URLPatternInput(input, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -162,9 +162,11 @@ class Event {
this[_path] = []; this[_path] = [];
if (!eventInitDict[_skipInternalInit]) { if (!eventInitDict[_skipInternalInit]) {
webidl.requiredArguments(arguments.length, 1, { webidl.requiredArguments(
prefix: "Failed to construct 'Event'", arguments.length,
}); 1,
"Failed to construct 'Event'",
);
type = webidl.converters.DOMString(type, { type = webidl.converters.DOMString(type, {
prefix: "Failed to construct 'Event'", prefix: "Failed to construct 'Event'",
context: "Argument 1", context: "Argument 1",
@ -958,9 +960,7 @@ class EventTarget {
webidl.assertBranded(self, EventTargetPrototype); webidl.assertBranded(self, EventTargetPrototype);
const prefix = "Failed to execute 'addEventListener' on 'EventTarget'"; const prefix = "Failed to execute 'addEventListener' on 'EventTarget'";
webidl.requiredArguments(arguments.length, 2, { webidl.requiredArguments(arguments.length, 2, prefix);
prefix,
});
options = webidl.converters.AddEventListenerOptions(options, { options = webidl.converters.AddEventListenerOptions(options, {
prefix, prefix,
@ -1014,9 +1014,11 @@ class EventTarget {
) { ) {
const self = this ?? globalThis_; const self = this ?? globalThis_;
webidl.assertBranded(self, EventTargetPrototype); webidl.assertBranded(self, EventTargetPrototype);
webidl.requiredArguments(arguments.length, 2, { webidl.requiredArguments(
prefix: "Failed to execute 'removeEventListener' on 'EventTarget'", arguments.length,
}); 2,
"Failed to execute 'removeEventListener' on 'EventTarget'",
);
const { listeners } = self[eventTargetData]; const { listeners } = self[eventTargetData];
if (callback !== null && ReflectHas(listeners, type)) { if (callback !== null && ReflectHas(listeners, type)) {
@ -1052,9 +1054,11 @@ class EventTarget {
// executed. // executed.
const self = this ?? globalThis_; const self = this ?? globalThis_;
webidl.assertBranded(self, EventTargetPrototype); webidl.assertBranded(self, EventTargetPrototype);
webidl.requiredArguments(arguments.length, 1, { webidl.requiredArguments(
prefix: "Failed to execute 'dispatchEvent' on 'EventTarget'", arguments.length,
}); 1,
"Failed to execute 'dispatchEvent' on 'EventTarget'",
);
// This is an optimization to avoid creating an event listener // This is an optimization to avoid creating an event listener
// on each startup. // on each startup.
@ -1261,9 +1265,11 @@ class CustomEvent extends Event {
constructor(type, eventInitDict = {}) { constructor(type, eventInitDict = {}) {
super(type, eventInitDict); super(type, eventInitDict);
webidl.requiredArguments(arguments.length, 1, { webidl.requiredArguments(
prefix: "Failed to construct 'CustomEvent'", arguments.length,
}); 1,
"Failed to construct 'CustomEvent'",
);
const { detail } = eventInitDict; const { detail } = eventInitDict;
this.#detail = detail; this.#detail = detail;
} }
@ -1512,7 +1518,7 @@ function checkThis(thisArg) {
function reportError(error) { function reportError(error) {
checkThis(this); checkThis(this);
const prefix = "Failed to call 'reportError'"; const prefix = "Failed to call 'reportError'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
reportException(error); reportException(error);
} }

View file

@ -45,7 +45,7 @@ class AbortSignal extends EventTarget {
static timeout(millis) { static timeout(millis) {
const prefix = "Failed to call 'AbortSignal.timeout'"; const prefix = "Failed to call 'AbortSignal.timeout'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
millis = webidl.converters["unsigned long long"](millis, { millis = webidl.converters["unsigned long long"](millis, {
enforceRange: true, enforceRange: true,
}); });

View file

@ -22,7 +22,7 @@ const {
*/ */
function atob(data) { function atob(data) {
const prefix = "Failed to execute 'atob'"; const prefix = "Failed to execute 'atob'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
data = webidl.converters.DOMString(data, { data = webidl.converters.DOMString(data, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -46,7 +46,7 @@ function atob(data) {
*/ */
function btoa(data) { function btoa(data) {
const prefix = "Failed to execute 'btoa'"; const prefix = "Failed to execute 'btoa'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
data = webidl.converters.DOMString(data, { data = webidl.converters.DOMString(data, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -4701,7 +4701,7 @@ class ByteLengthQueuingStrategy {
/** @param {{ highWaterMark: number }} init */ /** @param {{ highWaterMark: number }} init */
constructor(init) { constructor(init) {
const prefix = "Failed to construct 'ByteLengthQueuingStrategy'"; const prefix = "Failed to construct 'ByteLengthQueuingStrategy'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
init = webidl.converters.QueuingStrategyInit(init, { init = webidl.converters.QueuingStrategyInit(init, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -4758,7 +4758,7 @@ class CountQueuingStrategy {
/** @param {{ highWaterMark: number }} init */ /** @param {{ highWaterMark: number }} init */
constructor(init) { constructor(init) {
const prefix = "Failed to construct 'CountQueuingStrategy'"; const prefix = "Failed to construct 'CountQueuingStrategy'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
init = webidl.converters.QueuingStrategyInit(init, { init = webidl.converters.QueuingStrategyInit(init, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -4950,7 +4950,7 @@ class ReadableStream {
pipeThrough(transform, options = {}) { pipeThrough(transform, options = {}) {
webidl.assertBranded(this, ReadableStreamPrototype); webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'pipeThrough' on 'ReadableStream'"; const prefix = "Failed to execute 'pipeThrough' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
transform = webidl.converters.ReadableWritablePair(transform, { transform = webidl.converters.ReadableWritablePair(transform, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -4988,7 +4988,7 @@ class ReadableStream {
try { try {
webidl.assertBranded(this, ReadableStreamPrototype); webidl.assertBranded(this, ReadableStreamPrototype);
const prefix = "Failed to execute 'pipeTo' on 'ReadableStream'"; const prefix = "Failed to execute 'pipeTo' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
destination = webidl.converters.WritableStream(destination, { destination = webidl.converters.WritableStream(destination, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -5079,7 +5079,7 @@ class ReadableStreamDefaultReader {
/** @param {ReadableStream<R>} stream */ /** @param {ReadableStream<R>} stream */
constructor(stream) { constructor(stream) {
const prefix = "Failed to construct 'ReadableStreamDefaultReader'"; const prefix = "Failed to construct 'ReadableStreamDefaultReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
stream = webidl.converters.ReadableStream(stream, { stream = webidl.converters.ReadableStream(stream, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -5179,7 +5179,7 @@ class ReadableStreamBYOBReader {
/** @param {ReadableStream<R>} stream */ /** @param {ReadableStream<R>} stream */
constructor(stream) { constructor(stream) {
const prefix = "Failed to construct 'ReadableStreamBYOBReader'"; const prefix = "Failed to construct 'ReadableStreamBYOBReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
stream = webidl.converters.ReadableStream(stream, { stream = webidl.converters.ReadableStream(stream, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -5321,7 +5321,7 @@ class ReadableStreamBYOBRequest {
respond(bytesWritten) { respond(bytesWritten) {
webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype); webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
const prefix = "Failed to execute 'respond' on 'ReadableStreamBYOBRequest'"; const prefix = "Failed to execute 'respond' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
bytesWritten = webidl.converters["unsigned long long"](bytesWritten, { bytesWritten = webidl.converters["unsigned long long"](bytesWritten, {
enforceRange: true, enforceRange: true,
prefix, prefix,
@ -5354,7 +5354,7 @@ class ReadableStreamBYOBRequest {
webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype); webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
const prefix = const prefix =
"Failed to execute 'respondWithNewView' on 'ReadableStreamBYOBRequest'"; "Failed to execute 'respondWithNewView' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
view = webidl.converters.ArrayBufferView(view, { view = webidl.converters.ArrayBufferView(view, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -5448,7 +5448,7 @@ class ReadableByteStreamController {
webidl.assertBranded(this, ReadableByteStreamControllerPrototype); webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
const prefix = const prefix =
"Failed to execute 'enqueue' on 'ReadableByteStreamController'"; "Failed to execute 'enqueue' on 'ReadableByteStreamController'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
const arg1 = "Argument 1"; const arg1 = "Argument 1";
chunk = webidl.converters.ArrayBufferView(chunk, { chunk = webidl.converters.ArrayBufferView(chunk, {
prefix, prefix,
@ -6038,7 +6038,7 @@ class WritableStreamDefaultWriter {
*/ */
constructor(stream) { constructor(stream) {
const prefix = "Failed to construct 'WritableStreamDefaultWriter'"; const prefix = "Failed to construct 'WritableStreamDefaultWriter'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
stream = webidl.converters.WritableStream(stream, { stream = webidl.converters.WritableStream(stream, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -492,7 +492,7 @@ class File extends Blob {
*/ */
constructor(fileBits, fileName, options = {}) { constructor(fileBits, fileName, options = {}) {
const prefix = "Failed to construct 'File'"; const prefix = "Failed to construct 'File'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
fileBits = webidl.converters["sequence<BlobPart>"](fileBits, { fileBits = webidl.converters["sequence<BlobPart>"](fileBits, {
context: "Argument 1", context: "Argument 1",

View file

@ -352,7 +352,7 @@ class FileReader extends EventTarget {
readAsArrayBuffer(blob) { readAsArrayBuffer(blob) {
webidl.assertBranded(this, FileReaderPrototype); webidl.assertBranded(this, FileReaderPrototype);
const prefix = "Failed to execute 'readAsArrayBuffer' on 'FileReader'"; const prefix = "Failed to execute 'readAsArrayBuffer' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
this.#readOperation(blob, { kind: "ArrayBuffer" }); this.#readOperation(blob, { kind: "ArrayBuffer" });
} }
@ -360,7 +360,7 @@ class FileReader extends EventTarget {
readAsBinaryString(blob) { readAsBinaryString(blob) {
webidl.assertBranded(this, FileReaderPrototype); webidl.assertBranded(this, FileReaderPrototype);
const prefix = "Failed to execute 'readAsBinaryString' on 'FileReader'"; const prefix = "Failed to execute 'readAsBinaryString' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
// alias for readAsArrayBuffer // alias for readAsArrayBuffer
this.#readOperation(blob, { kind: "BinaryString" }); this.#readOperation(blob, { kind: "BinaryString" });
} }
@ -369,7 +369,7 @@ class FileReader extends EventTarget {
readAsDataURL(blob) { readAsDataURL(blob) {
webidl.assertBranded(this, FileReaderPrototype); webidl.assertBranded(this, FileReaderPrototype);
const prefix = "Failed to execute 'readAsDataURL' on 'FileReader'"; const prefix = "Failed to execute 'readAsDataURL' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
// alias for readAsArrayBuffer // alias for readAsArrayBuffer
this.#readOperation(blob, { kind: "DataUrl" }); this.#readOperation(blob, { kind: "DataUrl" });
} }
@ -381,7 +381,7 @@ class FileReader extends EventTarget {
readAsText(blob, encoding = undefined) { readAsText(blob, encoding = undefined) {
webidl.assertBranded(this, FileReaderPrototype); webidl.assertBranded(this, FileReaderPrototype);
const prefix = "Failed to execute 'readAsText' on 'FileReader'"; const prefix = "Failed to execute 'readAsText' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
if (encoding !== undefined) { if (encoding !== undefined) {
encoding = webidl.converters["DOMString"](encoding, { encoding = webidl.converters["DOMString"](encoding, {
prefix, prefix,

View file

@ -23,7 +23,7 @@ import { URL } from "ext:deno_url/00_url.js";
*/ */
function createObjectURL(blob) { function createObjectURL(blob) {
const prefix = "Failed to execute 'createObjectURL' on 'URL'"; const prefix = "Failed to execute 'createObjectURL' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
blob = webidl.converters["Blob"](blob, { blob = webidl.converters["Blob"](blob, {
context: "Argument 1", context: "Argument 1",
prefix, prefix,
@ -38,7 +38,7 @@ function createObjectURL(blob) {
*/ */
function revokeObjectURL(url) { function revokeObjectURL(url) {
const prefix = "Failed to execute 'revokeObjectURL' on 'URL'"; const prefix = "Failed to execute 'revokeObjectURL' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
url = webidl.converters["DOMString"](url, { url = webidl.converters["DOMString"](url, {
context: "Argument 1", context: "Argument 1",
prefix, prefix,

View file

@ -100,7 +100,7 @@ class MessagePort extends EventTarget {
postMessage(message, transferOrOptions = {}) { postMessage(message, transferOrOptions = {}) {
webidl.assertBranded(this, MessagePortPrototype); webidl.assertBranded(this, MessagePortPrototype);
const prefix = "Failed to execute 'postMessage' on 'MessagePort'"; const prefix = "Failed to execute 'postMessage' on 'MessagePort'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
message = webidl.converters.any(message); message = webidl.converters.any(message);
let options; let options;
if ( if (
@ -329,7 +329,7 @@ webidl.converters.StructuredSerializeOptions = webidl
function structuredClone(value, options) { function structuredClone(value, options) {
const prefix = "Failed to execute 'structuredClone'"; const prefix = "Failed to execute 'structuredClone'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
options = webidl.converters.StructuredSerializeOptions(options, { options = webidl.converters.StructuredSerializeOptions(options, {
prefix, prefix,
context: "Argument 2", context: "Argument 2",

View file

@ -28,7 +28,7 @@ class CompressionStream {
constructor(format) { constructor(format) {
const prefix = "Failed to construct 'CompressionStream'"; const prefix = "Failed to construct 'CompressionStream'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
format = webidl.converters.CompressionFormat(format, { format = webidl.converters.CompressionFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -76,7 +76,7 @@ class DecompressionStream {
constructor(format) { constructor(format) {
const prefix = "Failed to construct 'DecompressionStream'"; const prefix = "Failed to construct 'DecompressionStream'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
format = webidl.converters.CompressionFormat(format, { format = webidl.converters.CompressionFormat(format, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -219,7 +219,7 @@ class PerformanceMark extends PerformanceEntry {
options = {}, options = {},
) { ) {
const prefix = "Failed to construct 'PerformanceMark'"; const prefix = "Failed to construct 'PerformanceMark'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.DOMString(name, { name = webidl.converters.DOMString(name, {
prefix, prefix,
@ -394,7 +394,7 @@ class Performance extends EventTarget {
) { ) {
webidl.assertBranded(this, PerformancePrototype); webidl.assertBranded(this, PerformancePrototype);
const prefix = "Failed to execute 'getEntriesByName' on 'Performance'"; const prefix = "Failed to execute 'getEntriesByName' on 'Performance'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.DOMString(name, { name = webidl.converters.DOMString(name, {
prefix, prefix,
@ -414,7 +414,7 @@ class Performance extends EventTarget {
getEntriesByType(type) { getEntriesByType(type) {
webidl.assertBranded(this, PerformancePrototype); webidl.assertBranded(this, PerformancePrototype);
const prefix = "Failed to execute 'getEntriesByName' on 'Performance'"; const prefix = "Failed to execute 'getEntriesByName' on 'Performance'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
type = webidl.converters.DOMString(type, { type = webidl.converters.DOMString(type, {
prefix, prefix,
@ -430,7 +430,7 @@ class Performance extends EventTarget {
) { ) {
webidl.assertBranded(this, PerformancePrototype); webidl.assertBranded(this, PerformancePrototype);
const prefix = "Failed to execute 'mark' on 'Performance'"; const prefix = "Failed to execute 'mark' on 'Performance'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
markName = webidl.converters.DOMString(markName, { markName = webidl.converters.DOMString(markName, {
prefix, prefix,
@ -458,7 +458,7 @@ class Performance extends EventTarget {
) { ) {
webidl.assertBranded(this, PerformancePrototype); webidl.assertBranded(this, PerformancePrototype);
const prefix = "Failed to execute 'measure' on 'Performance'"; const prefix = "Failed to execute 'measure' on 'Performance'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
measureName = webidl.converters.DOMString(measureName, { measureName = webidl.converters.DOMString(measureName, {
prefix, prefix,

View file

@ -642,11 +642,9 @@ converters["sequence<DOMString>"] = createSequenceConverter(
converters.DOMString, converters.DOMString,
); );
function requiredArguments(length, required, opts = {}) { function requiredArguments(length, required, prefix) {
if (length < required) { if (length < required) {
const errMsg = `${ const errMsg = `${prefix ? prefix + ": " : ""}${required} argument${
opts.prefix ? opts.prefix + ": " : ""
}${required} argument${
required === 1 ? "" : "s" required === 1 ? "" : "s"
} required, but only ${length} present.`; } required, but only ${length} present.`;
throw new TypeError(errMsg); throw new TypeError(errMsg);

View file

@ -206,7 +206,7 @@ declare module "ext:deno_webidl/00_webidl.js" {
function requiredArguments( function requiredArguments(
length: number, length: number,
required: number, required: number,
opts: ConverterOpts, prefix: string,
): void; ): void;
type Dictionary = DictionaryMember[]; type Dictionary = DictionaryMember[];
interface DictionaryMember { interface DictionaryMember {

View file

@ -172,9 +172,7 @@ class WebSocket extends EventTarget {
super(); super();
this[webidl.brand] = webidl.brand; this[webidl.brand] = webidl.brand;
const prefix = "Failed to construct 'WebSocket'"; const prefix = "Failed to construct 'WebSocket'";
webidl.requiredArguments(arguments.length, 1, { webidl.requiredArguments(arguments.length, 1, prefix);
prefix,
});
url = webidl.converters.USVString(url, { url = webidl.converters.USVString(url, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -301,9 +299,7 @@ class WebSocket extends EventTarget {
webidl.assertBranded(this, WebSocketPrototype); webidl.assertBranded(this, WebSocketPrototype);
const prefix = "Failed to execute 'send' on 'WebSocket'"; const prefix = "Failed to execute 'send' on 'WebSocket'";
webidl.requiredArguments(arguments.length, 1, { webidl.requiredArguments(arguments.length, 1, prefix);
prefix,
});
data = webidl.converters.WebSocketSend(data, { data = webidl.converters.WebSocketSend(data, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -87,7 +87,7 @@ class WebSocketStream {
constructor(url, options) { constructor(url, options) {
this[webidl.brand] = webidl.brand; this[webidl.brand] = webidl.brand;
const prefix = "Failed to construct 'WebSocketStream'"; const prefix = "Failed to construct 'WebSocketStream'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
url = webidl.converters.USVString(url, { url = webidl.converters.USVString(url, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",

View file

@ -35,7 +35,7 @@ class Storage {
key(index) { key(index) {
webidl.assertBranded(this, StoragePrototype); webidl.assertBranded(this, StoragePrototype);
const prefix = "Failed to execute 'key' on 'Storage'"; const prefix = "Failed to execute 'key' on 'Storage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
index = webidl.converters["unsigned long"](index, { index = webidl.converters["unsigned long"](index, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -47,7 +47,7 @@ class Storage {
setItem(key, value) { setItem(key, value) {
webidl.assertBranded(this, StoragePrototype); webidl.assertBranded(this, StoragePrototype);
const prefix = "Failed to execute 'setItem' on 'Storage'"; const prefix = "Failed to execute 'setItem' on 'Storage'";
webidl.requiredArguments(arguments.length, 2, { prefix }); webidl.requiredArguments(arguments.length, 2, prefix);
key = webidl.converters.DOMString(key, { key = webidl.converters.DOMString(key, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -63,7 +63,7 @@ class Storage {
getItem(key) { getItem(key) {
webidl.assertBranded(this, StoragePrototype); webidl.assertBranded(this, StoragePrototype);
const prefix = "Failed to execute 'getItem' on 'Storage'"; const prefix = "Failed to execute 'getItem' on 'Storage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
key = webidl.converters.DOMString(key, { key = webidl.converters.DOMString(key, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
@ -75,7 +75,7 @@ class Storage {
removeItem(key) { removeItem(key) {
webidl.assertBranded(this, StoragePrototype); webidl.assertBranded(this, StoragePrototype);
const prefix = "Failed to execute 'removeItem' on 'Storage'"; const prefix = "Failed to execute 'removeItem' on 'Storage'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, prefix);
key = webidl.converters.DOMString(key, { key = webidl.converters.DOMString(key, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",