Last active
October 28, 2023 21:37
-
-
Save aeinbu/3f61a29906a17eaf55c150c71f5f2f97 to your computer and use it in GitHub Desktop.
Snippets to aid debugging collections transformations (map/filter/reduce) and promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"console.log(\"***\", ...)": { | |
"prefix": "conso", | |
"scope": "javascript,typescript,typescriptreact", | |
"body": [ | |
"console.log(\"*** $1\", $0)", | |
"" | |
] | |
}, | |
"debug-map":{ | |
"prefix": "debug-map", | |
"scope": "javascript,typescript,typescriptreact", | |
"body": [ | |
".map(res => { console.log(\"DEBUG-MAP ***\", res); return res;})" | |
] | |
}, | |
"debug-then":{ | |
"prefix": "debug-then", | |
"scope": "javascript,typescript,typescriptreact", | |
"body": [ | |
".then(res => { console.log(\"DEBUG-THEN ***\", res); return res;})" | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"debug-map":{ | |
"prefix": "debug-map", | |
"body": [ | |
".map(res => { console.log(\"DEBUG-MAP ***\", res); return res;})" | |
] | |
}, | |
"debug-reduce":{ | |
"prefix": "debug-reduce", | |
"body": [ | |
".reduce((acc, cur, ix, src) => { if(ix === src.length - 1) console.log(\"DEBUG-REDUCE ***\", src); return src;}, [])" | |
] | |
}, | |
"debug-then":{ | |
"prefix": "debug-then", | |
"body": [ | |
".then(res => { console.log(\"DEBUG-THEN ***\", res); return res;})" | |
] | |
}, | |
"conso":{ | |
"prefix": "console", | |
"body": [ | |
"console.log(\"*** $1\", $0);", | |
"" | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Element": { | |
"prefix": "<", | |
"body": [ | |
"<$1>$2</$1>$0", | |
], | |
"description": "Creates a React fragment" | |
}, | |
"Self closed element": { | |
"prefix": "</", | |
"body": [ | |
"<$1/>$0", | |
], | |
"description": "Creates a React fragment" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this?
These are snippets for debugging javascript, wrapped and ready to use with Visual Studio Code.
When debugging complex chained collection expressions or promise chains, it is often helpfull to see intermediate results in between the different chained steps. By inserting the one-liners these helpers represent you can achieve this without breaking up your code to insert temporaty variable.
Use with collections
Use with promises