Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Created October 2, 2017 03:42
Show Gist options
  • Save VitorLuizC/16edb4af3ee7b1fe7a5b21a8f32b8f73 to your computer and use it in GitHub Desktop.
Save VitorLuizC/16edb4af3ee7b1fe7a5b21a8f32b8f73 to your computer and use it in GitHub Desktop.
const divide = (...values) => {
divide.before(...values)
try {
const result = values.reduce((a, b) => a / b, 0)
divide.success(result, ...values)
divide.after(...values)
return result
} catch (error) {
divide.failure(error, ...values)
divide.after(...values)
}
}
divide.before = (...values) => console.log('Before: ' + values.join(' % '))
divide.success = (result, ...values) => console.log('Success: ' + values.join(' % ') + ' = ' + result)
divide.failure = (error, ...values) => console.log('Failure: ' + values.join(' % ') + ' = ' + error.message)
divide.after = (...values) => console.log('After: ' + values.join(' % '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment