(state = initialState, action = {}) => { state = Immutable.Iterable.isIterable(state) ? state : Immutable.fromJS(state); return R.propIs(Function, action.type, handlers) ? handlers[action.type](state, action) : Immutable.fromJS(state); };
const getRest = R.converge( R.objOf, [R.head, R.compose(R.last, R.head, R.toPairs, R.last)] ) const getKey = R.compose(R.head, R.head, R.toPairs, R.last) const switchValues = R.converge( R.pair, [getKey, getRest] ) const regexPair = R.compose( R.append(R.__, [regexKey]), R.ifElse( R.propIs(String, regexKey), R.converge(RegExp, [R.prop(regexKey), R.propOr("", regexOptionsKey)]), R.prop(regexKey) ) ) const formatWithOperatorPair = R.compose( formatQuery, R.unnest, R.ifElse( R.path([1, regexKey]), R.adjust(regexPair, 1), R.adjust(singlePair, 1) ) )
import axios from 'axios' import R from 'ramda' import RS from 'ramdasauce' // check for an invalid config const isInvalidConfig = R.anyPass([ R.isNil, R.isEmpty, R.complement(R.has('baseURL')), R.complement(R.propIs(String, 'baseURL')), R.propSatisfies(R.isEmpty, 'baseURL') ]) // the default configuration for axios const DEFAULT_CONFIG = { timeout: 0, headers: {} } export const NONE = null export const CLIENT_ERROR = 'CLIENT_ERROR' export const SERVER_ERROR = 'SERVER_ERROR' export const TIMEOUT_ERROR = 'TIMEOUT_ERROR' export const CONNECTION_ERROR = 'CONNECTION_ERROR' export const NETWORK_ERROR = 'NETWORK_ERROR' export const UNKNOWN_ERROR = 'UNKNOWN_ERROR' const TIMEOUT_ERROR_CODES = ['ECONNABORTED'] const NODEJS_CONNECTION_ERROR_CODES = ['ENOTFOUND', 'ECONNREFUSED', 'ECONNRESET'] const in200s = RS.isWithin(200, 299) const in400s = RS.isWithin(400, 499)
(state = initialState, action = {}) => R.propIs(Function, action.type, handlers) ? handlers[action.type](state, action) : Immutable.fromJS(state);