Created
January 6, 2016 06:11
-
-
Save jupemara/52e6fda6a73686a3b930 to your computer and use it in GitHub Desktop.
Promise with coffee-script
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
Promise = require 'bluebird' | |
fn = (num) -> | |
return new Promise (resolve, reject) -> | |
if num is 1 | |
reject new Error "Invalid number #{num}" | |
resolve num | |
fn(1) | |
.then (num) -> | |
console.log num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment