Fix Set size querying

This commit is contained in:
James Sumners 2023-02-21 17:58:37 -05:00
parent cc042f9a27
commit 0ed048233e
2 changed files with 6 additions and 6 deletions

View File

@ -14,7 +14,7 @@
* is not accepting any requests.
*/
module.exports = function enqueue (message, expect, emitter, cb) {
if (this._queue.length >= this.size || this._frozen) {
if (this._queue.size >= this.size || this._frozen) {
return false
}

View File

@ -4,13 +4,13 @@ const { test } = require('tap')
const enqueue = require('../../../../lib/client/request-queue/enqueue')
test('rejects new requests if size is exceeded', async t => {
const q = { _queue: { length: 5 }, size: 5 }
const q = { _queue: { size: 5 }, size: 5 }
const result = enqueue.call(q, 'foo', 'bar', {}, {})
t.notOk(result)
})
test('rejects new requests if queue is frozen', async t => {
const q = { _queue: { length: 0 }, size: 5, _frozen: true }
const q = { _queue: { size: 0 }, size: 5, _frozen: true }
const result = enqueue.call(q, 'foo', 'bar', {}, {})
t.notOk(result)
})
@ -18,7 +18,7 @@ test('rejects new requests if queue is frozen', async t => {
test('adds a request and returns if no timeout', async t => {
const q = {
_queue: {
length: 0,
size: 0,
add (obj) {
t.same(obj, {
message: 'foo',
@ -38,7 +38,7 @@ test('adds a request and returns if no timeout', async t => {
test('adds a request and returns timer not set', async t => {
const q = {
_queue: {
length: 0,
size: 0,
add (obj) {
t.same(obj, {
message: 'foo',
@ -61,7 +61,7 @@ test('adds a request, returns true, and clears queue', t => {
t.plan(4)
const q = {
_queue: {
length: 0,
size: 0,
add (obj) {
t.same(obj, {
message: 'foo',