all files / src/ bindActionData.js

95.83% Statements 23/24
91.3% Branches 21/23
100% Functions 7/7
85.71% Lines 6/7
7 statements, 2 functions, 10 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18          188× 171×         17× 17×        
import mapValues from 'lodash.mapvalues'
 
/**
 * Adds additional properties to the results of the function or map of functions passed
 */
export default function bindActionData(action, data) {
  if (typeof action === 'function') {
    return (...args) => ({
      ...action(...args),
      ...data
    })
  }
  Eif (typeof action === 'object') {
    return mapValues(action, value => bindActionData(value, data))
  }
  return action
}