Negatively Proportional Model
Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

simple-output

2.1.1 • Public • Published

simple-output

NPM version Build Status License

Pretty output messages to stdout/stderr

Getting Started

Install the module with: npm install simple-output

Examples

var log = require('simple-output');
 
log.success('Successful hello world');

Available methods

  • success(msg)
  • error(msg)
  • info(msg)
  • message(msg)
  • node(msg)
  • warn(msg)

Testing

This module helps on testing your output data by making it simpler to mock simple-output and its methods or use the exposed streams interface to which the data gets written to.

In order to test your output information, replace the stdout/stderr properties with an mock object containing a write function (simulating the streams api). See the example below:

Mock simpleOutput.stdout

var log = require('simple-output');
var myModule = require('../my-module');
 
log.stdout = {
    write: function(msg) {
        assert(msg, 'hello world');
    }
};
 
myModule.methodThatUsesSimpleLogInfoInternally();

Using a mocking library

var requireInject = require('require-inject');
 
var myModule = requireInject('../my-module', {
    'simple-output': {
        info: msg => assert(msg, 'hello world');
    }
});
 
myModule.methodThatUsesSimpleLogInfoInternally();

License

MIT © 2019 Ruy Adorno

Install

npm i simple-output

DownloadsWeekly Downloads

9,120

Version

2.1.1

License

none

Unpacked Size

4.64 kB

Total Files

4

Last publish

Collaborators

  • avatar