Socket
Socket
Sign inDemoInstall

@babel/plugin-proposal-optional-catch-binding

Package Overview
Dependencies
78
Maintainers
5
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/plugin-proposal-optional-catch-binding

Compile optional catch bindings


Version published
Weekly downloads
9.5M
increased by4.58%
Maintainers
5
Install size
6.19 kB
Created
Weekly downloads
 

Package description

What is @babel/plugin-proposal-optional-catch-binding?

The @babel/plugin-proposal-optional-catch-binding package allows developers to use the optional catch binding syntax proposed for JavaScript. This syntax lets you use try/catch blocks without needing to specify a catch binding if you don't need it for the catch block.

What are @babel/plugin-proposal-optional-catch-binding's main functionalities?

Optional Catch Binding

This feature allows you to omit the catch binding (the error variable) when you don't need to use it within the catch block. It simplifies the syntax when the error object is unnecessary.

try {
  // some code that might throw
} catch {
  // handle the error without using the error object
}

Other packages similar to @babel/plugin-proposal-optional-catch-binding

Readme

Source

@babel/plugin-proposal-optional-catch-binding

Optional catch binding enables the catch block to execute whether or not an argument is passed to the catch statement (CatchClause).

Examples

try {
  throw 0;
} catch {
  doSomethingWhichDoesntCareAboutTheValueThrown();
}
try {
  throw 0;
} catch {
  doSomethingWhichDoesntCareAboutTheValueThrown();
} finally {
  doSomeCleanup();
}

Installation

npm install --save-dev @babel/plugin-proposal-optional-catch-binding

Usage

.babelrc

{
  "plugins": ["@babel/plugin-proposal-optional-catch-binding"]
}

Via CLI

babel --plugins @babel/plugin-proposal-optional-catch-binding script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-proposal-optional-catch-binding"]
});

References

  • Proposal: Optional Catch Binding for ECMAScript

Keywords

FAQs

Last updated on 08 Jan 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc