diff --git a/lib/wasi.js b/lib/wasi.js index eef36d24d487e7..ea2e2b794b22d7 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -2,10 +2,10 @@ /* global WebAssembly */ const { ArrayIsArray, - ArrayPrototypeForEach, ArrayPrototypeMap, + ArrayPrototypePush, FunctionPrototypeBind, - ObjectKeys, + ObjectEntries, Symbol, } = primordials; const { @@ -39,7 +39,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); @@ -48,10 +48,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); }