Repository URL to install this package:
|
Version:
7.0.0-alpha.3 ▾
|
import { isObj, EMPTY_OBJ, EMPTY_ARRAY } from 'exotic'
import { OneRouterConfigMap, OneRouterConfigObjType } from './typings'
const config: OneRouterConfigMap = new Map()
/**
* @todo maybe could scope configs for isolated tests
*/
const setConfig = (x: OneRouterConfigObjType) => {
Object.keys(x).forEach((key: keyof OneRouterConfigObjType) => {
config.set(key as any, x[key])
})
const pathParams = config.get('pathParams')
const routePathsList = isObj(pathParams)
? Object.values(pathParams)
: EMPTY_ARRAY
config.set('routePathsList', routePathsList)
}
setConfig({
pathParams: {},
routePathsList: [],
})
export { config, setConfig }