mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
wasi: improve use of primordials
PR-URL: https://github.com/nodejs/node/pull/31212 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
e908323b7e
commit
b8922e8924
13
lib/wasi.js
13
lib/wasi.js
@ -2,10 +2,10 @@
|
|||||||
/* global WebAssembly */
|
/* global WebAssembly */
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeForEach,
|
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
ArrayPrototypePush,
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
ObjectKeys,
|
ObjectEntries,
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class WASI {
|
|||||||
for (const key in env) {
|
for (const key in env) {
|
||||||
const value = env[key];
|
const value = env[key];
|
||||||
if (value !== undefined)
|
if (value !== undefined)
|
||||||
envPairs.push(`${key}=${value}`);
|
ArrayPrototypePush(envPairs, `${key}=${value}`);
|
||||||
}
|
}
|
||||||
} else if (env !== undefined) {
|
} else if (env !== undefined) {
|
||||||
throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env);
|
throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env);
|
||||||
@ -49,10 +49,9 @@ class WASI {
|
|||||||
const preopenArray = [];
|
const preopenArray = [];
|
||||||
|
|
||||||
if (typeof preopens === 'object' && preopens !== null) {
|
if (typeof preopens === 'object' && preopens !== null) {
|
||||||
ArrayPrototypeForEach(ObjectKeys(preopens), (key) => {
|
for (const [key, value] of ObjectEntries(preopens)) {
|
||||||
preopenArray.push(String(key));
|
ArrayPrototypePush(preopenArray, String(key), String(value));
|
||||||
preopenArray.push(String(preopens[key]));
|
}
|
||||||
});
|
|
||||||
} else if (preopens !== undefined) {
|
} else if (preopens !== undefined) {
|
||||||
throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens);
|
throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user