Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.42 KB

Readme.md

File metadata and controls

55 lines (39 loc) · 1.42 KB

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