lib/vow.js
function(timeout) {
        var defer = new Deferred(),
            timer = setTimeout(
                function() {
                    defer.reject(new vow.TimedOutError('timed out'));
                },
                timeout);

        this.then(
            function(val) {
                defer.resolve(val);
            },
            function(reason) {
                defer.reject(reason);
            });

        defer.promise().always(function() {
            clearTimeout(timer);
        });

        return defer.promise();
    }
function(timeout) {
        var defer = new Deferred(),
            timer = setTimeout(
                function() {
                    defer.reject(new vow.TimedOutError('timed out'));
                },
                timeout);

        this.then(
            function(val) {
                defer.resolve(val);
            },
            function(reason) {
                defer.reject(reason);
            });

        defer.promise().always(function() {
            clearTimeout(timer);
        });

        return defer.promise();
    }
function ( timeout ) { var defer = new Deferred ( ) , timer = setTimeout ( function ( ) { defer . reject ( new vow . TimedOutError ( 'timed out' ) ) ; } , timeout ) ; this . then ( function ( val ) { defer . resolve ( val ) ; } , function ( reason ) { defer . reject ( reason ) ; } ) ; defer . promise ( ) . always ( function ( ) { clearTimeout ( timer ) ; } ) ; return defer . promise ( ) ; }
Returns a new promise that will be rejected in `timeout` milliseconds
if the promise is not resolved beforehand.

@param {Number} timeout
@returns {vow:Promise}

@example
```js
var defer = vow.defer(),
promiseWithTimeout1 = defer.promise().timeout(50),
promiseWithTimeout2 = defer.promise().timeout(200);

setTimeout(
function() {
defer.resolve('ok');
},
100);

promiseWithTimeout1.fail(function(reason) {
// promiseWithTimeout to be rejected in 50ms
});

promiseWithTimeout2.then(function(value) {
// promiseWithTimeout to be fulfilled with "'ok'" value
});
```
Returns a new promise that will be rejected in timeout milliseconds if the promise is not resolved beforehand .