From e387882952943d107c57968701927007d94df58b Mon Sep 17 00:00:00 2001 From: Tenor Biel Date: Mon, 18 May 2015 15:27:34 -0500 Subject: [PATCH 1/2] feature(annotations): add ES7 decorator functions --- src/annotations.js | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/annotations.js b/src/annotations.js index a8a8302..37677bb 100644 --- a/src/annotations.js +++ b/src/annotations.js @@ -148,6 +148,42 @@ function readAnnotations(fn) { return collectedAnnotations; } +// Decorator versions of annotation classes +function inject(...tokens) { + return function(fn) { + annotate(fn, new Inject(...tokens)); + }; +} + +function inject(...tokens) { + return function(fn) { + annotate(fn, new Inject(...tokens)); + }; +} + +function injectPromise(...tokens) { + return function(fn) { + annotate(fn, new InjectPromise(...tokens)); + }; +} + +function injectLazy(...tokens) { + return function(fn) { + annotate(fn, new InjectLazy(...tokens)); + }; +} + +function provide(...tokens) { + return function(fn) { + annotate(fn, new Provide(...tokens)); + }; +} + +function providePromise(...tokens) { + return function(fn) { + annotate(fn, new ProvidePromise(...tokens)); + }; +} export { annotate, @@ -162,5 +198,11 @@ export { Provide, ProvidePromise, ClassProvider, - FactoryProvider + FactoryProvider, + + inject, + injectPromise, + injectLazy, + provide, + providePromise, }; From dbe2799e56acbb28a61aaacc3697e2f52d25b5ec Mon Sep 17 00:00:00 2001 From: Tenor Biel Date: Thu, 16 Jul 2015 02:19:54 -0500 Subject: [PATCH 2/2] feature(annotations): export ES7 decorators functions in public API --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index dd19076..37a3e11 100644 --- a/src/index.js +++ b/src/index.js @@ -11,5 +11,10 @@ export { SuperConstructor, TransientScope, ClassProvider, - FactoryProvider + FactoryProvider, + inject, + injectPromise, + injectLazy, + provide, + providePromise } from './annotations';