diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-02-09 15:31:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 16:31:46 +0100 |
commit | 900953a65a7cb54eb8d11eba4a30e52da7dbb469 (patch) | |
tree | 7ca5b7b8261ffd92c945c618ac8bf9eaf15f5ceb /op_crates/web/01_event.js | |
parent | 47b3e4bada01f29a6cf2a143b94d772242bbab67 (diff) |
fix(op_crates): Don't use `Deno.inspect` in op crates (#9332)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'op_crates/web/01_event.js')
-rw-r--r-- | op_crates/web/01_event.js | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/op_crates/web/01_event.js b/op_crates/web/01_event.js index 3fd4841a8..91ae2ef68 100644 --- a/op_crates/web/01_event.js +++ b/op_crates/web/01_event.js @@ -143,8 +143,8 @@ }); } - [Symbol.for("Deno.customInspect")]() { - return buildCustomInspectOutput(this, EVENT_PROPS); + [Symbol.for("Deno.customInspect")](inspect) { + return buildCustomInspectOutput(this, EVENT_PROPS, inspect); } get bubbles() { @@ -387,14 +387,9 @@ } } - function buildCustomInspectOutput(obj, props) { - const inspectObj = {}; - - for (const prop of props) { - inspectObj[prop] = obj[prop]; - } - - return `${obj.constructor.name} ${Deno.inspect(inspectObj)}`; + function buildCustomInspectOutput(object, keys, inspect) { + const inspectObject = Object.fromEntries(keys.map((k) => [k, object[k]])); + return `${object.constructor.name} ${inspect(inspectObject)}`; } function defineEnumerableProps( @@ -1041,7 +1036,7 @@ return "ErrorEvent"; } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](inspect) { return buildCustomInspectOutput(this, [ ...EVENT_PROPS, "message", @@ -1049,7 +1044,7 @@ "lineno", "colno", "error", - ]); + ], inspect); } } @@ -1095,13 +1090,13 @@ this.#reason = reason; } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](inspect) { return buildCustomInspectOutput(this, [ ...EVENT_PROPS, "wasClean", "code", "reason", - ]); + ], inspect); } } @@ -1118,13 +1113,13 @@ this.lastEventId = eventInitDict?.lastEventId ?? ""; } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](inspect) { return buildCustomInspectOutput(this, [ ...EVENT_PROPS, "data", "origin", "lastEventId", - ]); + ], inspect); } } @@ -1146,11 +1141,11 @@ return "CustomEvent"; } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](inspect) { return buildCustomInspectOutput(this, [ ...EVENT_PROPS, "detail", - ]); + ], inspect); } } @@ -1169,13 +1164,13 @@ this.total = eventInitDict?.total ?? 0; } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](inspect) { return buildCustomInspectOutput(this, [ ...EVENT_PROPS, "lengthComputable", "loaded", "total", - ]); + ], inspect); } } |