Skip to content

Commit

Permalink
wasi: improve use of primordials
Browse files Browse the repository at this point in the history
PR-URL: #31212
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
cjihrig authored and MylesBorins committed Jan 16, 2020
1 parent f7833ac commit bdaac04
Showing 1 changed file with 6 additions and 7 deletions.
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

0 comments on commit bdaac04

Please sign in to comment.