import { murmur2 } from './hash' ; import { IDebugger } from './tokens' ; /**
 * A class that holds debugger configuration for all kernels.
 */ export class DebuggerConfig implements IDebugger . IConfig { param code param kernel getCodeId ( code , kernel ) { const fileParams = this . _fileParams . get ( kernel ) ; if ( ! fileParams ) { throw new Error ( `Kernel (${ kernel }) has no tmp file params.` ) ; } const hash = this . _hashMethods . get ( kernel ) ; if ( ! hash ) { throw new Error ( `Kernel (${ kernel }) has no hashing params.` ) ; } const { prefix , suffix } = fileParams ; return `${ prefix }${ hash ( code ) }${ suffix }` ; } param params setHashParams ( params ) { const { kernel , method , seed } = params ; switch ( method ) { case 'Murmur2' : this . _hashMethods . set ( kernel , code => murmur2 ( code , seed ) . toString ( ) ) ; break ; default : throw new Error ( `Hash method (${ method }) is not supported.` ) ; } } param params setTmpFileParams ( params ) { const { kernel , prefix , suffix } = params ; this . _fileParams . set ( kernel , { kernel , prefix , suffix } ) ; } private _fileParams = new Map < string , IDebugger . IConfig . FileParams > ( ) ; private _hashMethods = new Map < string , ( code : string ) => string > ( ) ; }