Socket
Socket
Sign inDemoInstall

limited-request-queue

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

48

lib-es5/index.js

@@ -122,10 +122,10 @@ "use strict";

_options.set(_assertThisInitialized(_this), {
_isPaused.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
value: false
});
_paused.set(_assertThisInitialized(_this), {
_options.set(_assertThisInitialized(_this), {
writable: true,
value: false
value: void 0
});

@@ -160,5 +160,3 @@

key: "enqueue",
value: function enqueue(url, data) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _classPrivateFieldGet(this, _options);
value: function enqueue(url, data, options) {
if (!_isurl["default"].lenient(url)) {

@@ -195,5 +193,10 @@ throw new TypeError("Invalid URL");

}, {
key: "has",
value: function has(id) {
return id in _classPrivateFieldGet(this, _items);
}
}, {
key: "pause",
value: function pause() {
_classPrivateFieldSet(this, _paused, true);
_classPrivateFieldSet(this, _isPaused, true);

@@ -210,3 +213,3 @@ return this;

value: function resume() {
_classPrivateFieldSet(this, _paused, false);
_classPrivateFieldSet(this, _isPaused, false);

@@ -220,3 +223,3 @@ _classPrivateMethodGet(this, _maybeStartNext, _maybeStartNext2).call(this);

get: function get() {
return _classPrivateFieldGet(this, _paused);
return _classPrivateFieldGet(this, _isPaused);
}

@@ -259,6 +262,6 @@ }, {

var _isPaused = new WeakMap();
var _options = new WeakMap();
var _paused = new WeakMap();
var _dequeueItem = new WeakSet();

@@ -282,8 +285,5 @@

var _emit2 = function _emit2(event) {
var _emit2 = function _emit2(event, args, timeout) {
var _this2 = this;
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
if (timeout > 0) {

@@ -319,7 +319,7 @@ setTimeout(function () {

if (!_classPrivateFieldGet(this, _paused) && availableSockets > 0) {
if (!_classPrivateFieldGet(this, _isPaused) && availableSockets > 0) {
var i = 0;
while (i < _classPrivateFieldGet(this, _priorityQueue).length) {
var _item$options$maxSock;
var _ref2, _item$options;

@@ -330,3 +330,3 @@ var canStart = false;

var maxSocketsPerHost = (_item$options$maxSock = item.options.maxSocketsPerHost) !== null && _item$options$maxSock !== void 0 ? _item$options$maxSock : _classPrivateFieldGet(this, _options).maxSocketsPerHost; // Not important, but feature complete
var maxSocketsPerHost = (_ref2 = (_item$options = item.options) === null || _item$options === void 0 ? void 0 : _item$options.maxSocketsPerHost) !== null && _ref2 !== void 0 ? _ref2 : _classPrivateFieldGet(this, _options).maxSocketsPerHost; // Not important, but feature complete

@@ -345,3 +345,3 @@ if (maxSocketsPerHost > 0) {

if (canStart) {
var _this$activeSockets2, _item$options$rateLim;
var _this$activeSockets2, _ref3, _item$options2;

@@ -354,3 +354,3 @@ _classPrivateFieldSet(this, _activeSockets, (_this$activeSockets2 = +_classPrivateFieldGet(this, _activeSockets)) + 1), _this$activeSockets2;

var rateLimit = (_item$options$rateLim = item.options.rateLimit) !== null && _item$options$rateLim !== void 0 ? _item$options$rateLim : _classPrivateFieldGet(this, _options).rateLimit;
var rateLimit = (_ref3 = (_item$options2 = item.options) === null || _item$options2 === void 0 ? void 0 : _item$options2.rateLimit) !== null && _ref3 !== void 0 ? _ref3 : _classPrivateFieldGet(this, _options).rateLimit;

@@ -370,5 +370,5 @@ _classPrivateMethodGet(this, _emit, _emit2).call(this, ITEM_EVENT, [item.url, item.data, _classPrivateMethodGet(this, _getDoneCallback, _getDoneCallback2).call(this, item)], rateLimit);

var _removeItem2 = function _removeItem2(_ref2) {
var hostKey = _ref2.hostKey,
id = _ref2.id;
var _removeItem2 = function _removeItem2(_ref4) {
var hostKey = _ref4.hostKey,
id = _ref4.id;

@@ -375,0 +375,0 @@ if (--_classPrivateFieldGet(this, _activeHosts)[hostKey] <= 0) {

@@ -30,4 +30,4 @@ import {EventEmitter} from "events";

#idCounter = 0;
#isPaused = false;
#options;
#paused = false;

@@ -78,7 +78,6 @@

* @param {string} event
* @param {Array} [args]
* @param {number} [timeout]
* @todo try/catch and emit "error" event?
* @param {Array} args
* @param {number} timeout
*/
#emit2(event, args=[], timeout=0)
#emit2(event, args, timeout)
{

@@ -97,3 +96,3 @@ if (timeout > 0)

enqueue(url, data, options=this.#options)
enqueue(url, data, options)
{

@@ -138,5 +137,12 @@ if (!isURL.lenient(url))

has(id)
{
return id in this.#items;
}
get isPaused()
{
return this.#paused;
return this.#isPaused;
}

@@ -160,3 +166,3 @@

if (!this.#paused && availableSockets > 0)
if (!this.#isPaused && availableSockets>0)
{

@@ -170,3 +176,3 @@ let i = 0;

const maxSocketsPerHost = item.options.maxSocketsPerHost ?? this.#options.maxSocketsPerHost;
const maxSocketsPerHost = item.options?.maxSocketsPerHost ?? this.#options.maxSocketsPerHost;

@@ -198,3 +204,3 @@ // Not important, but feature complete

const rateLimit = item.options.rateLimit ?? this.#options.rateLimit;
const rateLimit = item.options?.rateLimit ?? this.#options.rateLimit;

@@ -235,3 +241,3 @@ this.#emit2(ITEM_EVENT, [item.url, item.data, this.#getDoneCallback(item)], rateLimit);

{
this.#paused = true;
this.#isPaused = true;
return this;

@@ -267,3 +273,3 @@ }

{
this.#paused = false;
this.#isPaused = false;
this.#maybeStartNext();

@@ -270,0 +276,0 @@ return this;

{
"name": "limited-request-queue",
"description": "Interactively manage concurrency for outbound requests.",
"version": "5.0.0",
"version": "5.1.0",
"license": "MIT",

@@ -14,14 +14,14 @@ "author": "Steven Vachon <contact@svachon.com> (https://svachon.com)",

"isurl": "^4.0.1",
"parse-domain": "^2.3.1"
"parse-domain": "^2.3.2"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
"@babel/plugin-proposal-private-methods": "^7.4.4",
"@babel/preset-env": "^7.5.5",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-proposal-private-methods": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"chai": "^4.2.0",
"coveralls": "^3.0.5",
"coveralls": "^3.0.6",
"gzip-size-cli": "^3.0.0",

@@ -31,3 +31,3 @@ "mocha": "^6.2.0",

"parcel": "^1.12.3",
"rimraf": "^2.6.3"
"rimraf": "^3.0.0"
},

@@ -34,0 +34,0 @@ "engines": {

@@ -65,2 +65,5 @@ # limited-request-queue [![NPM Version][npm-image]][npm-url] ![File Size][filesize-image] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]

### `.has(id)`
Returns `true` if the queue contains an active or queued item tagged with `id` and `false` if not.
### `.isPaused`

@@ -67,0 +70,0 @@ Returns `true` if the queue is currently paused and `false` if not.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc