Skip to content

jakwuh/es-decorators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Most useful EcmaScript decorators

Resources

Stars

Watchers

Forks

Packages

No packages published