Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/router / src / config.ts
Size: Mime:
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 }