Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

output-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

output-interceptor

Intercepts stdout/ stderr.

Source
npmnpm
Version
3.2.0
Version published
Weekly downloads
61
64.86%
Maintainers
1
Weekly downloads
 
Created
Source

output-interceptor

GitSpo Mentions Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Intercepts stdout/ stderr.

Implementation

This module uses domain to capture asyncrhonous function output.

Read Capturing stdout/ stderr in Node.js using Domain module.

Usage

import {
  createOutputInterceptor
} from 'output-interceptor';

const interceptOutput = createOutputInterceptor();

const main = async () => {
  const result = await interceptOutput(() => {
    console.log('foo');
    console.error('bar');

    return Promise.resolve('baz');
  });

  result === 'baz';

  interceptOutput.output === 'foo\nbar\n';
};

main();

API

/**
 * @property interceptStderr Default: true.
 * @property interceptStdout Default: true.
 * @property stripAnsi Default: true.
 */
export type OutputInterceptorUserConfigurationType = {|
  +interceptStderr?: boolean,
  +interceptStdout?: boolean,
  +stripAnsi?: boolean
|};

/**
 * @returns Intercepted output.
 */
type FlushType = () => string;

/**
 * @property output Output produced during the executing of the `routine`.
 */
export type OutputInterceptorType = {|
  <T>(routine: () => Promise<T> | T): Promise<T>,
  output: ''
|};

createOutputInterceptor(userConfiguration?: OutputInterceptorUserConfigurationType): OutputInterceptorType;

Keywords

interceptor

FAQs

Package last updated on 03 Aug 2019

Did you know?

Socket

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