Skip to content

felix-kaestner/decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decorator

Decorator for ES6 classes.

Codecov Issues License

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.


Released under the MIT License.

About

TypeScript class decorators

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •