Skip to content

Instantly share code, notes, and snippets.

View alexsvt2's full-sized avatar
๐Ÿ˜„

Alexis Lรณpez alexsvt2

๐Ÿ˜„
  • Tijuana, Baja California, Mexico
  • 06:18 (UTC -06:00)
View GitHub Profile
@alexsvt2
alexsvt2 / .block
Created March 8, 2022 14:26 — forked from mbostock/.block
Bar Chart with Negative Values
license: gpl-3.0
redirect: https://observablehq.com/@d3/diverging-bar-chart
@alexsvt2
alexsvt2 / footgun.md
Created January 15, 2021 18:12 — forked from Rich-Harris/footgun.md
Top-level `await` is a footgun

Edit โ€” February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

@alexsvt2
alexsvt2 / axios-catch-error.js
Created January 14, 2021 17:28 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success ๐ŸŽ‰
console.log(response);
} catch (error) {
// Error ๐Ÿ˜จ