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

@babel/plugin-proposal-decorators

Package Overview
Dependencies
Maintainers
5
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-proposal-decorators

Compile class and object decorators to ES5

  • 7.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.6M
decreased by-27.32%
Maintainers
5
Weekly downloads
 
Created

What is @babel/plugin-proposal-decorators?

The @babel/plugin-proposal-decorators package is a Babel plugin that enables the use of decorators, which are a stage 2 proposal for JavaScript. Decorators provide a way to add annotations and a meta-programming syntax for class declarations and members. Decorators can be used to modify classes, properties, methods, and accessors.

What are @babel/plugin-proposal-decorators's main functionalities?

Class Decorators

Class decorators are applied to the class and can be used to observe, modify, or replace a class definition. They can be used for logging, auto-binding, injecting dependencies, etc.

@decorator
class MyClass {}

function decorator(Class) {
  // Modify or wrap the class
  return modifiedClass;
}

Method Decorators

Method decorators are applied to methods of a class and can be used to observe, modify, or replace method definitions. This can be useful for debouncing, throttling, memoization, etc.

class MyClass {
  @decorator
  myMethod() {}
}

function decorator(target, name, descriptor) {
  // Modify or wrap the method
  return modifiedDescriptor;
}

Property Decorators

Property decorators are applied to class properties and can be used to modify the behavior of a property, such as by adding getters and setters, or by initializing with a default value.

class MyClass {
  @decorator
  myProperty;
}

function decorator(target, name) {
  // Modify or define property behavior
}

Accessor Decorators

Accessor decorators are applied to getters and setters and can be used to observe, modify, or replace accessors. This can be useful for validation, logging, etc.

class MyClass {
  _myValue;

  @decorator
  get myValue() {
    return this._myValue;
  }

  set myValue(value) {
    this._myValue = value;
  }
}

function decorator(target, name, descriptor) {
  // Modify or wrap the accessor
  return modifiedDescriptor;
}

Other packages similar to @babel/plugin-proposal-decorators

Keywords

FAQs

Package last updated on 27 May 2020

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