lib/altshift/promise.js
function (milliseconds) {
        if (milliseconds === undefined) {
            milliseconds = this._timeout;
        }

        var self = this;

        if (self._timeout !== milliseconds) {
            self._timeout = milliseconds;
            if (self._timer) {
                clearTimeout(this._timer);
                self._timer = null;
            }

            if (milliseconds) {
                this._timer = setTimeout(function () {
                    self._timer = null;
                    if (!self.finished) {
                        var error = new core.Error({
                            code: 'timeout',
                            message: 'Promise has timeout'
                        });

                        /*if (self.getPromise().cancel) {
                            self.getPromise().cancel(error);
                        } else {
                            self.emitError(error);
                        }*/

                        if (this._canceller) {
                            self.cancel(error);
                        } else {
                            self.emitError(error);
                        }
                    }
                }, milliseconds);
            }
        }
        return this;
    }
function (milliseconds) {
        if (milliseconds === undefined) {
            milliseconds = this._timeout;
        }

        var self = this;

        if (self._timeout !== milliseconds) {
            self._timeout = milliseconds;
            if (self._timer) {
                clearTimeout(this._timer);
                self._timer = null;
            }

            if (milliseconds) {
                this._timer = setTimeout(function () {
                    self._timer = null;
                    if (!self.finished) {
                        var error = new core.Error({
                            code: 'timeout',
                            message: 'Promise has timeout'
                        });

                        /*if (self.getPromise().cancel) {
                            self.getPromise().cancel(error);
                        } else {
                            self.emitError(error);
                        }*/

                        if (this._canceller) {
                            self.cancel(error);
                        } else {
                            self.emitError(error);
                        }
                    }
                }, milliseconds);
            }
        }
        return this;
    }
function ( milliseconds ) { if ( milliseconds === undefined ) { milliseconds = this . _timeout ; } var self = this ; if ( self . _timeout !== milliseconds ) { self . _timeout = milliseconds ; if ( self . _timer ) { clearTimeout ( this . _timer ) ; self . _timer = null ; } if ( milliseconds ) { this . _timer = setTimeout ( function ( ) { self . _timer = null ; if ( ! self . finished ) { var error = new core . Error ( { code : 'timeout' , message : 'Promise has timeout' } ) ; /*if (self.getPromise().cancel) {
                            self.getPromise().cancel(error);
                        } else {
                            self.emitError(error);
                        }*/ if ( this . _canceller ) { self . cancel ( error ) ; } else { self . emitError ( error ) ; } } } , milliseconds ) ; } } return this ; }
Set the timeout in milliseconds to auto cancel the promise

@param {int} milliseconds
@return this
Set the timeout in milliseconds to auto cancel the promise