import DebugNode from './node' ; const cache = [ ] ; const MAX_LOGS = 100 ; export default function Debug ( namespace ) { const debug = DebugNode ( namespace , ( ... args ) => { cache . push ( args ) ; if ( cache . length > MAX_LOGS ) { cache . shift ( ) ; } } ) ; return debug ; } export { Debug } ; Debug . enable = ( namespace ) : void => { DebugNode . enable ( namespace ) ; } ; Debug . enabled = ( namespace ) : boolean => DebugNode . enabled ( namespace ) ; export function getLogs ( numChars = 7500 ) { const output = cache . map ( ( c ) => c . map ( ( item ) => { if ( typeof item === 'string' ) { return item ; } return JSON . stringify ( item ) ; } ) . join ( '  ' ) ) . join ( '\n' ) ; if ( output . length < numChars ) { return output ; } return output . slice ( - numChars ) ; }