Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
abstract-decorator
Advanced tools
JavaScript doesn't have a built in language feature for defining abstract
classes and enforcing their contracts - but with decorators, we can create that
functionality ourselves! The @abstract
decorator allows you to define simple
abstract classes, like so:
@abstract
class CookieService {
@abstract headers;
@abstract getValue() {}
@abstract setValue() {}
}
You can then extend the class and provide the abstract values:
class BrowserCookieService extends CookieService {
headers = new Map();
getValue() {
// get cookie value
}
setValue(value) {
// set cookie value
}
}
If a subclass fails to provide the correct values, then an error will be thrown the first time the class is instatiated. The two types of abstract values that can be defined are fields and methods, and they are defined by decorating a class field or a method respectively.
The errors thrown by @abstract
are useful in development, but are pointless
overhead in production applications. If you're consuming this package, you can
remove the decorators using the filter-imports
babel plugin:
{
"plugins": [
[
"babel-plugin-filter-imports",
{
"imports": {
"abstract-decorator": ["default"]
}
}
]
]
}
This setup is provided out-of-the-box in Ember apps and addons, zero configuration necessary!
This package is compatible with Node v10 and above out of the box.
This package supports the stage 1/legacy decorators transform. This is transform that is the current recommendation of the champions of the decorators proposal.
This package does not support Typescript. Typescript has first class support for abstract classes, so there's no need to include extra weight via this decorator.
npm install --save abstract-decorator
# or with yarn
yarn add abstract-decorator
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
The default blueprint for ember-cli addons.
The npm package abstract-decorator receives a total of 24 weekly downloads. As such, abstract-decorator popularity was classified as not popular.
We found that abstract-decorator 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.