



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
bar |
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
JSON.stringify(Array.from(document.querySelectorAll('#accordion > *')).map((node, i, items) => { | |
if (node.nodeName !== 'H2') return false | |
const next = items[i + 1] | |
return { | |
title: node.querySelector('a').innerText.trim(), | |
items: Array.from(next.querySelectorAll('#nested > *')).map((node, i, items) => { | |
if (node.nodeName !== 'H3') return false | |
const next = items[i + 1] | |
return { |
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
async function someHellComputation(initialData) { | |
const a = await fnA(initialData).catch(() => { throw 'errored on A' }) | |
const b = await fnB(a).catch(() => { throw 'errored on B' }) | |
return await fnC(b).catch(() => { throw 'errored on C' }) | |
} | |
someHellComputation(10) | |
.then(console.log) | |
.catch(console.error) |
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
const databaseGetUser = id => | |
id === 'not-exists' | |
? Promise.reject('some weird database error') | |
: Promise.resolve({id, username: 'username'}) | |
const databaseGetPosts = user => | |
user.id === 'fail-to-get-posts' | |
? Promise.reject('some weird database error for posts') | |
: Promise.resolve([{title: 'A'}, {title: 'B'}]) |
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
const databaseGetUser = id => | |
id === 'not-exists' | |
? Promise.reject('some weird database error') | |
: Promise.resolve({id, username: 'username'}) | |
const databaseGetPosts = user => | |
user.id === 'fail-to-get-posts' | |
? Promise.reject('some weird database error') | |
: Promise.resolve([{title: 'A'}, {title: 'B'}]) |
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
const databaseGetUser = id => | |
id === 'not-exists' | |
? Promise.reject('some weird database error') | |
: Promise.resolve({id, username: 'username'}) | |
function getUser(id) { | |
return databaseGetUser(id) | |
.catch(err => { throw 'user doesn\'t exists' }) | |
} |