This file contains hidden or 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
| Promise.reject('some error') | |
| .catch(err => { throw 'earth is not flat' }) // runs | |
| .catch(err => console.log(err)) // logs 'earth is not flat' |
This file contains hidden or 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
| Promise.reject('some error') | |
| .catch(err => { throw err }) // runs | |
| .catch(err => console.log(2)) // runs |
This file contains hidden or 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
| Promise.reject('some error') | |
| .catch(err => console.log(1)) // runs | |
| .catch(err => console.log(2)) // never runs |
This file contains hidden or 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
| function someHellComputation(initialData) { | |
| return fnA(initialData) | |
| .then(fnB) | |
| .then(fnC) | |
| } | |
| someHellComputation(10) | |
| .then(console.log) | |
| .catch(err => { | |
| // where does err come from: fnA, fnB, fnC? |
This file contains hidden or 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
| function someHellComputation(initialData) { | |
| return fnA(initialData) | |
| .then(fnB) | |
| .then(fnC) | |
| } | |
| someHellComputation(10) | |
| .then(console.log) | |
| .catch(console.error) |
This file contains hidden or 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
| function someHellComputation(initialData, callback) { | |
| fnA(initialData, (err, intermediateData) => { | |
| if (err) return callback(err) | |
| fnB(intermediateData, (err, anotherData) => { | |
| if (err) return callback(err) | |
| fnC(anotherData), (err, finalData) => { | |
| if (err) return callback(err) | |
| callback(null, finalData) |
This file contains hidden or 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 arr = [ | |
| { | |
| id: 10, | |
| title: "Test 10", | |
| item: "Item 1" | |
| }, | |
| { | |
| id: 10, | |
| title: "Test 10", | |
| item: "Item 2" |
This file contains hidden or 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
| import lazyLoadingRoutes from '../../support/lazyLoadingRoutes' | |
| export default lazyLoadingRoutes([ | |
| { path: '/login', component: 'Login', meta: { requiresAuth: false } }, | |
| { path: '/forgotPassword', component: 'ForgotPassword', meta: { requiresAuth: false } }, | |
| { path: '/forgotEmail', component: 'ForgotEmail', meta: { requiresAuth: false } }, | |
| { path: '/createAccount', component: 'CreateAccount', meta: { requiresAuth: false } } | |
| ]) | |
This file contains hidden or 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
| module.exports = { | |
| async signup(name, email, password) { | |
| const exists = await models.user.findOne({ where: { email } }) | |
| if (exists) { | |
| throw new Error({ error: 'E-mail já existe. Tente se registrar com outro.' }) | |
| } | |
| const passwordEncrypted = await hashing(password) |
This file contains hidden or 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 R = require('ramda') | |
| const | |
| divisibleBy = (n, x) => x % n === 0 | |
| , odd = R.compose(R.not, R.partial(divisibleBy, [2])) | |
| , fizzbuzz = x => | |
| R.ifElse( | |
| R.pipe(R.length, R.equals(0)) |