Decorator for Yapa promises


Yapawapa is a decorator of Yapa promises. It makes it easy to add arbitrary functions to the prototype of a Yapa promise constructor. Those functions can then seamlessly be used within a promise chain.

$ npm install yapawapa
var yapawapa = require('yapawapa');

Returns a promise constructor whose prototype has been decorated with decorations. Functions found in decorations will be wrapped so that they can be used seamlessly in a promise chain. Getters and setters in decorations will be wrapped so that they are called on the underlying context of the promise instance.

The promise constructor generated by decorate. All functions that were added through decorate will be called in the context of context. All getters and setters will be read/write-throughs to the matching properties of context.

var Promise = yapawapa.decorate({
  get name() {
    return this.name;
, syncMethodfunction() { 
    return this.name + ' sync'; 
, asyncMethodfunction(cb) { 
    process.nextTick( function() { cb(null, this.name + ' async'); });
var promise = Promise({ name: 'yapawapa' });
assert.equal(promise.name, 'yapawapa');
.values(function(syncValueasyncValue) {
  assert.equal(syncValue, 'yapawapa is sync');
  assert.equal(asyncValue, 'yapawapa is async');
$ cd yapawapa
$ 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 http://semver.org/.

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