value explorer for Sets and Maps

This commit is contained in:
Dmitry Vasilev
2023-08-01 00:05:04 +03:00
parent 93dc56c08d
commit 6ffc971dda
3 changed files with 23 additions and 3 deletions

View File

@@ -1,5 +1,4 @@
// TODO paging for large arrays/objects
// TODO maps, sets
// TODO show Errors in red
// TODO fns as clickable links (jump to definition), both for header and for
// content

View File

@@ -40,6 +40,12 @@ export const displayed_entries = object => {
)
} else if(Array.isArray(object)) {
return object.map((v, i) => [i, v])
} else if(object[Symbol.toStringTag] == 'Set') {
// TODO display set as list without keys as indexes, because Set in JS are
// not ordered and it would be incorrect to imply ordering
return [...object.values()].map((entry, i) => [i, entry])
} else if(object[Symbol.toStringTag] == 'Map') {
return [...object.entries()]
} else if(typeof(object.toJSON) == 'function') {
const result = toJSON_safe(object)
if(result == object) {
@@ -139,7 +145,7 @@ const header_object = object => {
return `${k}: ${value}`
})
.join(', ')
return `${prefix} {${inner}}`
return `${prefix}{${inner}}`
}
export const header = (object, no_toJSON = false) => {