Skip to content

Instantly share code, notes, and snippets.

@jupemara
Created January 6, 2016 06:11
Show Gist options
  • Save jupemara/52e6fda6a73686a3b930 to your computer and use it in GitHub Desktop.
Save jupemara/52e6fda6a73686a3b930 to your computer and use it in GitHub Desktop.
Promise with coffee-script
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