Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
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 540 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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.