File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @ngnjs/queue" ,
3- "version" : " 1.0.0-alpha.3 " ,
3+ "version" : " 1.0.0-alpha.4 " ,
44 "description" : " A lightweight NGN queue/taskrunner." ,
55 "type" : " module" ,
66 "main" : " src/index.js" ,
2323 "@ngnjs/plugin-debug" : " ^1.0.0-alpha"
2424 },
2525 "peerDependencies" : {
26- "ngn" : " >= 2.0.0-alpha.5" ,
26+ "ngn" : " ^ 2.0.0-alpha.5" ,
2727 "@ngnjs/plugin" : " >=1.0.0-alpha.8"
2828 },
2929 "dependencies" : {},
6969 "buildoption" : {
7070 "preserveEntrySignatures" : true
7171 },
72+ "autoimport" : [
73+ " import ngn from 'ngn'"
74+ ],
7275 "alias" : {
7376 "ngn" : " /node_modules/ngn/index.js" ,
7477 "@ngnjs/plugin" : " /source/@ngnjs/plugin/index.js" ,
Original file line number Diff line number Diff line change @@ -265,17 +265,12 @@ export default class Queue extends EventEmitter {
265265 this . #timer = setTimeout ( ( ) => this . abort ( true , activeItem ) , this . #timeout)
266266 }
267267
268- this . afterOnce ( 'task.done' , this . size , ( ) => {
269- this . emit ( 'complete' )
270- } )
271-
272268 if ( ! sequential ) {
269+ this . afterOnce ( 'task.done' , this . size , 'complete' )
270+
273271 // Run in parallel
274272 // const TOKEN = Symbol('queue runner')
275- this . afterOnce ( 'blah.blah' , this . size , 'complete' )
276273 for ( const task of this . #queue. items ) {
277- // task.once('done', () => this.emit('blah.blah'))
278- // task.once('task.done', () => console.log('here'))
279274 task . run ( )
280275 }
281276 } else {
Original file line number Diff line number Diff line change @@ -97,9 +97,18 @@ test('NGN Queue parallel execution', t => {
9797 x . push ( 'Task 3' )
9898 } )
9999
100+ let ended = false
100101 tasks . on ( 'complete' , function ( ) {
102+ if ( ended ) {
103+ t . fail ( "'complete' event fired more than once." )
104+ t . end ( )
105+ return
106+ }
107+
108+ ended = true
101109 t . expect ( 3 , x . length , 'All functions ran in parallel.' )
102- t . end ( )
110+
111+ setTimeout ( ( ) => t . end ( ) , 300 )
103112 } )
104113
105114 tasks . run ( )
You can’t perform that action at this time.
0 commit comments