Socket
Socket
Sign inDemoInstall

patch-console

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    patch-console

Patch console methods to intercept output


Version published
Weekly downloads
492K
decreased by-7.3%
Maintainers
1
Install size
5.84 kB
Created
Weekly downloads
 

Readme

Source

patch-console test

Patch console methods to intercept output

Install

$ npm install patch-console

Usage

import patchConsole from 'patch-console';

const restore = patchConsole((stream, data) => {
	// stream = 'stdout'
	// data = "Hello World"
});

console.log('Hello World');

// Restore original methods
restore();

API

patchConsole(callback)

After this function is called, output from console methods will be intercepted and won't show up in the actual stdout or stderr stream. To restore original console methods and stop intercepting output, call the function which patchConsole() returns.

callback

Type: Function

Function that will be called when output from one of the console methods is intercepted. First argument is name of the stream ("stdout" or "stderr"), second argument is output itself.

Console methods

This module intercepts the following methods:

  • console.assert()
  • console.count()
  • console.countReset()
  • console.debug()
  • console.dir()
  • console.dirxml()
  • console.error()
  • console.group()
  • console.groupCollapsed()
  • console.groupEnd()
  • console.info()
  • console.log()
  • console.table()
  • console.time()
  • console.timeEnd()
  • console.timeLog()
  • console.trace()
  • console.warn()

Keywords

FAQs

Last updated on 04 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc