3.0.3 • Published 5 months ago

@aloreljs/bound-decorator v3.0.3

Weekly downloads
46
License
Apache-2.0
Repository
github
Last release
5 months ago

Bound decorator

An ES7 decorator for making class methods bound to the class instance (including statics).

MASTER CI status NPM badge dependencies badge Coverage Status


Table of Contents

Installation

npm install @aloreljs/bound-decorator

Compatibility

The library's only goal is to be compatible with Typescript 5 decorators which, at the time of writing, use the 2022-03 stage 3 decorators proposal.

Usage

import {BoundMethod} from '@aloreljs/bound-decorator';

class MyClass {
  
  @BoundMethod()
  method1() {
    // equivalent to
    // this.method1 = this.method1.bind(this);
  }
  
  @BoundMethod('a', 'b')
  method2(a, b, c) {
    // equivalent to
    // this.method2 = this.method2.bind(this, 'a', 'b');
  }

  @BoundMethod()
  static foo() {
    // Equivalent to
    // MyClass.foo = MyClass.foo.bind(MyClass);
  }
}
3.0.3

5 months ago

3.0.2

7 months ago

3.0.1

7 months ago

3.0.0

7 months ago

2.0.0

2 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago