@revgaming/global
Version:
application bundle to globalize with ioc-like loader and localizations
18 lines (15 loc) • 460 B
JavaScript
import {config, mergeConfig} from '@revgaming/config'
const globalizeConfig = function (key) {
if (key === false) return
if (window[key] !== undefined) throw 'config already registered'
window[key] = config
}
export const bootConfig = opts => {
globalizeConfig(opts.global ?? 'config')
if (opts.hasOwnProperty('config')) mergeConfig(opts.config)
else if (opts) mergeConfig(opts)
return {
config: config,
mergeConfig: mergeConfig,
}
}