Skip to content

Commit e05efb0

Browse files
committed
Changed 'complete' event to 'end' in order to be consistent with the rest of NGN
1 parent 4a9e994 commit e05efb0

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngnjs/queue",
3-
"version": "1.0.0-alpha.5",
3+
"version": "1.0.0-alpha.6",
44
"description": "A lightweight NGN queue (taskrunner).",
55
"type": "module",
66
"main": "src/index.js",

src/item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class Item extends NGN.EventEmitter {
1616
#done = () => {
1717
clearTimeout(this.#timer)
1818
this.#status = 'complete'
19-
this.emit('complete', this)
19+
this.emit('end', this)
2020
this.emit('done')
2121
INFO('QUEUE.TASK.DONE', `Finished processing ${this._dsc}.`)
2222
}

src/runner.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default class Queue extends EventEmitter {
4545
moduleVersion: NGN.hiddenconstant('<#REPLACE_VERSION#>')
4646
})
4747

48-
this.on('complete', () => this.reset())
48+
this.on('end', () => this.reset())
4949

5050
// Add the cancel alias.
5151
this.alias('cancel', this.abort)
@@ -251,7 +251,7 @@ export default class Queue extends EventEmitter {
251251
// Immediately "complete" when the queue is empty.
252252
if (this.#queue.size === 0) {
253253
this._status = 'pending'
254-
this.emit('complete')
254+
this.emit('end')
255255
return
256256
}
257257

@@ -266,7 +266,7 @@ export default class Queue extends EventEmitter {
266266
}
267267

268268
if (!sequential) {
269-
this.afterOnce('task.done', this.size, 'complete')
269+
this.afterOnce('task.done', this.size, 'end')
270270

271271
// Run in parallel
272272
// const TOKEN = Symbol('queue runner')
@@ -284,7 +284,7 @@ export default class Queue extends EventEmitter {
284284
})
285285
}
286286

287-
process.run(() => this.emit('complete'))
287+
process.run(() => this.emit('end'))
288288
}
289289
}
290290

tests/01-sanity.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test('Sanity', t => {
99
}
1010

1111
const TaskRunner = new Queue()
12-
t.ok(typeof TaskRunner === 'object', 'The plugin class is recognized.')
12+
t.expect('object', typeof TaskRunner, 'The plugin class is recognized.')
1313

1414
// This functionality/test was removed so the NGN namespace does not need to be a Proxy
1515
// t.ok(NGN.Queue !== undefined, 'The exported queue is available directly on the NGN namespace.')
@@ -98,9 +98,9 @@ test('NGN Queue parallel execution', t => {
9898
})
9999

100100
let ended = false
101-
tasks.on('complete', function () {
101+
tasks.on('end', function () {
102102
if (ended) {
103-
t.fail("'complete' event fired more than once.")
103+
t.fail("'end' event fired more than once.")
104104
t.end()
105105
return
106106
}
@@ -135,7 +135,7 @@ test('NGN Queue Async execution', t => {
135135
x.push('Task 3')
136136
})
137137

138-
tasks.on('complete', function () {
138+
tasks.on('end', function () {
139139
t.ok(x.length === 3, 'Invalid result.' + x.toString())
140140
t.end()
141141
})
@@ -247,7 +247,7 @@ test('NGN Queue Simple linear execution', t => {
247247
x.push(3)
248248
})
249249

250-
tasks.on('complete', function () {
250+
tasks.on('end', function () {
251251
t.ok(x[0] === 1 && x[1] === 2 && x[2] === 3, 'Invalid result.' + x.toString())
252252
t.end()
253253
})
@@ -280,7 +280,7 @@ test('NGN Queue Asynchronous sequential execution', t => {
280280

281281
extra.skip()
282282

283-
tasks.on('complete', function () {
283+
tasks.on('end', function () {
284284
t.ok(x.length === 3, 'Appropriately skipped step.')
285285
t.ok(x[0] === 1 && x[1] === 2 && x[2] === 3, 'Valid result: ' + x.toString())
286286
t.end()
@@ -326,7 +326,7 @@ test('NGN Queue Abort Process', t => {
326326

327327
test('NGN Queue Process an empty queue.', t => {
328328
const tasks = new Queue()
329-
tasks.on('complete', function () {
329+
tasks.on('end', function () {
330330
t.pass('No error on empty task.')
331331
tasks.reset()
332332
t.end()

0 commit comments

Comments
 (0)