node package manager


build status Confetti

Confetti is a promise decorator built on top of rsvp.js. With Confetti, you can easily define promise constructors that have custom functions attached to the constructor's prototype. The custom functions get wrapped in a way that allows them to be called within the framework of promises. It's quite cool.

The documentation for this project is lacking and I plan on adding much more thorough documentation as soon as I can. Until then, if you have any questions about Confetti, open up an issue or contact me through whatever means works for you.


$ npm install confetti



var confetti = require('confetti');



Returns a promise constructor with each function contained in functions added to its prototype. Before being added to the constructor's prototype, each function contained in functions will be wrapped to work within the promise framework.

Async Functions

Confetti works with both sync and async functions. In order to determine whether or not the function being dealt with is sync or async, Confetti relies on the function's signature. If the function's signature contains 1 more parameter then it's being called with, Confetti will assume the function is asynchronous and that the missing argument is the callback function.

Note that Confetti is very picky about function signatures. Bad things will happen when the number of arguments a function is called with doesn't match up with the number of formal parameters. The one exception to this rule is for async functions. With async functions, you should omit the callback argument when calling them.



var confetti = require('confetti');
var Promise = confetti.define({ 
  sync: function(adjective) { 
    return 'Sync functions are ' + adjective + '!';
  async: function(adjective, cb) {
    process.nextTick(function() {
      cb(null, 'Async functions are ' + adjective + '!');
var promise = new Promise();
.value(function(result) { console.log(result); })
.sync('old school')
.value(function(result) { console.log(result); })
.error(function(err) { console.log('error is bad'); });


Async functions are hip!
Sync functions are old school!


$ cd confetti
$ npm test


Found a bug? Create an issue on GitHub.


For transparency and insight into the release cycle, releases will be numbered with the follow format:


And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit


Copyright (c) 2012 Jake Harding
Licensed under the MIT License.