pl

p-log

Log the value/error of a promise

Showing:

Popularity

Downloads/wk

162

GitHub Stars

23

Maintenance

Last Commit

5mos ago

Contributors

2

Package

Dependencies

1

Size (min+gzip)

0.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

p-log

Log the value/error of a promise

Install

$ npm install p-log

Usage

import pLog from 'p-log';

Promise.resolve('unicorn')
    .then(pLog()) // Logs `unicorn`
    .then(value => {
        // `value` is still `unicorn`
    });
import pLog from 'p-log';

Promise.resolve()
    .then(() => {
        throw new Error('pony');
    })
    .catch(pLog.catch()) // Logs `Error: pony`
    .catch(error => {
        // `error` is still `Error: pony`
    });

API

pLog(logger?)

Use this in a .then() method.

Returns a thunk that returns a Promise.

pLog.catch(logger?)

Use this in a .catch() method.

Returns a thunk that returns a Promise.

logger

Type: Function\ Default: console.log

The logger to use. Any return value or exception is ignored.

  • p-tap - Tap into a promise chain without affecting its value or state
  • p-if - Conditional promise chains
  • p-catch-if - Conditional promise catch handler
  • More…

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100