GeezerVison is showing github.com — wasi: improve use of primordials · nodejs/node@bdaac04
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/wasi.js +6-7Lines changed: 6 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 | /* global WebAssembly */ |
3 | 3 | const { |
4 | 4 | ArrayIsArray, |
5 | | - ArrayPrototypeForEach, |
6 | 5 | ArrayPrototypeMap, |
| 6 | + ArrayPrototypePush, |
7 | 7 | FunctionPrototypeBind, |
8 | | - ObjectKeys, |
| 8 | + ObjectEntries, |
9 | 9 | Symbol, |
10 | 10 | } = primordials; |
11 | 11 |
|
@@ -40,7 +40,7 @@ class WASI { |
40 | 40 | for (const key in env) { |
41 | 41 | const value = env[key]; |
42 | 42 | if (value !== undefined) |
43 | | - envPairs.push(`${key}=${value}`); |
| 43 | + ArrayPrototypePush(envPairs, `${key}=${value}`); |
44 | 44 | } |
45 | 45 | } else if (env !== undefined) { |
46 | 46 | throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env); |
@@ -49,10 +49,9 @@ class WASI { |
49 | 49 | const preopenArray = []; |
50 | 50 |
|
51 | 51 | if (typeof preopens === 'object' && preopens !== null) { |
52 | | - ArrayPrototypeForEach(ObjectKeys(preopens), (key) => { |
53 | | - preopenArray.push(String(key)); |
54 | | - preopenArray.push(String(preopens[key])); |
55 | | - }); |
| 52 | + for (const [key, value] of ObjectEntries(preopens)) { |
| 53 | + ArrayPrototypePush(preopenArray, String(key), String(value)); |
| 54 | + } |
56 | 55 | } else if (preopens !== undefined) { |
57 | 56 | throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens); |
58 | 57 | } |
|