0.1.0 • Published 10 months ago

@environment-safe/console-intercept v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@environment-safe/console-intercept

When you want to intercept console output in a uniform way across the server and browser (probably in a test suite that can run on the command line and browser).

import it with:

import { intercept } from '@environment-safe/console-intercept'; 

require it with (only supported in the browser via babel/webpack/browserify):

const { intercept } = require( '@environment-safe/console-intercept'); 

Use it like:

const terminate = intercept((text)=>{
   //do something with the text here
   return ''; //return what *actually* gets output
});
// log some things
terminate(); //stop intercepting