Socket
Book a DemoInstallSign in
Socket

built-in-decorators

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

built-in-decorators

Legacy decorators for proposed built-in decorators

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Built-in Decorators

Based on the Fall 2019, Stage 2 Decorators Proposal, these decorators are defined as "built-in decorators that can either be used directly, or can be used as a basis to define other decorators."

@wrap

The @wrap decorator can be used on a method to pass the function through another function. For example:

class C {
  @wrap(f) method() {}
}

is roughly equivalent to the following:

class C {
  method() {}
}
C.prototype.method = f(C.prototype.method);

@wrap can also be used on a class to wrap the entire class:

@wrap(f)
class C {}

is roughly equivalent to:

class C {}
C = f(C);

@register

The @register decorator schedules a callback to run after the class is created.

class C {
  @register(f) method() {}
}

is roughly equivalent to:

class C {
  method() {}
}
f(C, 'method');

@initialize

Not currently implemented, this proved difficult with the legacy decorators approach.

FAQs

Package last updated on 05 Oct 2019

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