Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
/ log-cb Public archive

A better looking method to format errors and data from a callback.

License

Notifications You must be signed in to change notification settings

jamen/log-cb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log-cb NPM version Build Status

A better looking method to format errors and data from a callback.

// Use inside Node callbacks.
fs.readFile('LICENSE', log('Success!', 'Error :<'));

// Or promises
foo(10).catch(log('', 'Error happened'));

// You can use log.err above instead:
bar(99).catch(log.err('Error happened'));

Installation

$ npm install --save log-cb

API

log(passMessage, [failMessage])

Log custom message for passing

  • passMessage: What to log if your callback has no errors.
  • failMessage: What to log if your callback has errors. Defaults to something custom.

log.err(failMessage, [passMessage])

The reverse of the original function, for better syntax:

log('', 'it broke!');
// vs
log.err('it broke!');

License

MIT © Jamen Marz

About

A better looking method to format errors and data from a callback.

Resources

License

Stars

Watchers

Forks

Packages

No packages published