import { logger } from './logger' ; export function error ( condition , format , ... args ) { if ( format === undefined ) { throw new Error ( '`Ohbug warning(condition, format, ...args)` requires a warning message argument' ) ; } if ( ! condition ) { let argIndex = 0 ; const message = format . replace ( /%s/g , ( ) => args [ argIndex ++ ] ) ; throw new Error ( `Ohbug ${ message }` ) ; } } export function warning ( condition , format , ... args ) { try { if ( process . env . NODE_ENV !== 'production' ) { if ( format === undefined ) { throw new Error ( '`Ohbug warning(condition, format, ...args)` requires a warning message argument' ) ; } if ( ! condition ) { let argIndex = 0 ; const message = format . replace ( /%s/g , ( ) => args [ argIndex ++ ] ) ; logger . warn ( message ) ; } } } catch ( e ) { } }