Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twilio-transport

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twilio-transport - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

43

lib/transport.js

@@ -167,2 +167,4 @@ 'use strict';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, Transport);

@@ -176,3 +178,7 @@

return _this2._twilsock && _this2._twilsock.isConnected;
} }
} },
_concurrentHttpRequestLimit: { value: options.concurrentHttpRequestLimit || Infinity },
_concurrentHttpRequestCount: { value: 0, writable: true },
_requestQueue: { value: [] }
});

@@ -182,2 +188,5 @@

twilsock.connect();
twilsock.on('connected', function () {
return _this2._processQueuedRequests();
});
}

@@ -233,4 +242,20 @@ }

return sendViaTwilsock();
} else if (forceTwilsock) {
return Promise.reject(new TwilsockUnavailableError());
} else if (_this4._concurrentHttpRequestCount >= _this4._concurrentHttpRequestLimit) {
return new Promise(function (resolve, reject) {
return _this4._requestQueue.push({ sendingOptions: sendingOptions, resolve: resolve, reject: reject });
});
}
return !forceTwilsock ? sendDirectHttp() : Promise.reject(new TwilsockUnavailableError());
_this4._concurrentHttpRequestCount++;
return sendDirectHttp().then(function (r) {
_this4._concurrentHttpRequestCount--;
_this4._processQueuedRequests();
return r;
}).catch(function (err) {
_this4._concurrentHttpRequestCount--;
_this4._processQueuedRequests();
throw err;
});
};

@@ -246,2 +271,16 @@

}, {
key: '_processQueuedRequests',
value: function _processQueuedRequests() {
while (this._requestQueue.length > 0 && (this._twilsockIsAvailable || this._concurrentHttpRequestCount < this._concurrentHttpRequestLimit)) {
var r = this._requestQueue.shift();
this._oneOfBasedOnChannelAvailability(r.sendingOptions, false).then(r.resolve).catch(r.reject);
}
}
/**
* @private
*/
}, {
key: '_get',

@@ -248,0 +287,0 @@ value: function _get(uri, headers, forceTwilsock) {

2

package.json
{
"name": "twilio-transport",
"version": "0.1.1",
"version": "0.1.2",
"description": "Twilio generic transport interface",

@@ -5,0 +5,0 @@ "main": "lib/transport.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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