Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 16, 2013 13:27
Show Gist options
  • Select an option

  • Save cuipengfei/7986907 to your computer and use it in GitHub Desktop.

Select an option

Save cuipengfei/7986907 to your computer and use it in GitHub Desktop.
promise it wont hurt values and promises
var q = require('q');
var defer = q.defer();
function attachTitle(name) {
return "DR. " + name
}
defer.promise
.then(attachTitle)
.then(console.log)
defer.resolve("MANHATTAN")
// prove to yourself
// that promise handlers will wrap your returned values in promises
// allowing additional chaining.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment