Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d5a9799

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
wasi: refactor to avoid unsafe array iteration
PR-URL: #36724 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e3a091d commit d5a9799
Copy full SHA for d5a9799

File tree

Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed
Open diff view settings
Collapse file

‎lib/wasi.js‎

Copy file name to clipboardExpand all lines: lib/wasi.js
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const {
3+
ArrayPrototypeForEach,
34
ArrayPrototypeMap,
45
ArrayPrototypePush,
56
FunctionPrototypeBind,
@@ -62,18 +63,22 @@ class WASI {
6263
const env = [];
6364
if (options.env !== undefined) {
6465
validateObject(options.env, 'options.env');
65-
for (const [key, value] of ObjectEntries(options.env)) {
66-
if (value !== undefined)
67-
ArrayPrototypePush(env, `${key}=${value}`);
68-
}
66+
ArrayPrototypeForEach(
67+
ObjectEntries(options.env),
68+
({ 0: key, 1: value }) => {
69+
if (value !== undefined)
70+
ArrayPrototypePush(env, `${key}=${value}`);
71+
});
6972
}
7073

7174
const preopens = [];
7275
if (options.preopens !== undefined) {
7376
validateObject(options.preopens, 'options.preopens');
74-
for (const [key, value] of ObjectEntries(options.preopens)) {
75-
ArrayPrototypePush(preopens, String(key), String(value));
76-
}
77+
ArrayPrototypeForEach(
78+
ObjectEntries(options.preopens),
79+
({ 0: key, 1: value }) =>
80+
ArrayPrototypePush(preopens, String(key), String(value))
81+
);
7782
}
7883

7984
const { stdin = 0, stdout = 1, stderr = 2 } = options;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.