Socket
Socket
Sign inDemoInstall

superagent

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superagent - npm Package Compare versions

Comparing version 0.8.2 to 0.9.0

5

History.md
0.9.0 / 2012-08-28
==================
* add `.timeout(ms)`. Closes #17
0.8.2 / 2012-08-28

@@ -3,0 +8,0 @@ ==================

52

lib/node/index.js

@@ -132,2 +132,3 @@

this._redirectList = [];
this.on('end', this.clearTimeout.bind(this));
this.on('response', function(res){

@@ -398,2 +399,28 @@ self.callback(null, res);

/**
* Set timeout to `ms`.
*
* @param {Number} ms
* @return {Request} for chaining
* @api public
*/
Request.prototype.timeout = function(ms){
this._timeout = ms;
return this;
};
/**
* Clear previous timeout.
*
* @return {Request} for chaining
* @api public
*/
Request.prototype.clearTimeout = function(){
this._timeout = 0;
clearTimeout(this._timer);
return this;
};
/**
* Redirect to `url

@@ -519,3 +546,15 @@ *

Request.prototype.callback = function(err, res){
if (this._finished) return;
var fn = this._callback;
// flag as finished so we dont
// get double-callbacks
this._finished = true;
// ignore errors, at this point
// they dont matter anymore
this.on('error', noop);
// invoke callback
if (2 == fn.length) return fn(err, res);

@@ -539,3 +578,4 @@ fn(res); // TODO: emit error

, buffer = this._buffer
, method = this.method;
, method = this.method
, timeout = this._timeout;

@@ -545,2 +585,12 @@ // store callback

// timeout
if (timeout && !this._timer) {
this._timer = setTimeout(function(){
var err = new Error('timeout of ' + timeout + 'ms exceeded');
err.timeout = timeout;
self.callback(err);
req.abort();
}, timeout);
}
// body

@@ -547,0 +597,0 @@ switch (method) {

2

package.json
{
"name": "superagent"
, "version": "0.8.2"
, "version": "0.9.0"
, "description": "elegant & feature rich browser / node HTTP with a fluent API"

@@ -5,0 +5,0 @@ , "keywords": ["http", "ajax", "request", "agent"]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc