Awesome
Decorator
<p align="center"> <span>Decorator for ES6 classes.</span> <br><br> <a href="https://app.codecov.io/gh/felix-kaestner/decorator/"> <img alt="Codecov" src="https://img.shields.io/codecov/c/github/felix-kaestner/decorator?color=29b6f6&style=flat-square&token=G0HFHGFM94"> </a> <a href="https://github.com/felix-kaestner/decorator/issues"> <img alt="Issues" src="https://img.shields.io/github/issues/felix-kaestner/decorator?color=29b6f6&style=flat-square"> </a> <a href="https://github.com/felix-kaestner/decorator/stargazers"> <img alt="Stars" src="https://img.shields.io/github/stars/felix-kaestner/decorator?color=29b6f6&style=flat-square"> </a> <a href="https://github.com/felix-kaestner/decorator/blob/main/LICENSE"> <img alt="License" src="https://img.shields.io/github/license/felix-kaestner/decorator?color=29b6f6&style=flat-square"> </a> <a href="https://twitter.com/kaestner_felix"> <img alt="Twitter" src="https://img.shields.io/badge/twitter-@kaestner_felix-29b6f6?style=flat-square"> </a> </p>Install
Install with npm
or yarn
:
$ npm i git+https://github.com/felix-kaestner/decorator
$ yarn add git+https://github.com/felix-kaestner/decorator
Usage
import {sealed} from '@felix-kaestner/decorator'
@sealed
class BugReport {
title: string;
constructor(t: string) {
this.title = t
}
}
API
@sealed
Apply Object.seal on a class constructor and prototype with @sealed
.
import {sealed} from '@felix-kaestner/decorator'
@sealed
class BugReport {
title: string;
constructor(t: string) {
this.title = t
}
}
@immutable
Apply Object.freeze on a class constructor and prototype with @immutable
.
import {immutable} from '@felix-kaestner/decorator'
@immutable
class BugReport {
title: string;
constructor(t: string) {
this.title = t
}
}
@final
Apply both Object.seal and Object.freeze on a class constructor and prototype with @final
.
import final from '@felix-kaestner/decorator'
@final
class BugReport {
title: string;
constructor(t: string) {
this.title = t
}
}
This is equivalent to using both @sealed
and @immutable
.
Contribute
All contributions in any form are welcome! 🙌
Just use the Issue and Pull Request templates and
I will be happy to review your suggestions. 👍
Released under the MIT License.