Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi: improve use of primordials #31212

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* global WebAssembly */
const {
ArrayIsArray,
ArrayPrototypeForEach,
ArrayPrototypeMap,
ArrayPrototypePush,
FunctionPrototypeBind,
ObjectKeys,
ObjectEntries,
Symbol,
} = primordials;

Expand Down Expand Up @@ -40,7 +40,7 @@ class WASI {
for (const key in env) {
const value = env[key];
if (value !== undefined)
envPairs.push(`${key}=${value}`);
ArrayPrototypePush(envPairs, `${key}=${value}`);
}
} else if (env !== undefined) {
throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env);
Expand All @@ -49,10 +49,9 @@ class WASI {
const preopenArray = [];

if (typeof preopens === 'object' && preopens !== null) {
ArrayPrototypeForEach(ObjectKeys(preopens), (key) => {
preopenArray.push(String(key));
preopenArray.push(String(preopens[key]));
});
for (const [key, value] of ObjectEntries(preopens)) {
ArrayPrototypePush(preopenArray, String(key), String(value));
}
} else if (preopens !== undefined) {
throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens);
}
Expand Down