@environment-safe/console-intercept

0.1.0 • Public • Published

@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

Package Sidebar

Install

npm i @environment-safe/console-intercept

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

10.7 kB

Total Files

11

Last publish

Collaborators

  • khrome