Lodash Chain (v6)

Revision 6 of this benchmark created on


Description

Compare chaining lodash functions to multiple function calls on a collection of objects

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>

Setup

var myCollection = [{
      is_active: true,
      description: 'HazMat',
      price: 150,
      information: 'Handling of Hazardous Materials',
      is_required: true
    }, {
      is_active: true,
      description: 'Stop Off',
      price: 50,
      information: 'Stop Off',
      is_required: true
    }, {
      is_active: true,
      description: 'Chassis Repositioning',
      price: 800,
      information: 'From BNSF and CSX, $45 from UP and NS'
    }, {
      is_active: true,
      description: 'Crosstown',
      price: 105,
      information: 'From BNSF to NS Memphis $602.00 All other locations'
    }, {
      is_active: true,
      description: 'Detention',
      price: 70,
      information: 'Per hour'
    }, {
      is_active: true,
      description: 'Poor chassis',
      price: 18,
      information: 'COCP chassis'
    }, {
      is_active: true,
      description: 'Free time',
      price: 150,
      information: '2 hours outshot free drop zone'
    }, {
      is_active: true,
      description: 'Drop',
      price: 90,
      information: 'Double published rate outside of free drop zone'
    }, {
      is_active: true,
      description: 'Detention',
      price: 70,
      information: 'Per hour'
    }]
    
    var accessorial = {
      description: 'Detention'
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Methods (Chain)
var result = _(myCollection).filter(function(item) {
  return item.is_required
}).pluck('description').contains(accessorial.description)
ready
Functions (Compose)
var result = _.contains(_.pluck(_.filter(myCollection, function(item) {
  return item.is_required
}), 'description'), accessorial.description);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.