Sha256: 53cd72865995280b2b46c5f253a30fa25a0d3f302ff6120d199ca06ae3d51902

Contents?: true

Size: 1.58 KB

Versions: 153

Compression:

Stored size: 1.58 KB

Contents

var baseCompareAscending = require('./baseCompareAscending');

/**
 * Used by `_.sortByOrder` to compare multiple properties of a value to another
 * and stable sort them.
 *
 * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise,
 * a value is sorted in ascending order if its corresponding order is "asc", and
 * descending if "desc".
 *
 * @private
 * @param {Object} object The object to compare.
 * @param {Object} other The other object to compare.
 * @param {boolean[]} orders The order to sort by for each property.
 * @returns {number} Returns the sort order indicator for `object`.
 */
function compareMultiple(object, other, orders) {
  var index = -1,
      objCriteria = object.criteria,
      othCriteria = other.criteria,
      length = objCriteria.length,
      ordersLength = orders.length;

  while (++index < length) {
    var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
    if (result) {
      if (index >= ordersLength) {
        return result;
      }
      var order = orders[index];
      return result * ((order === 'asc' || order === true) ? 1 : -1);
    }
  }
  // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  // that causes it, under certain circumstances, to provide the same value for
  // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  // for more details.
  //
  // This also ensures a stable sort in V8 and other engines.
  // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
  return object.index - other.index;
}

module.exports = compareMultiple;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/compareMultiple.js
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/compareMultiple.js