UNPKG

train

Version:

Train a fast (FIFO) queue with a rollback mechanism. Behind the scenes it uses 2 arrays to simulate and perform fast shifting and popping operations without using the Array#shift() method..

25 lines (22 loc) 863 B
#!/usr/bin/env node exports.test = function ( done ) { var log = console.log , assert = require( 'assert' ) , Train = require( '../' ) , t = new Train() , exit = typeof done === 'function' ? done : function () {} ; log( '- test iterate() with no elements.' ) t.iterate( function ( el, i, done ) { throw new Error( 'this statement should not execute!' ); }, null, function ( err, cnt ) { var alen = arguments.length; log( '- check callback arguments' ); assert.ok( alen === 2, 'callback sould get 2 arguments, now length is: ' + alen ); log( '- check if err === null' ); assert.ok( err === null, 'something goes wrong!' ); log( '- check if counter === 0' ); assert.ok( cnt === 0, 'element counter should be 0!' ); exit(); } ); };