From 0bb96cde726127291dccb62145e76a50b2efcd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 16 Apr 2022 14:09:07 +0200 Subject: refactor: update runtime code for primordial check x in y (#13642) Co-authored-by: Yoshiya Hinosawa --- ext/console/02_console.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'ext/console/02_console.js') diff --git a/ext/console/02_console.js b/ext/console/02_console.js index a16095179..d29bee801 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -107,6 +107,7 @@ ReflectGet, ReflectGetOwnPropertyDescriptor, ReflectGetPrototypeOf, + ReflectHas, WeakMapPrototype, WeakSetPrototype, } = window.__bootstrap.primordials; @@ -327,7 +328,10 @@ function inspectFunction(value, level, inspectOptions) { const cyan = maybeColor(colors.cyan, inspectOptions); - if (customInspect in value && typeof value[customInspect] === "function") { + if ( + ReflectHas(value, customInspect) && + typeof value[customInspect] === "function" + ) { return String(value[customInspect](inspect)); } // Might be Function/AsyncFunction/GeneratorFunction/AsyncGeneratorFunction @@ -1203,7 +1207,10 @@ inspectOptions, proxyDetails, ) { - if (customInspect in value && typeof value[customInspect] === "function") { + if ( + ReflectHas(value, customInspect) && + typeof value[customInspect] === "function" + ) { return String(value[customInspect](inspect)); } // This non-unique symbol is used to support op_crates, ie. @@ -1212,7 +1219,7 @@ // Internal only, shouldn't be used by users. const privateCustomInspect = SymbolFor("Deno.privateCustomInspect"); if ( - privateCustomInspect in value && + ReflectHas(value, privateCustomInspect) && typeof value[privateCustomInspect] === "function" ) { // TODO(nayeemrmn): `inspect` is passed as an argument because custom @@ -2048,8 +2055,8 @@ const valueObj = value || {}; const keys = properties || ObjectKeys(valueObj); for (const k of keys) { - if (!primitive && k in valueObj) { - if (!(k in objectValues)) { + if (!primitive && ReflectHas(valueObj, k)) { + if (!(ReflectHas(objectValues, k))) { objectValues[k] = ArrayPrototypeFill(new Array(numRows), ""); } objectValues[k][idx] = stringifyValue(valueObj[k]); -- cgit v1.2.3