包详细信息

brout

mantoni17.7kMIT1.3.0

stdout and stderr for browsers

stdout, stderr, browser, browserify

自述文件

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

更新日志

Changes

1.3.0

  • Detect process existence to support browserify --no-detect-globals.

1.2.0

1.1.1

  • Redirect consol.info to stdout and console.error to stderr instead of aliasing console.log and console.warn (cool-Blue)

1.1.0

Streams 3: Update through2 to 2.0

Bump devDependencies:

  • browserify@13.0
  • mocaccino@1.7
  • phantomic@1.4

1.0.2

  • Update through2 to ^1.1

1.0.1

  • Fix transform #1 (Deema Yvanow)
  • Bump through2 to 0.6

1.0.0

  • Use through2 instead of through

0.2.0

  • Expose emitter as process._brout

0.1.5

  • Don't break on old IE: Provide empty stubs for log, info, warn and error if console is not there.

0.1.4

  • Implement console.trace()

0.1.3

  • Log error message to console on process.exit if code is not zero

0.1.2

  • Fixed dependencies

0.1.0

  • Initial release