jessetane/queue — pull request #2 by bitmage (2013-06-20 19:28:11+00:00)
Title: Bug fix & Better Defaults for Timeout Behavior

Hey, so I did a couple things here.

The inheritance approach that was here before didn't work - it would assign all instances of Queue to the same parent EventEmitter. Therefore they would share events, creating a lot of noise and incorrect behavior. I came across this when I created a master test to run all the tests together. There I was getting duplicate outputs. I fixed this, using util.inherits:

http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor

I'm sure there's a way to do inheritance manually but this utility seems to be popular in the node ecosystem.

Secondly, I found the timeout behavior to be unintuitive. It required a handler for the "on timeout" event, and without that, and the subsequent call to next(), it would just hang and not continue processing the queue. This seems like a bad default behavior, so I changed it to check if there are event handlers for 'timeout' and if there are not, just continue processing when a timeout is encountered.

I added a test for this behavior. I added the 'all' test to run everything as you would expect, and I added a script for this to package.json so that anyone coming to this library can run `npm test`.

I would suggest using a testing framework that will give you control over running and reporting. I personally use mocha. If you add it to the devDependencies it won't be installed by any users of the library, only people who manually run 'npm install'.

Regards,
Brandon