Debugging utilities wrapped in hendlers.
Most of the debugging functionality are skipped
when the DEBUGGING member of the module is falsy
compare two values vith strict equal operator, if they are not equal, will croak an exception
import { ASSERT } from './debug.js'
var myvalue = true
// ok
ASSERT(myvalue, true)
// ko, will throw false
ASSERT(myvalue, false)Assert true but not strictly, if you pass a falsy value will throw that value
import { ASSERT_T } from from './debug.js'
var myvalue1 = 1
var myvalue2 = NaN
// ok
ASSERT_T(myvalue1)
// ko, will throw NaN
ASSERT_T(myvalue2)Assert false but not strictly, if you pass a truthy value will throw that value
import { ASSERT_F } from from './debug.js'
var myvalue1 = NaN
var myvalue2 = 1
// ok
ASSERT_F(myvalue1)
// ko, will throw 1
ASSERT_F(myvalue2)Userfull to check the debugging status
import { DEBUGGING } from './debug.js'
if(DEBUGGING){
console.warn('debugging mode')
}
else {
console.log('normal mode')
}Functional wrapper for throw
import { croak } from './debug.js'
// will throw the string 'wrong value'
croak('wrong value')Functional wrapper for debugger directive
import { pause } from './debug.js'
// will stop the execution and start the debugger
pause()Sets the debugging status
import { DEBUG } from './debug.js'
DEBUG(false)
console.log('debugging?', debug.DEBUGGING)
DEBUG(true)
console.log('debugging?', debug.DEBUGGING)