Skip to content

Instantly share code, notes, and snippets.

View s-taylor's full-sized avatar

Simon Taylor s-taylor

View GitHub Profile
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:22
Understanding async await - part 2
someAsyncThing()
.then(result => { ... })
@s-taylor
s-taylor / example.js
Last active September 22, 2017 05:33
Understanding async await - part 3
await Promise.reject(new Error('Boom'));
@s-taylor
s-taylor / example.js
Created September 22, 2017 05:33
Understanding async await - part 4
throw new Error('Boom');
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:25
Understanding async await - part 5
async function () {
// someAsyncThing being a function that returns a promise
  const result = await someAsyncThing();
  return result.value;
}
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:25
Understanding async await - part 6
function () {
// someAsyncThing being a function that returns a promise
 return someAsyncThing()
 .then(result => result.value);
}
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:35
Understanding async await - part 7
async function someFunc () {
 // since we’re using await on someAsyncThing and the promise rejected
// this line will now throw it will throw `new Error('Boom')`
  const result = await someAsyncThing();
 // this line will not execute
 return result.value;
}
// externally we’ll get a rejected promise returned containing `Error('Boom')`
await someFunc();
// But since we’re using await here, the rejected promise gets turned back
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:44
Understanding async await - part 8
function fetchStuff(data) {
  const page = data.page;
return fetchResults(page)
  .then(res => res.results);
}
fetchStuff()
.catch(err => { /* handle error here */ });
@s-taylor
s-taylor / example.js
Last active September 27, 2017 22:52
Understanding async await - part 9
async function fetchStuff(data) {
  const page = data.page;
const results = await fetchResults(page);
  return res.results;
}
fetchStuff()
.catch(err => { /* handle error here */ });
@s-taylor
s-taylor / example.js
Created September 27, 2017 22:54
Understanding async await - part 10
function fetchStuff(data) {
  try {
  const page = data.page;
return fetchResults(page)
 .then(res => res.results);
  } catch (err) {
  return Promise.reject(err);
  }
}
@s-taylor
s-taylor / README.md
Created May 6, 2020 06:08 — forked from borekb/README.md
How to link to headings in GitHub issues and pull requests

How to link to headings in GitHub issues and pull requests

If you have an issue comment / PR description on GitHub, it doesn't automatically get anchors / IDs that you could link to:

Screenshot 2019-07-11 at 13

What I like to do is to add a visible # character like this:

Screenshot 2019-07-11 at 13 42 21