https://github.com/kt3k/52deco
Use decorator without transpilation
https://github.com/kt3k/52deco
decorator esnext javascript
Last synced: 9 months ago
JSON representation
Use decorator without transpilation
- Host: GitHub
- URL: https://github.com/kt3k/52deco
- Owner: kt3k
- Created: 2018-03-11T05:53:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-11T06:21:20.000Z (over 8 years ago)
- Last Synced: 2025-03-17T19:35:05.977Z (about 1 year ago)
- Topics: decorator, esnext, javascript
- Language: JavaScript
- Size: 34.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 52deco v1.0.1
[](https://circleci.com/gh/kt3k/52deco)
[](https://codecov.io/gh/kt3k/52deco)
> Use decorator without transpilation
52deco is a small utility for performing the same operation what ESNext decorators do. Decorators Proposal has been changing a lot and the only [babel transpilation][babel-plugin-transform-decorators-legacy] available today is outdated and not reliable. This tool supports using decorator with simple helper function.
# :cd: Install
Via npm:
npm install --save 52deco
# :book: Usage
In case of method decorator:
```js
const deco = requrie('52deco')
class Foo {
method () { ... }
}
deco.method(decorator, Foo, 'method')
```
The above is equivalent of:
```js
class Foo {
@decorator
method () { ... }
}
```
In case of class decorator:
```js
const deco = require('52deco')
class Foo {
...
}
deco.class(decorator, Foo)
```
The above is equivalent of:
```js
@decorator
class Foo {
...
}
```
# Note
There is the babel transform [babel-plugin-transform-decorators-legacy][]. However that doesn't follow the current spec and not reliable.
# Origin
See: https://splatoonwiki.org/wiki/.52_Gal_Deco
# License
MIT
[babel-plugin-transform-decorators-legacy]: https://npm.im/babel-plugin-transform-decorators-legacy