Sha256: b04aff9f4e4b74672a0031202b66dc9b1116c7817e103bcb56954e284ab00765

Contents?: true

Size: 1.56 KB

Versions: 291

Compression:

Stored size: 1.56 KB

Contents

var compareAscending = require('./_compareAscending');

/**
 * Used by `_.orderBy` to compare multiple properties of a value to another
 * and stable sort them.
 *
 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
 * specify an order of "desc" for descending or "asc" for ascending sort order
 * of corresponding values.
 *
 * @private
 * @param {Object} object The object to compare.
 * @param {Object} other The other object to compare.
 * @param {boolean[]|string[]} 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 = compareAscending(objCriteria[index], othCriteria[index]);
    if (result) {
      if (index >= ordersLength) {
        return result;
      }
      var order = orders[index];
      return result * (order == 'desc' ? -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://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  return object.index - other.index;
}

module.exports = compareMultiple;

Version data entries

291 entries across 267 versions & 32 rubygems

Version Path
appmap-0.71.0 ./node_modules/lodash/_compareMultiple.js
disco_app-0.16.1 test/dummy/node_modules/lodash/_compareMultiple.js
appmap-0.70.2 ./node_modules/lodash/_compareMultiple.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/lodash/_compareMultiple.js
appmap-0.70.1 ./node_modules/lodash/_compareMultiple.js
appmap-0.70.0 ./node_modules/lodash/_compareMultiple.js
appmap-0.69.0 ./node_modules/lodash/_compareMultiple.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/lodash/_compareMultiple.js
appmap-0.68.2 ./node_modules/lodash/_compareMultiple.js
appmap-0.68.1 ./node_modules/lodash/_compareMultiple.js
disco_app-0.15.2 test/dummy/node_modules/lodash/_compareMultiple.js
appmap-0.68.0 ./node_modules/lodash/_compareMultiple.js
appmap-0.67.1 ./node_modules/lodash/_compareMultiple.js
trusty-cms-5.0.3 node_modules/lodash/_compareMultiple.js
trusty-cms-5.0.2 node_modules/lodash/_compareMultiple.js
appmap-0.67.0 ./node_modules/lodash/_compareMultiple.js
disco_app-0.18.4 test/dummy/node_modules/lodash/_compareMultiple.js
disco_app-0.18.1 test/dummy/node_modules/lodash/_compareMultiple.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/lodash/_compareMultiple.js
disco_app-0.14.0 test/dummy/node_modules/lodash/_compareMultiple.js