brout

stdout and stderr for browsers

MIT 14 个版本
安装
npm install brout
yarn add brout
pnpm add brout
bun add brout
README

stdout and stderr for browsers

Installs process.stdout and process.stderr and redirects console like node.

Repository: https://github.com/mantoni/brout.js


Install with npm

npm install brout

Usage

Assume my-script.js contains this:

process.stdout.write('Hello stdout!\n');
console.log('Hello %s!', 'console');

Use with browserify and phantomic:

$ browserify -t brout my-script.js | phantomic
Hello stdout!
Hello console!

API

var brout = require('brout');

brout.on('out', function (str)) {
  // ...
});

brout.on('err', function (str)) {
  // ...
});

brout.on('exit', function (code)) {
  // ...
});

Event listeners are tiggered by these calls:

  • process.stdout.write(string)
  • process.stderr.write(string)
  • process.exit(code)

The console functions log, info, warn and error get replaced and the original implementation is exposed:

  • console.log.original
  • console.info.original
  • console.warn.original
  • console.error.original

The console override behaves like node's implementation and writes to process.stdout and process.sterr.

If an out or err listener is installed, then the corresponding console message is no longer forwarded to the original console implementation.

License

MIT

版本列表
1.3.0 2019-10-09
1.2.0 2016-10-28
1.1.1 2016-08-26
1.1.0 2016-01-19
1.0.2 2015-06-24
1.0.1 2014-11-27
1.0.0 2014-08-06
0.2.0 2014-04-09
0.1.5 2014-03-30
0.1.4 2014-03-13
0.1.3 2014-02-03
0.1.2 2014-01-26
0.1.1 2014-01-25
0.1.0 2014-01-23