lib/promise.js
function (callback, errback) {
            var promise = new Promise(),
                self = this;

            function _errback(e) {
                if (isFunction(errback)) {
                    try {
                        var res = spreadArgs(errback, [e]);
                        isPromiseLike(res) ? res.then(promise.callback, promise.errback) : promise.callback(res);
                    } catch (e) {
                        promise.errback(e);
                    }
                } else {
                    promise.errback(e);
                }
            }

            function _callback() {
                try {
                    var res = isFunction(callback) ? spreadArgs(callback, arguments) : callback;
                    if (isPromiseLike(res)) {
                        res.then(promise.callback, _errback);
                    } else {
                        promise.callback(res);
                        promise = null;
                    }
                    callback = res = null;
                } catch (e) {
                    _errback(e);
                }
            }

            self.addCallback(_callback);
            self.addErrback(_errback);
            return promise.promise();
        }
function (callback, errback) {
            var promise = new Promise(),
                self = this;

            function _errback(e) {
                if (isFunction(errback)) {
                    try {
                        var res = spreadArgs(errback, [e]);
                        isPromiseLike(res) ? res.then(promise.callback, promise.errback) : promise.callback(res);
                    } catch (e) {
                        promise.errback(e);
                    }
                } else {
                    promise.errback(e);
                }
            }

            function _callback() {
                try {
                    var res = isFunction(callback) ? spreadArgs(callback, arguments) : callback;
                    if (isPromiseLike(res)) {
                        res.then(promise.callback, _errback);
                    } else {
                        promise.callback(res);
                        promise = null;
                    }
                    callback = res = null;
                } catch (e) {
                    _errback(e);
                }
            }

            self.addCallback(_callback);
            self.addErrback(_errback);
            return promise.promise();
        }
function ( callback , errback ) { var promise = new Promise ( ) , self = this ; function _errback ( e ) { if ( isFunction ( errback ) ) { try { var res = spreadArgs ( errback , [ e ] ) ; isPromiseLike ( res ) ? res . then ( promise . callback , promise . errback ) : promise . callback ( res ) ; } catch ( e ) { promise . errback ( e ) ; } } else { promise . errback ( e ) ; } } function _callback ( ) { try { var res = isFunction ( callback ) ? spreadArgs ( callback , arguments ) : callback ; if ( isPromiseLike ( res ) ) { res . then ( promise . callback , _errback ) ; } else { promise . callback ( res ) ; promise = null ; } callback = res = null ; } catch ( e ) { _errback ( e ) ; } } self . addCallback ( _callback ) ; self . addErrback ( _errback ) ; return promise . promise ( ) ; }
Call to chaining of promises

```
new Promise()
.callback("hello")
.chain(function(previousPromiseResults){
return previousPromiseResults + " world";
}, errorHandler)
.chain(function(previousPromiseResults){
return when(dbCall());
}).classic(function(err, results){
//all promises are done
});

```

You can also use static values

```
new Promise().callback()
.chain("hello")
.chain(function(prev){
return prev + " world!"
}).then(function(str){
console.log(str); //"hello world!"
});
```

If you do not provide an `errback` for each chain then it will be propogated to the final promise


```
new Promise()
.chain(function(){
return new comb.Promise().errback(new Error("error"));
})
.chain(function(){
return prev + " world!"
})
.classic(function(err, str){
console.log(err.message); //"error"
});
```


@param callback method to call this one completes. If you return a promise the execution will delay until the returned promise has resolved.
@param [errback=null] method to call if this promise errors. If errback is not specified then the returned promises
errback method will be used.

@return {comb.Promise} A new that wraps the promise for chaining
Call to chaining of promises