🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

simple-output

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-output

Output messages to stdout/stderr, zero deps.

3.0.0
latest
Source
npm
Version published
Weekly downloads
13K
72.71%
Maintainers
1
Weekly downloads
 
Created
Source

simple-output

NPM version Build Status License

Pretty output messages to stdout/stderr with no extra dependencies.



render examples

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)
  • info(msg)
  • warn(msg)
  • error(msg)
  • node(msg) prints a green hexagon icon (on supported platforms) along with msg
  • message(msg) prints msg, no icon associated with it
  • hint(msg) useful if you want to dim some of the output

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 © 2022 Ruy Adorno

Keywords

terminal

FAQs

Package last updated on 24 Jan 2022

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