param { * } registries param { * } newRegistries export function addRegistries ( registries , newRegistries ) { Object . keys ( newRegistries ) . forEach ( ( registryName ) => { if ( registries [ registryName ] ) { throw new Error ( `There is already a registry named "${ registryName }".` ) ; } registries [ registryName ] = newRegistries [ registryName ] ; } ) ; return registries ; } param { * } registries param { * } specs export function register ( registries , specs ) { Object . keys ( specs ) . forEach ( ( registryName ) => { if ( ! registries [ registryName ] ) { throw new Error ( `There is no registry named "${ registryName }".` ) ; } if ( ! registries [ registryName ] . register ) { throw new Error ( `Registry "${ registryName }" must have a register function.` ) ; } specs [ registryName ] . forEach ( ( f ) => registries [ registryName ] . register ( f ) ) ; } ) ; return registries ; } param { * } registries export function registryFactory ( registries ) { return { registries ( ) { return registries ; } , register ( specs ) { return register ( registries , specs ) ; } , } ; }