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; |