https://github.com/rstuven/es-decorate
ES7 decorators for CoffeeScript
https://github.com/rstuven/es-decorate
coffeescript decorators es7 es7-decorators javascript
Last synced: 6 months ago
JSON representation
ES7 decorators for CoffeeScript
- Host: GitHub
- URL: https://github.com/rstuven/es-decorate
- Owner: rstuven
- Created: 2015-04-27T23:09:08.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-27T23:17:45.000Z (about 10 years ago)
- Last Synced: 2024-11-20T21:05:06.153Z (6 months ago)
- Topics: coffeescript, decorators, es7, es7-decorators, javascript
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# es-decorate
> ES7 decorators for CoffeeScript
## Why
Libraries such as
[Angular](https://angular.io/docs/js/latest/api/annotations/)
and
[Aurelia](http://eisenbergeffect.bluespire.com/aurelia-update-with-decorators-ie9-and-more/)
are starting to use decorators according to the API proposed in
https://github.com/wycats/javascript-decorators
which is supported in Babel 5+ and TypeScript 1.5On the other hand, it seems CoffeeScript
won't be adding decorators any time soon:
- https://github.com/jashkenas/coffeescript/issues/76
- https://github.com/jashkenas/coffeescript/issues/996`es-decorate` fills the syntactic gap providing a
helper function that can apply decorators compliant
with the proposed decorator API.## Install
npm install --save es-decorate
## Usage
Following the examples in https://github.com/wycats/javascript-decorators:
``` coffeescript
decorate = require 'es-decorate'# Class decorator must be assigned to variable or property.
Foo = decorate F('color'), G, class # Class name is optional in CoffeeScript# Method with redundant name
bar: decorate 'bar', @, F('color'), G, -># Or just...
decorate 'baz', @, F('color'), G, ->
# ...if no code analyzer will miss the explicit method declaration
```Multiline declaration:
``` coffeescript
Foo = decorate [
F 'color'
G
H
I 123
J
], class Foo
```Less dumb example, using Angular 2:
``` coffeescript
decorate = require 'es-decorate'
{Component, View} = require 'angular2/angular2'AppComponent = decorate [
Component selector: 'my-app'
View template: 'My first Angular 2 App
'
], class AppComponent
constructor: ->
```