ConsoleOnly
Write to the console only after an expected write has already occurred
- Suppresses console logging you are not interested in
- Useful for debugging and tracing
- Zero dependencies
- Works in Node and the Browser
Install
$ npm i consoleonly
Init
Node
import ConsoleOnly from 'consoleonly'
Browser
<script type="module">
import ConsoleOnly from 'https://cdn.jsdelivr.net/gh/draeder/consoleonly/index.js'
</script>
Example
let consoleOnly = ConsoleOnly()
console.only.on()
console.only('This will never log, because console.only expects an index > 0')
console.only(3,'This will never log, because 2 has not fired yet')
console.only(1,'This will log first')
console.log('This will never log, because we are only interested in console.only')
console.only(2,'This will log second')
console.only.off()
console.log('This will log as normal')
console.log('So will this')
console.only(4, 'This will not log, because console.only has been disabled')