Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
decorator-utils
Advanced tools
Helpful utility functions to use when writing your own ES7 decorators.
Helpful utility functions to use when writing your own ES7 decorators.
Install the package with NPM:
$ npm install decorator-utils
A simple example:
import {DecoratorUtils} from "decorator-utils";
function decorator(target, name, descriptor) {
let declarationType = DecoratorUtils.getDeclarationType(arguments);
if (declarationType !== DecoratorUtils.declarationTypes.CLASS_METHOD) {
throw new Error("Decorator must be applied to a class method declaration.");
}
// The rest of the decorator's logic...
}
@decorator // Error will be thrown.
class Dog {
@decorator // Error will NOT be thrown.
woof() {}
}
The package exposes a static class, DecoratorUtils
, which has the following functions and properties:
arguments
object of the decorator function. Just pass it through!DecoratorUtils.declarationTypes
.DecoratorUtils.declarationTypes
.String
-> Symbol
). To be used in conjunction with DecoratorUtils.getDeclarationType()
.CLASS
CLASS_METHOD
CLASS_ACCESSOR
OBJECT_LITERAL_METHOD
OBJECT_LITERAL_ACCESSOR
FAQs
Helpful utility functions to use when writing your own ES7 decorators.
We found that decorator-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.