diff --git a/.dlint.json b/.dlint.json index f583d01c1c..d25defffb1 100644 --- a/.dlint.json +++ b/.dlint.json @@ -3,7 +3,8 @@ "tags": ["recommended"], "include": [ "ban-untagged-todo", - "camelcase" + "camelcase", + "guard-for-in" ], "exclude": [ "no-invalid-triple-slash-reference" diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 43232ef90f..d71609dd19 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -26,6 +26,7 @@ MapPrototypeSet, MathCeil, ObjectKeys, + ObjectPrototypeHasOwnProperty, ObjectPrototypeIsPrototypeOf, Promise, SafeArrayIterator, @@ -167,6 +168,9 @@ const details = []; for (const key in post.ops) { + if (!ObjectPrototypeHasOwnProperty(post.ops, key)) { + continue; + } const preOp = pre.ops[key] ?? { opsDispatchedAsync: 0, opsCompletedAsync: 0 }; const postOp = post.ops[key]; diff --git a/cli/tests/unit/headers_test.ts b/cli/tests/unit/headers_test.ts index e46cfc6c53..fda4e81d9f 100644 --- a/cli/tests/unit/headers_test.ts +++ b/cli/tests/unit/headers_test.ts @@ -34,52 +34,52 @@ const headerDict: Record = { }; // deno-lint-ignore no-explicit-any const headerSeq: any[] = []; -for (const name in headerDict) { - headerSeq.push([name, headerDict[name]]); +for (const [name, value] of Object.entries(headerDict)) { + headerSeq.push([name, value]); } Deno.test(function newHeaderWithSequence() { const headers = new Headers(headerSeq); - for (const name in headerDict) { - assertEquals(headers.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + assertEquals(headers.get(name), String(value)); } assertEquals(headers.get("length"), null); }); Deno.test(function newHeaderWithRecord() { const headers = new Headers(headerDict); - for (const name in headerDict) { - assertEquals(headers.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + assertEquals(headers.get(name), String(value)); } }); Deno.test(function newHeaderWithHeadersInstance() { const headers = new Headers(headerDict); const headers2 = new Headers(headers); - for (const name in headerDict) { - assertEquals(headers2.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + assertEquals(headers2.get(name), String(value)); } }); Deno.test(function headerAppendSuccess() { const headers = new Headers(); - for (const name in headerDict) { - headers.append(name, headerDict[name]); - assertEquals(headers.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + headers.append(name, value); + assertEquals(headers.get(name), String(value)); } }); Deno.test(function headerSetSuccess() { const headers = new Headers(); - for (const name in headerDict) { - headers.set(name, headerDict[name]); - assertEquals(headers.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + headers.set(name, value); + assertEquals(headers.get(name), String(value)); } }); Deno.test(function headerHasSuccess() { const headers = new Headers(headerDict); - for (const name in headerDict) { + for (const name of Object.keys(headerDict)) { assert(headers.has(name), "headers has name " + name); assert( !headers.has("nameNotInHeaders"), @@ -90,7 +90,7 @@ Deno.test(function headerHasSuccess() { Deno.test(function headerDeleteSuccess() { const headers = new Headers(headerDict); - for (const name in headerDict) { + for (const name of Object.keys(headerDict)) { assert(headers.has(name), "headers have a header: " + name); headers.delete(name); assert(!headers.has(name), "headers do not have anymore a header: " + name); @@ -99,8 +99,8 @@ Deno.test(function headerDeleteSuccess() { Deno.test(function headerGetSuccess() { const headers = new Headers(headerDict); - for (const name in headerDict) { - assertEquals(headers.get(name), String(headerDict[name])); + for (const [name, value] of Object.entries(headerDict)) { + assertEquals(headers.get(name), String(value)); assertEquals(headers.get("nameNotInHeaders"), null); } }); diff --git a/ext/broadcast_channel/01_broadcast_channel.js b/ext/broadcast_channel/01_broadcast_channel.js index 59c6b7cef3..82bede8b06 100644 --- a/ext/broadcast_channel/01_broadcast_channel.js +++ b/ext/broadcast_channel/01_broadcast_channel.js @@ -34,7 +34,7 @@ break; } - const [name, data] = message; + const { 0: name, 1: data } = message; dispatch(null, name, new Uint8Array(data)); } diff --git a/ext/cache/01_cache.js b/ext/cache/01_cache.js index ab44c11b5f..bf0243e3c5 100644 --- a/ext/cache/01_cache.js +++ b/ext/cache/01_cache.js @@ -255,7 +255,7 @@ }, ); if (matchResult) { - const [meta, responseBodyRid] = matchResult; + const { 0: meta, 1: responseBodyRid } = matchResult; let body = null; if (responseBodyRid !== null) { body = readableStreamForRid(responseBodyRid); diff --git a/ext/console/02_console.js b/ext/console/02_console.js index e5fe3416a3..9b898a040f 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -360,7 +360,7 @@ ObjectKeys(value).length > 0 || ObjectGetOwnPropertySymbols(value).length > 0 ) { - const [propString, refIndex] = inspectRawObject( + const { 0: propString, 1: refIndex } = inspectRawObject( value, inspectOptions, ); @@ -847,7 +847,7 @@ displayName: "", delims: ["[", "]"], entryHandler: (entry, inspectOptions) => { - const [index, val] = entry; + const { 0: index, 1: val } = entry; let i = index; lastValidIndex = index; if (!ObjectPrototypeHasOwnProperty(value, i)) { @@ -940,7 +940,7 @@ displayName: "Map", delims: ["{", "}"], entryHandler: (entry, inspectOptions) => { - const [key, val] = entry; + const { 0: key, 1: val } = entry; inspectOptions.indentLevel++; const inspectedValue = `${ inspectValueWithQuotes(key, inspectOptions) @@ -1100,7 +1100,7 @@ const cyan = maybeColor(colors.cyan, inspectOptions); const red = maybeColor(colors.red, inspectOptions); - const [state, result] = core.getPromiseDetails(value); + const { 0: state, 1: result } = core.getPromiseDetails(value); if (state === PromiseState.Pending) { return `Promise { ${cyan("")} }`; @@ -1363,7 +1363,7 @@ ); } else { // Otherwise, default object formatting - let [insp, refIndex] = inspectRawObject(value, inspectOptions); + let { 0: insp, 1: refIndex } = inspectRawObject(value, inspectOptions); insp = refIndex + insp; return insp; } @@ -1568,17 +1568,17 @@ let g_; let b_; if (h < 60) { - [r_, g_, b_] = [c, x, 0]; + ({ 0: r_, 1: g_, 2: b_ } = [c, x, 0]); } else if (h < 120) { - [r_, g_, b_] = [x, c, 0]; + ({ 0: r_, 1: g_, 2: b_ } = [x, c, 0]); } else if (h < 180) { - [r_, g_, b_] = [0, c, x]; + ({ 0: r_, 1: g_, 2: b_ } = [0, c, x]); } else if (h < 240) { - [r_, g_, b_] = [0, x, c]; + ({ 0: r_, 1: g_, 2: b_ } = [0, x, c]); } else if (h < 300) { - [r_, g_, b_] = [x, 0, c]; + ({ 0: r_, 1: g_, 2: b_ } = [x, 0, c]); } else { - [r_, g_, b_] = [c, 0, x]; + ({ 0: r_, 1: g_, 2: b_ } = [c, 0, x]); } return [ MathRound((r_ + m) * 255), @@ -1645,7 +1645,7 @@ } for (let i = 0; i < rawEntries.length; ++i) { - const [key, value] = rawEntries[i]; + const { 0: key, 1: value } = rawEntries[i]; if (key == "background-color") { if (value != null) { css.backgroundColor = value; @@ -1736,12 +1736,12 @@ ansi += `\x1b[47m`; } else { if (ArrayIsArray(css.backgroundColor)) { - const [r, g, b] = css.backgroundColor; + const { 0: r, 1: g, 2: b } = css.backgroundColor; ansi += `\x1b[48;2;${r};${g};${b}m`; } else { const parsed = parseCssColor(css.backgroundColor); if (parsed !== null) { - const [r, g, b] = parsed; + const { 0: r, 1: g, 2: b } = parsed; ansi += `\x1b[48;2;${r};${g};${b}m`; } else { ansi += "\x1b[49m"; @@ -1770,12 +1770,12 @@ ansi += `\x1b[37m`; } else { if (ArrayIsArray(css.color)) { - const [r, g, b] = css.color; + const { 0: r, 1: g, 2: b } = css.color; ansi += `\x1b[38;2;${r};${g};${b}m`; } else { const parsed = parseCssColor(css.color); if (parsed !== null) { - const [r, g, b] = parsed; + const { 0: r, 1: g, 2: b } = parsed; ansi += `\x1b[38;2;${r};${g};${b}m`; } else { ansi += "\x1b[39m"; @@ -1799,7 +1799,7 @@ } if (!colorEquals(css.textDecorationColor, prevCss.textDecorationColor)) { if (css.textDecorationColor != null) { - const [r, g, b] = css.textDecorationColor; + const { 0: r, 1: g, 2: b } = css.textDecorationColor; ansi += `\x1b[58;2;${r};${g};${b}m`; } else { ansi += "\x1b[59m"; @@ -2045,7 +2045,7 @@ return; } - const [first, ...rest] = args; + const [first, ...rest] = new SafeArrayIterator(args); if (typeof first === "string") { this.error( diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index 4ab9556103..d253976ef1 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -305,7 +305,7 @@ const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`; // deno-lint-ignore prefer-primordials - for (const [name, value] of formData) { + for (const { 0: name, 1: value } of formData) { if (typeof value === "string") { ArrayPrototypePush( chunks, diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index d1246a9f21..bea1abce2a 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -42,6 +42,8 @@ JSONParse, ObjectDefineProperties, ObjectPrototypeIsPrototypeOf, + // TODO(lucacasonato): add SharedArrayBuffer to primordials + // SharedArrayBufferPrototype TypedArrayPrototypeSlice, TypeError, Uint8Array, @@ -185,7 +187,7 @@ * @returns {InnerBody} */ clone() { - const [out1, out2] = this.stream.tee(); + const { 0: out1, 1: out2 } = this.stream.tee(); this.streamOrStatic = out1; const second = new InnerBody(out2); second.source = core.deserialize(core.serialize(this.source)); @@ -447,6 +449,7 @@ if (typeof V === "object") { if ( ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || + // deno-lint-ignore prefer-primordials ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ) { return webidl.converters["ArrayBuffer"](V, opts); diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js index 359b10b455..ce2e723700 100644 --- a/ext/ffi/00_ffi.js +++ b/ext/ffi/00_ffi.js @@ -268,7 +268,10 @@ let size = 0; let alignment = 1; for (const field of new SafeArrayIterator(type.struct)) { - const [fieldSize, fieldAlign] = getTypeSizeAndAlignment(field, cache); + const { 0: fieldSize, 1: fieldAlign } = getTypeSizeAndAlignment( + field, + cache, + ); alignment = MathMax(alignment, fieldAlign); size = MathCeil(size / fieldAlign) * fieldAlign; size += fieldSize; @@ -319,7 +322,7 @@ "Invalid UnsafeCallback, cannot be nonblocking", ); } - const [rid, pointer] = ops.op_ffi_unsafe_callback_create( + const { 0: rid, 1: pointer } = ops.op_ffi_unsafe_callback_create( definition, callback, ); @@ -362,7 +365,7 @@ symbols = {}; constructor(path, symbols) { - [this.#rid, this.symbols] = ops.op_ffi_load({ path, symbols }); + ({ 0: this.#rid, 1: this.symbols } = ops.op_ffi_load({ path, symbols })); for (const symbol in symbols) { if (!ObjectPrototypeHasOwnProperty(symbols, symbol)) { continue; diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index ce18c2b764..357bdfbe2f 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -140,7 +140,7 @@ // Date header: https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.2 let str = `HTTP/1.1 ${status} ${statusCodes[status]}\r\nDate: ${date}\r\n`; for (let i = 0; i < headerList.length; ++i) { - const [name, value] = headerList[i]; + const { 0: name, 1: value } = headerList[i]; // header-field = field-name ":" OWS field-value OWS str += `${name}: ${value}\r\n`; } diff --git a/ext/http/01_http.js b/ext/http/01_http.js index 8151d5a740..cb98d246d8 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -115,7 +115,7 @@ return null; } - const [streamRid, method, url] = nextRequest; + const { 0: streamRid, 1: method, 2: url } = nextRequest; SetPrototypeAdd(this.managedResources, streamRid); /** @type {ReadableStream | undefined} */ diff --git a/ext/net/01_net.js b/ext/net/01_net.js index d2c67e713c..c15ff56aff 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -175,7 +175,7 @@ } this.#promiseId = promise[promiseIdSymbol]; if (this.#unref) core.unrefOp(this.#promiseId); - const [rid, localAddr, remoteAddr] = await promise; + const { 0: rid, 1: localAddr, 2: remoteAddr } = await promise; this.#promiseId = null; if (this.addr.transport == "tcp") { localAddr.transport = "tcp"; @@ -260,21 +260,21 @@ let remoteAddr; switch (this.addr.transport) { case "udp": { - [nread, remoteAddr] = await core.opAsync( + ({ 0: nread, 1: remoteAddr } = await core.opAsync( "op_net_recv_udp", this.rid, buf, - ); + )); remoteAddr.transport = "udp"; break; } case "unixpacket": { let path; - [nread, path] = await core.opAsync( + ({ 0: nread, 1: path } = await core.opAsync( "op_net_recv_unixpacket", this.rid, buf, - ); + )); remoteAddr = { transport: "unixpacket", path }; break; } @@ -330,7 +330,7 @@ function listen(args) { switch (args.transport ?? "tcp") { case "tcp": { - const [rid, addr] = ops.op_net_listen_tcp({ + const { 0: rid, 1: addr } = ops.op_net_listen_tcp({ hostname: args.hostname ?? "0.0.0.0", port: args.port, }, args.reusePort); @@ -338,7 +338,7 @@ return new Listener(rid, addr); } case "unix": { - const [rid, path] = ops.op_net_listen_unix(args.path); + const { 0: rid, 1: path } = ops.op_net_listen_unix(args.path); const addr = { transport: "unix", path, @@ -354,7 +354,7 @@ return function listenDatagram(args) { switch (args.transport) { case "udp": { - const [rid, addr] = udpOpFn( + const { 0: rid, 1: addr } = udpOpFn( { hostname: args.hostname ?? "127.0.0.1", port: args.port, @@ -365,7 +365,7 @@ return new Datagram(rid, addr); } case "unixpacket": { - const [rid, path] = unixOpFn(args.path); + const { 0: rid, 1: path } = unixOpFn(args.path); const addr = { transport: "unixpacket", path, @@ -381,7 +381,7 @@ async function connect(args) { switch (args.transport ?? "tcp") { case "tcp": { - const [rid, localAddr, remoteAddr] = await core.opAsync( + const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync( "op_net_connect_tcp", { hostname: args.hostname ?? "127.0.0.1", @@ -393,7 +393,7 @@ return new TcpConn(rid, remoteAddr, localAddr); } case "unix": { - const [rid, localAddr, remoteAddr] = await core.opAsync( + const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync( "op_net_connect_unix", args.path, ); diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 5b585932e5..632e1fbd4a 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -34,7 +34,7 @@ if (transport !== "tcp") { throw new TypeError(`Unsupported transport: '${transport}'`); } - const [rid, localAddr, remoteAddr] = await core.opAsync( + const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync( "op_net_connect_tls", { hostname, port }, { certFile, caCerts, certChain, privateKey, alpnProtocols }, @@ -46,7 +46,7 @@ class TlsListener extends Listener { async accept() { - const [rid, localAddr, remoteAddr] = await core.opAsync( + const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync( "op_net_accept_tls", this.rid, ); @@ -70,7 +70,7 @@ if (transport !== "tcp") { throw new TypeError(`Unsupported transport: '${transport}'`); } - const [rid, localAddr] = ops.op_net_listen_tls( + const { 0: rid, 1: localAddr } = ops.op_net_listen_tls( { hostname, port }, { cert, certFile, key, keyFile, alpnProtocols, reusePort }, ); @@ -86,7 +86,7 @@ alpnProtocols = undefined, } = {}, ) { - const [rid, localAddr, remoteAddr] = await opStartTls({ + const { 0: rid, 1: localAddr, 2: remoteAddr } = await opStartTls({ rid: conn.rid, hostname, certFile, diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 5fa0c52bde..1191565ee2 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -367,16 +367,16 @@ } #updateComponents() { - [ - this.#schemeEnd, - this.#usernameEnd, - this.#hostStart, - this.#hostEnd, - this.#port, - this.#pathStart, - this.#queryStart, - this.#fragmentStart, - ] = componentsBuf; + ({ + 0: this.#schemeEnd, + 1: this.#usernameEnd, + 2: this.#hostStart, + 3: this.#hostEnd, + 4: this.#port, + 5: this.#pathStart, + 6: this.#queryStart, + 7: this.#fragmentStart, + } = componentsBuf); } [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { diff --git a/ext/url/01_urlpattern.js b/ext/url/01_urlpattern.js index ef7df60e5b..14f0525514 100644 --- a/ext/url/01_urlpattern.js +++ b/ext/url/01_urlpattern.js @@ -155,7 +155,7 @@ return false; } - const [values] = res; + const values = res[0]; const keys = ObjectKeys(values); for (let i = 0; i < keys.length; ++i) { @@ -196,7 +196,7 @@ return null; } - const [values, inputs] = res; + const { 0: values, 1: inputs } = res; if (inputs[1] === null) { inputs.pop(); } diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index 031558bee9..a4556c03c7 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -193,7 +193,7 @@ DATA_CLONE_ERR, }); for (let i = 0; i < entries.length; ++i) { - const [key, value] = entries[i]; + const { 0: key, 1: value } = entries[i]; const desc = { value, enumerable: true }; ObjectDefineProperty(DOMException, key, desc); ObjectDefineProperty(DOMException.prototype, key, desc); diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 5b1c0141dd..1bad4f314a 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -23,6 +23,7 @@ BigInt64ArrayPrototype, BigUint64ArrayPrototype, DataView, + FinalizationRegistry, Int8ArrayPrototype, Int16ArrayPrototype, Int32ArrayPrototype, @@ -45,7 +46,8 @@ RangeError, ReflectHas, SafePromiseAll, - SharedArrayBuffer, + // TODO(lucacasonato): add SharedArrayBuffer to primordials + // SharedArrayBufferPrototype Symbol, SymbolAsyncIterator, SymbolFor, @@ -205,6 +207,7 @@ assert(typeof O === "object"); assert( ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, O) || + // deno-lint-ignore prefer-primordials ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, O), ); if (isDetachedBuffer(O)) { diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index b1dc6d4114..8de7b949f2 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -18,6 +18,8 @@ const { PromiseReject, PromiseResolve, + // TODO(lucacasonato): add SharedArrayBuffer to primordials + // SharedArrayBufferPrototype StringPrototypeCharCodeAt, StringPrototypeSlice, TypedArrayPrototypeSubarray, @@ -108,6 +110,7 @@ // When doing so they will have to make sure that changes to input do not affect future calls to decode(). if ( ObjectPrototypeIsPrototypeOf( + // deno-lint-ignore prefer-primordials SharedArrayBuffer.prototype, input || input.buffer, ) diff --git a/ext/web/09_file.js b/ext/web/09_file.js index 0fc1e7e964..ecdce3e6a4 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -23,10 +23,13 @@ AsyncGeneratorPrototypeNext, Date, DatePrototypeGetTime, + FinalizationRegistry, MathMax, MathMin, ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, + // TODO(lucacasonato): add SharedArrayBuffer to primordials + // SharedArrayBufferPrototype StringPrototypeCharAt, StringPrototypeToLowerCase, StringPrototypeSlice, @@ -407,6 +410,7 @@ } if ( ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || + // deno-lint-ignore prefer-primordials ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ) { return webidl.converters["ArrayBuffer"](V, opts); diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index 8b8aa57ace..7ab2beb826 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -36,7 +36,7 @@ constructor() { this[webidl.brand] = webidl.brand; - const [port1Id, port2Id] = opCreateEntangledMessagePort(); + const { 0: port1Id, 1: port2Id } = opCreateEntangledMessagePort(); const port1 = createMessagePort(port1Id); const port2 = createMessagePort(port2Id); this.#port1 = port1; @@ -329,8 +329,7 @@ context: "Argument 2", }); const messageData = serializeJsMessageData(value, options.transfer); - const [data] = deserializeJsMessageData(messageData); - return data; + return deserializeJsMessageData(messageData)[0]; } window.__bootstrap.messagePort = { diff --git a/ext/webgpu/src/01_webgpu.js b/ext/webgpu/src/01_webgpu.js index 792267bda6..eb239bab8b 100644 --- a/ext/webgpu/src/01_webgpu.js +++ b/ext/webgpu/src/01_webgpu.js @@ -41,6 +41,7 @@ Uint32Array, Uint32ArrayPrototype, Uint8Array, + WeakRef, } = window.__bootstrap.primordials; const _rid = Symbol("[[rid]]"); @@ -1893,7 +1894,7 @@ throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } for (let i = 0; i < mappedRanges.length; ++i) { - const [buffer, _rid, start] = mappedRanges[i]; + const { 0: buffer, /* 1: rid, */ 2: start } = mappedRanges[i]; // TODO(lucacasonato): is this logic correct? const end = start + buffer.byteLength; if ( @@ -1962,7 +1963,7 @@ throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } for (let i = 0; i < mappedRanges.length; ++i) { - const [buffer, mappedRid] = mappedRanges[i]; + const { 0: buffer, 1: mappedRid } = mappedRanges[i]; const { err } = ops.op_webgpu_buffer_unmap( bufferRid, mappedRid, diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index a71993c877..4127d24bf2 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -70,7 +70,7 @@ SetPrototypeDelete, SetPrototypeAdd, // TODO(lucacasonato): add SharedArrayBuffer to primordials - // SharedArrayBuffer, + // SharedArrayBufferPrototype String, StringFromCodePoint, StringPrototypeCharCodeAt, @@ -447,6 +447,7 @@ } function isSharedArrayBuffer(V) { + // deno-lint-ignore prefer-primordials return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V); } diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js index 4ff40ad773..0d0a4211a4 100644 --- a/ext/websocket/01_websocket.js +++ b/ext/websocket/01_websocket.js @@ -32,6 +32,8 @@ PromisePrototypeThen, RegExpPrototypeTest, Set, + // TODO(lucacasonato): add SharedArrayBuffer to primordials + // SharedArrayBufferPrototype StringPrototypeEndsWith, StringPrototypeToLowerCase, Symbol, @@ -58,9 +60,9 @@ return webidl.converters["Blob"](V, opts); } if (typeof V === "object") { - // TODO(littledivy): use primordial for SharedArrayBuffer if ( ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) || + // deno-lint-ignore prefer-primordials ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V) ) { return webidl.converters["ArrayBuffer"](V, opts); diff --git a/runtime/js/01_build.js b/runtime/js/01_build.js index 23a1c819b7..778331cdd6 100644 --- a/runtime/js/01_build.js +++ b/runtime/js/01_build.js @@ -13,7 +13,11 @@ }; function setBuildInfo(target) { - const [arch, vendor, os, env] = StringPrototypeSplit(target, "-", 4); + const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit( + target, + "-", + 4, + ); build.target = target; build.arch = arch; build.vendor = vendor; diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index fa544a5102..85c01e1a92 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -139,7 +139,7 @@ #pollControl = async () => { while (this.#status === "RUNNING") { - const [type, data] = await hostRecvCtrl(this.#id); + const { 0: type, 1: data } = await hostRecvCtrl(this.#id); // If terminate was called then we ignore all messages if (this.#status === "TERMINATED") { diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index 770cef1a8a..87b2015fb9 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -213,7 +213,7 @@ 'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {'; const typeEntries = ObjectEntries(types); for (let i = 0; i < typeEntries.length; ++i) { - let [name, type] = typeEntries[i]; + let { 0: name, 1: type } = typeEntries[i]; const optional = type.startsWith("?"); if (optional) type = type.slice(1); @@ -243,7 +243,7 @@ return [new Function("view", str), new Uint32Array(offset)]; } - const [statStruct, statBuf] = createByteStruct({ + const { 0: statStruct, 1: statBuf } = createByteStruct({ isFile: "bool", isDirectory: "bool", isSymlink: "bool", @@ -392,8 +392,8 @@ atime, mtime, ) { - const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); - const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); + const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime); + const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime); ops.op_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec); } @@ -402,8 +402,8 @@ atime, mtime, ) { - const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); - const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); + const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime); + const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime); await core.opAsync( "op_futime_async", rid, @@ -419,8 +419,8 @@ atime, mtime, ) { - const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); - const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); + const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime); + const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime); ops.op_utime_sync( pathFromURL(path), atimeSec, @@ -435,8 +435,8 @@ atime, mtime, ) { - const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime); - const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime); + const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime); + const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime); await core.opAsync( "op_utime_async", pathFromURL(path), diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js index de733d7eb1..9c1d96a28f 100644 --- a/runtime/js/40_spawn.js +++ b/runtime/js/40_spawn.js @@ -172,7 +172,7 @@ ); } - const [status, stdout, stderr] = await SafePromiseAll([ + const { 0: status, 1: stdout, 2: stderr } = await SafePromiseAll([ this.#status, collectOutput(this.#stdout), collectOutput(this.#stderr), diff --git a/third_party b/third_party index 3e5b0cea16..17e31cec93 160000 --- a/third_party +++ b/third_party @@ -1 +1 @@ -Subproject commit 3e5b0cea163cc0f2b3b0c7cedffc112cc49d6a78 +Subproject commit 17e31cec93aef7d014dcc46bc58ef1a86c0a9995 diff --git a/tools/wpt.ts b/tools/wpt.ts index 338c894646..5d0c2e7627 100755 --- a/tools/wpt.ts +++ b/tools/wpt.ts @@ -285,7 +285,7 @@ function assertAllExpectationsHaveTests( const missingTests: string[] = []; function walk(parentExpectation: Expectation, parent: string) { - for (const key in parentExpectation) { + for (const [key, expectation] of Object.entries(parentExpectation)) { const path = `${parent}/${key}`; if ( filter && @@ -293,7 +293,6 @@ function assertAllExpectationsHaveTests( ) { continue; } - const expectation = parentExpectation[key]; if (typeof expectation == "boolean" || Array.isArray(expectation)) { if (!tests.has(path)) { missingTests.push(path); @@ -368,8 +367,8 @@ async function update() { const currentExpectation = getExpectation(); - for (const path in resultTests) { - const { passed, failed, testSucceeded } = resultTests[path]; + for (const result of Object.values(resultTests)) { + const { passed, failed, testSucceeded } = result; let finalExpectation: boolean | string[]; if (failed.length == 0 && testSucceeded) { finalExpectation = true; @@ -655,9 +654,7 @@ function discoverTestsToRun( parentExpectation: Expectation | string[] | boolean, prefix: string, ) { - for (const key in parentFolder) { - const entry = parentFolder[key]; - + for (const [key, entry] of Object.entries(parentFolder)) { if (Array.isArray(entry)) { for ( const [path, options] of entry.slice(