redux-devshare
Version:
[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Code Climate][climate-image]][climate-url] [![Code Coverage][coverage-i
40 lines (36 loc) • 1.11 kB
JavaScript
import { isFunction } from 'lodash'
export { getEventsFromInput } from './events'
/**
* @private
* @description Create a function if not already one
* @param {Function|Object|Array|String} Callable function or value of return for new function
*/
export const createCallable = f => isFunction(f) ? f : () => f
/**
* @private
* @description Validate config input
* @param {Object} Config object containing all combined configs
*/
export const validateConfig = (config) => {
// require needed Firebase config
const requiredProps = [
'databaseURL',
'authDomain',
'apiKey'
]
requiredProps.forEach((p) => {
if (!config[p]) {
throw new Error(`${p} is a required config parameter for react-redux-firebase.`)
}
})
// Check that some certain config are functions if they exist
const functionProps = [
'fileMetadataFactory',
'profileDecorator'
]
functionProps.forEach((p) => {
if (!!config[p] && !isFunction(config[p])) {
throw new Error(`${p} parameter in react-redux-firebase config must be a function. check your compose function.`)
}
})
}