Skip to content

Instantly share code, notes, and snippets.

@nour-s
Last active April 16, 2022 19:44
Show Gist options
  • Save nour-s/bc4bd95ece64cbbc09eca90d4ed2958f to your computer and use it in GitHub Desktop.
Save nour-s/bc4bd95ece64cbbc09eca90d4ed2958f to your computer and use it in GitHub Desktop.

Those are some snippets that I made to help me use the extention vscode-debug-visualizer

Visualize a JS map

image

Make sure the variable name is map or change the snippet below to use the right name.

{
    "kind": { "grid": true },
    "text": "A map visualization",
    "columnLabels": [
        {
            "label": "test"
        }
    ],
    "rows": [
        {
            "label": "keys",
            "columns":
                Array.from(map.keys()).map(key => ({ "content": `${key}`, "tag": `${key}` }))
        },
        {
            "label": "values",
            "columns":
                Array.from(map.values()).map(value => ({ "content": `${value}`, "tag": `${value}` }))
        }
    ]
}

Or as a table

{ 
kind: { table: true },
rows: [...map].map(([k, v]) => ({ key: k, value: v })) 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment