(obj, ...keys)
| 239 | } |
| 240 | |
| 241 | function getBody(obj, ...keys) { |
| 242 | if (obj instanceof Promise && !("[[PromiseStatus]]" in obj)) |
| 243 | obj = getPromiseStatus(obj); |
| 244 | |
| 245 | let value = objValue(obj, ...keys); |
| 246 | const $group = tag("c-group"); |
| 247 | const $toggler = tag("c-type", { |
| 248 | attr: { |
| 249 | type: "body-toggler", |
| 250 | }, |
| 251 | textContent: value ? value.constructor.name : value + "", |
| 252 | }); |
| 253 | |
| 254 | if (value instanceof Object) { |
| 255 | $toggler.onclick = function () { |
| 256 | if (this.classList.contains("__show-data")) { |
| 257 | this.classList.remove("__show-data"); |
| 258 | $group.textContent = null; |
| 259 | return; |
| 260 | } |
| 261 | |
| 262 | this.classList.toggle("__show-data"); |
| 263 | |
| 264 | const possibleKeys = []; |
| 265 | |
| 266 | for (let key in value) { |
| 267 | possibleKeys.push(key); |
| 268 | } |
| 269 | |
| 270 | possibleKeys.push( |
| 271 | ...[ |
| 272 | ...Object.keys(value), |
| 273 | ...Object.getOwnPropertyNames(value), |
| 274 | ...Object.keys(value["__proto__"] || {}), |
| 275 | ], |
| 276 | ); |
| 277 | |
| 278 | if (value["__proto__"]) possibleKeys.push("__proto__"); |
| 279 | if (value["prototype"]) possibleKeys.push("prototype"); |
| 280 | |
| 281 | [...new Set(possibleKeys)].forEach((key) => |
| 282 | $group.append(appendProperties(obj, ...keys, key)), |
| 283 | ); |
| 284 | }; |
| 285 | $toggler.textContent = value.constructor.name; |
| 286 | } else { |
| 287 | const $val = getElement(value); |
| 288 | $val.textContent = (value ?? value + "").toString(); |
| 289 | $group.append($val); |
| 290 | } |
| 291 | |
| 292 | return [$toggler, $group]; |
| 293 | } |
| 294 | |
| 295 | function appendProperties(obj, ...keys) { |
| 296 | const key = keys.pop(); |
no test coverage detected