npm/decorate

Name: decorate

Owner: npm

Description: decorate a function transparently

Created: 2017-05-06 01:02:29.0

Updated: 2018-04-06 03:35:44.0

Pushed: 2017-05-24 05:40:20.0

Homepage: null

Size: 5

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

@npm/decorate

Decorate a function, forwarding properties.

t decorate = require('@npm/decorate')

tion myFunction () {
turn 1

nction.bloo = 3

t decorated = decorate(myFunction, (...args) => {
turn myFunction(...args) + 1


ole.log(decorated.name) // myFunction
ole.log(decorated.bloo) // 3
ole.log(decorated())    // 2

API
decorate(inner, wrapper) -> Function

Forward all properties from inner to a merged function that calls wrapper.

decorate.undecorate(Function) -> Function | Null

Return the inner function of a decorated function. or null.

decorate.decorations(Function) -> Iterator<Function>

Return an iterator that yields all decoration wrappers of a given function in order.

License

ISC


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.