twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

readable_serial_ordered.js (941B)


      1 var serialOrdered = require('../serialOrdered.js');
      2 
      3 // API
      4 module.exports = ReadableSerialOrdered;
      5 // expose sort helpers
      6 module.exports.ascending  = serialOrdered.ascending;
      7 module.exports.descending = serialOrdered.descending;
      8 
      9 /**
     10  * Streaming wrapper to `asynckit.serialOrdered`
     11  *
     12  * @param   {array|object} list - array or object (named list) to iterate over
     13  * @param   {function} iterator - iterator to run
     14  * @param   {function} sortMethod - custom sort function
     15  * @param   {function} callback - invoked when all elements processed
     16  * @returns {stream.Readable#}
     17  */
     18 function ReadableSerialOrdered(list, iterator, sortMethod, callback)
     19 {
     20   if (!(this instanceof ReadableSerialOrdered))
     21   {
     22     return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
     23   }
     24 
     25   // turn on object mode
     26   ReadableSerialOrdered.super_.call(this, {objectMode: true});
     27 
     28   this._start(serialOrdered, list, iterator, sortMethod, callback);
     29 }