New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

print-messages

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

print-messages

We console lots, this handles everything

latest
Source
npmnpm
Version
0.3.2
Version published
Maintainers
1
Created
Source

print-messages

Because making console.log easier to read and write is a double edge sword of time saving.

npm install print-messages
pm = require('print-messages');

Besides normal stuff like colored log, warn, success, and error methods, we have 2 more

  • node
  • promise

Node.js usually has callbacks like function(err, result){ ...

user.save(function(er,res){
    // String will be green or red depending on er, res
    pm.node('user.save results...', er, res);
})

Promises are becoming popular

var promiser = require('when');
willSucceed = promiser.defer()

pm.promise('promise result is(green or red): ', willSucceed.promise);
willSucceed.resolve("resolve is green");

// or we could have done this
//willSucceed.reject("reject is red");

#Examples

####Basic log, warn, success, error example-image

pm.log('log me', 'log me long tim');
pm.warn('warn me', 'warn me long tim');
pm.success('success me', 'success me long tim');
pm.error('error me', 'error me long tim');

Node callbacks

example-image

// Node callbacks are usually (err, res)
pm.node('some failing save message', 'That failed', null);
pm.node('some success message', null, {
  results: 'are cool'
});

Promises

example-image

promise = require('when');
    
willSucceed = promise.defer();
willFail = promise.defer();
    
pm.promise('This is for a promise', willSucceed.promise);
willSucceed.resolve('That works');

pm.promise('Whereas this is for a promise', willFail.promise);
willFail.reject('That fails');

Patch Notes

v0.3.0

Updated from coffee-script to js.

Added newLine [=true] and blankLine [=true] options to determine if arguments should be on new lines and if each log should be preceeded by a blank line. Both false looks like this:

pm.newLine = false;
pm.blankLine = false;

example-image

Added a way to change colors.

pm.colors.error = 'magenta';
pm.colors.success = 'blue';
pm.init()

example-image

v0.2.2

Ensured at least 1 printed message will appear, even if first arg is an object

v0.2.0

Added pm.node_cb for user.save(pm.node_cb('My message might be green or red'))

v0.1.0

Added pm.crash and pm.crash_cb for promise.otherwise(pm.crash) or promise.otherwise(pm.crash_cb('with message'))

Added pm.error_cb, pm.success_cb, pm.warn_cb, pm.log_cb for user.save().error(pm.error_cb('it failed)); // logs: 'it failed'.red, errors...

Keywords

console

FAQs

Package last updated on 07 Dec 2013

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