File Explorer

/var/runtime/node_modules/@aws-sdk/node_modules/asynckit

This explorer reads the filesystem of the server it runs on, so /workspace/user isn't present here. Browsing and the terminal still work against this server's own disk from /.

1 dir
9 files
serialOrdered.js1.7 KB · 76 lines
var iterate    = require('./lib/iterate.js')  , initState  = require('./lib/state.js')  , terminator = require('./lib/terminator.js')  ; // Public APImodule.exports = serialOrdered;// sorting helpersmodule.exports.ascending  = ascending;module.exports.descending = descending; /** * Runs iterator over provided sorted array elements in series * * @param   {array|object} list - array or object (named list) to iterate over * @param   {function} iterator - iterator to run * @param   {function} sortMethod - custom sort function * @param   {function} callback - invoked when all elements processed * @returns {function} - jobs terminator */function serialOrdered(list, iterator, sortMethod, callback){  var state = initState(list, sortMethod);   iterate(list, iterator, state, function iteratorHandler(error, result)  {    if (error)    {      callback(error, result);      return;    }     state.index++;     // are we there yet?    if (state.index < (state['keyedList'] || list).length)    {      iterate(list, iterator, state, iteratorHandler);      return;    }     // done here    callback(null, state.results);  });   return terminator.bind(state, callback);} /* * -- Sort methods */ /** * sort helper to sort array elements in ascending order * * @param   {mixed} a - an item to compare * @param   {mixed} b - an item to compare * @returns {number} - comparison result */function ascending(a, b){  return a < b ? -1 : a > b ? 1 : 0;} /** * sort helper to sort array elements in descending order * * @param   {mixed} a - an item to compare * @param   {mixed} b - an item to compare * @returns {number} - comparison result */function descending(a, b){  return -1 * ascending(a, b);}