Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36
Chrome 94
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
lodash fp 1678999.0 Ops/sec
native 5676929.5 Ops/sec
native with lodash 2749612.8 Ops/sec
native with named funcs 3313895.5 Ops/sec
HTML Preparation code:
x
 
1
<script src='https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)'></script>
2
Script Preparation code:
 
var fp = _.noConflict();
var context = {
  eventline: { hello: 'you' },
  config: 'sadas',
};
var isString = fp.isString;
var isArray = fp.isArray;
var getDefaultProps = fp.flow(
  fp.filter(
    _.overEvery([
      isString,
      function (prop) {
        return _.hasIn(context, prop);
      },
    ]),
  ),
  fp.reduce(function (acc, i) {
    acc[i] = context[i];
    return acc;
  }, {}),
);
var testNative = function(param) {
  param.filter(myVar => (typeof myVar === 'string' || myVar instanceof String) && context[myVar]).reduce(function (acc, i) {
    acc[i] = context[i];
    return acc;
  }, {}) 
}
var testNativeDash = function(param) {
  param.filter(myVar => _.isString(myVar) && _.hasIn(context, myVar)).reduce(function (acc, i) {
    acc[i] = context[i];
    return acc;
  }, {}) 
}
var isStr = myVar => typeof myVar === 'string' || myVar instanceof String;
var isWithinObj = myVar => !!context[myVar];
var reducer = function (acc, i) {
    acc[i] = context[i];
    return acc;
  }
var testNativeWithFunc = function(param) {
  param.filter(myVar => isStr(myVar) && isWithinObj(myVar)).reduce(reducer, {}) 
}
    
    
var test1 = ['eventline']
Tests:
  • lodash fp

     
    getDefaultProps(test1);
  • native

     
     testNative(test1)
  • native with lodash

     
    testNativeDash(test1)
  • native with named funcs

     
    testNativeWithFunc(test1)