Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baseball

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baseball

provides simplified promise error handling

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

baseball

Build Status

provides simplified promise error handling

How?

Install

Just npm install baseball

Use

With Promises:

var baseball = require('baseball')();

var throwAPitch = new Promise(function (resolve, reject) {
  reject(new Error("sports are hard"));
});

// automatically catches and logs to console.error
// Error: sports are hard
//
throwAPitch.catch(baseball);

With options (messagePrefix):

var baseball = require('baseball')("PREPEND ME: ");

var throwAPitch = new Promise(function (resolve, reject) {
  reject(new Error("everything is awful"));
});

// automatically catches and logs to console.error
// PREPEND ME: Error: everything is awful
//
throwAPitch.catch(baseball);

With options (logger):

var baseball = require('baseball')(bunyan.error);

var throwAPitch = new Promise(function (resolve, reject) {
  reject(new Error("everything is awful"));
});

// automatically catches and logs to bunyan
// Error: everything is awful
//
throwAPitch.catch(baseball);

With explicit options:

var baseball = require('baseball')({messagePrefix: "PREPEND ME: ", logger: bunyan.error});

var throwAPitch = new Promise(function (resolve, reject) {
  reject(new Error("everything is awful"));
});

// automatically catches and logs to bunyan
// PREPEND ME: Error: everything is awful
//
throwAPitch.catch(baseball);

Why?

Why not - sometimes even the simple things could be simplier. Ya know, for lazy people.

License?

MIT LICENSE

Keywords

FAQs

Package last updated on 04 Apr 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc