mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
wasi: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36724 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
e3a091d9f3
commit
d5a9799e76
1 file changed
+12
-7
+12
-7
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
const {
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypePush,
|
||||
FunctionPrototypeBind,
|
||||
@@ -62,18 +63,22 @@ class WASI {
|
||||
const env = [];
|
||||
if (options.env !== undefined) {
|
||||
validateObject(options.env, 'options.env');
|
||||
for (const [key, value] of ObjectEntries(options.env)) {
|
||||
if (value !== undefined)
|
||||
ArrayPrototypePush(env, `${key}=${value}`);
|
||||
}
|
||||
ArrayPrototypeForEach(
|
||||
ObjectEntries(options.env),
|
||||
({ 0: key, 1: value }) => {
|
||||
if (value !== undefined)
|
||||
ArrayPrototypePush(env, `${key}=${value}`);
|
||||
});
|
||||
}
|
||||
|
||||
const preopens = [];
|
||||
if (options.preopens !== undefined) {
|
||||
validateObject(options.preopens, 'options.preopens');
|
||||
for (const [key, value] of ObjectEntries(options.preopens)) {
|
||||
ArrayPrototypePush(preopens, String(key), String(value));
|
||||
}
|
||||
ArrayPrototypeForEach(
|
||||
ObjectEntries(options.preopens),
|
||||
({ 0: key, 1: value }) =>
|
||||
ArrayPrototypePush(preopens, String(key), String(value))
|
||||
);
|
||||
}
|
||||
|
||||
const { stdin = 0, stdout = 1, stderr = 2 } = options;
|
||||
|
||||
Reference in new issue
Block a user