Code coverage report for es6/lib/ensureItemIsObject.js

Statements: 100% (9 / 9)      Branches: 100% (2 / 2)      Functions: 100% (2 / 2)      Lines: 100% (6 / 6)      Ignored: none     

All files » es6/lib/ » ensureItemIsObject.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                1 5 8 7   1          
import {isPlainObject} from 'lodash';
 
/**
 * Function decorator, validates item is a javascript object.
 *
 * @param {Function} fn Underlying function to call.
 * @returns {Function}
 */
function ensureItemIsObject(fn) {
  return function(item) {
    if (isPlainObject(item)) {
      return fn(item);
    }
    throw new TypeError('Item must be plain object literal');
  };
}
 
export default ensureItemIsObject;