react-redux-fetch
Version:
A declarative and customizable way to fetch data for React components and manage that data in the Redux state
16 lines (12 loc) • 361 B
Flow
// @flow
import isFunction from 'lodash/isFunction';
import isObject from 'lodash/isObject';
type FuncOrObj = Function | Object;
const ensureObject: Function = (item: FuncOrObj, itemArg: Array<*>): Object => {
// $FlowFixMe
const obj = isFunction(item) ? item(...itemArg) : item;
return isObject(obj) ? obj : {};
};
export default {
ensureObject,
};