Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
78
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Allow parsing of optional catch bindings


Version published
Maintainers
6
Install size
2.68 kB
Created

Package description

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

The @babel/plugin-syntax-optional-catch-binding package allows Babel to parse JavaScript code that uses optional catch binding syntax. This syntax feature enables developers to use try/catch blocks without the need to specify an error variable in the catch clause if they don't need access to the error. This can make the code cleaner and more concise in situations where the error is irrelevant.

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

Optional Catch Binding Syntax

This feature allows developers to use try/catch blocks without having to bind the error object to a variable in the catch block. It's particularly useful when the error object is not used in the catch block.

try {
  // code that might throw an error
} catch {
  // handle the error without needing to bind it to a variable
}

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

Readme

Source

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

This plugin allows Babel to parse optional catch bindings.

Example

Syntax

try {
  throw 0;
} catch {
  doSomethingWhichDoesntCareAboutTheValueThrown();
  console.log("Yay, code executes!");
}

Installation

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

Usage

.babelrc

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

Via CLI

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

Via Node API

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

References

  • Proposal: Optional Catch Binding for ECMAScript

Keywords

FAQs

Last updated on 12 Feb 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