0.0.7 • Published 8 years ago

normalize-deco v0.0.7

Weekly downloads
41
License
-
Repository
github
Last release
8 years ago

Normalize Deco

A utility function for normalizing the way es2016 class decorator functions receive their arguments.

Usage

Wrap your decorator function in normalizeDeco.

The wrapper will determine whether or not your decorator is being called with or without options and handle them accordingly.

npm install normalize-deco
import normalizeDeco from "normalize-deco";

const myDeco = normalizeDeco((Target, a, b, c) => {
  Target.someCoolFunctionality = { ... };
  return Target;
});

// both cases will work the same:
@myDeco // no options
class A {}

@myDeco("a", "b", "c") // with options
class B {}

Caveat

Decorators that require function options are not supported because there's no way to determine if the function is an option argument or the target class argument. For example:

@myDeco(function() {}) // this will not work
class A {}
0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

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