1.0.5 • Published 2 years ago

consoleonly v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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'
// ... See example.js

Browser

<script type="module">
  import ConsoleOnly from 'https://cdn.jsdelivr.net/gh/draeder/consoleonly/index.js'
  // ... See example.html
</script>

Example

let consoleOnly = ConsoleOnly()

// Enable console.only
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')

// Disable console.only
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')
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago