diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-01-26 20:26:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 16:56:42 +0530 |
commit | 7b6339da6a22c361747d68945fe8aca3f78f013b (patch) | |
tree | a2472b6e036f1dd711fe9a8eb44e439c015f344e /core/01_core.js | |
parent | 87c2493855e73fb433b965040bb64cc51632c454 (diff) |
fix(core): Add lint check for core (#17223)
The prefer-primordials lint was skipped for `core/*.js`.
Diffstat (limited to 'core/01_core.js')
-rw-r--r-- | core/01_core.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/core/01_core.js b/core/01_core.js index 0b0804662..d3cd1d7be 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -9,22 +9,27 @@ SyntaxError, TypeError, URIError, - Map, Array, + ArrayFrom, ArrayPrototypeFill, + ArrayPrototypeJoin, ArrayPrototypePush, ArrayPrototypeMap, ErrorCaptureStackTrace, + Function, Promise, + ObjectAssign, ObjectFromEntries, + ObjectPrototypeHasOwnProperty, + Map, MapPrototypeGet, MapPrototypeHas, MapPrototypeDelete, MapPrototypeSet, PromisePrototypeThen, - PromisePrototypeFinally, + ReflectApply, + SafePromisePrototypeFinally, StringPrototypeSlice, - ObjectAssign, SymbolFor, setQueueMicrotask, } = window.__bootstrap.primordials; @@ -212,11 +217,17 @@ } // { <name>: <argc>, ... } - for (const ele of Object.entries(ops.asyncOpsInfo())) { - if (!ele) continue; - const [name, argc] = ele; + const info = ops.asyncOpsInfo(); + for (const name in info) { + if (!ObjectPrototypeHasOwnProperty(info, name)) { + continue; + } + const argc = info[name]; const op = ops[name]; - const args = Array.from({ length: argc }, (_, i) => `arg${i}`).join(", "); + const args = ArrayPrototypeJoin( + ArrayFrom({ length: argc }, (_, i) => `arg${i}`), + ", ", + ); ops[name] = genAsyncOp(op, name, args); } } @@ -225,7 +236,7 @@ if (opCallTracingEnabled) { const stack = StringPrototypeSlice(new Error().stack, 6); MapPrototypeSet(opCallTraces, promiseId, { opName, stack }); - return PromisePrototypeFinally( + return SafePromisePrototypeFinally( p, () => MapPrototypeDelete(opCallTraces, promiseId), ); @@ -235,7 +246,7 @@ } function opAsync(opName, ...args) { - return ops[opName](...args); + return ReflectApply(ops[opName], ops, args); } function refOp(promiseId) { @@ -257,7 +268,7 @@ } function metrics() { - const [aggregate, perOps] = ops.op_metrics(); + const { 0: aggregate, 1: perOps } = ops.op_metrics(); aggregate.ops = ObjectFromEntries(ArrayPrototypeMap( ops.op_op_names(), (opName, opId) => [opName, perOps[opId]], |