1.0.0 • Published 7 years ago

es-decorators v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

es-decorators Build Status

Most useful EcmaScript decorators

Usage

import {Debounce, Defaults} from 'es-decorators';

@Defaults({
  ammunitionCount: 100
})
class Panzer {
  
  @Debounce(1000, {leading: true})
  fire() {
    // ...
  }
  
}

API

@Autobind

binds method to container (e.g. class or object)

@Defaults(props)

props {object}
@Defaults decorator slightly differs from lodash.defaults

@Debounce(duration, options)

duration {number}
options {object} see lodash.debounce

@Throttle(duration, options)

duration {number}
options {object} see lodash.throttle

@Memoize(resolver)

resolver {function} see lodash.memoize

@Once

see lodash.once

@Retry(count = 0)

count {number} retry count. 0 means no retries, simply call.
Assumes that decorated function returns promise. The function will be called up to count times until it is resolved.

@DecorateInstance(decorator, ...args)

decorator {function}
args {*[]}
@DecorateInstance transforms instance method with provided decorator when it is accessed first time

1.0.0

7 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago