
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
🧪 Use decorators without the syntax & transpilers.
Want to write modern code utilizing decorators but don't want to throw in heavy transpiler just to get @decorator
syntax to work? Use decorate()
.
It is the future now. We can already use classes, fat arrow functions, ES modules & imports, even instance properties. So there's no need to use transpilers anymore. Except for decorators. The extremely useful feature that spent an eternity in the standardization process and is still not yet done. And won't be until like 2029.
decorate(Class, decorator)
decorate(Class, decorator('with-argument'))
decorate(Class, 'methodName', decorator)
decorate(Class, 'methodName', decorator({with: 'argument'}))
for example:
decorate(MyClass, someClassDecorator)
decorate(MyClass, customElement('my-element'))
decorate(MyClass, 'boundMethod', autobind)
decorate(MyClass, 'hiddenValue', nonenumerable)
decorate(MyClass, 'frozenValue', configurable(false))
install npm package
npm install decorate
import the decorate()
function
// Node.js
import decorate from 'decorate'
<!-- newer browsers -->
<script type="module">
import decorate from './node_modules/decorate/index.js'
</script>
<!-- older browsers -->
<script src="./node_modules/decorate/index.cjs"></script>
you can do this:
import decorate from 'decorate'
import {inlineView, bindable, computedFrom} from 'aurelia-framework'
class MyElement {
get fullName() {
return this.firstName + ' ' + this.lastName
}
}
decorate(MyElement, customElement('my-element'))
decorate(MyElement, inlineView('<template>fullName: ${fullName}</template>'))
decorate(MyElement, 'firstName', bindable)
decorate(MyElement, 'lastName', bindable({defaultBindingMode: au.bindingMode.twoWay}))
decorate(MyElement, 'fullName', computedFrom('firstName', 'lastName'))
instead of this:
import {customElement, inlineView, bindable, computedFrom} from 'aurelia-framework'
@customElement('my-element')
@inlineView('<template>fullName: ${fullName}</template>')
class MyElement {
@bindable
firstName
@bindable({defaultBindingMode: au.bindingMode.twoWay})
lastName
@computedFrom('firstName', 'lastName')
get fullName() {
return this.firstName + ' ' + this.lastName
}
}
FAQs
🧪 Use decorators without the syntax & transpilers
We found that decorate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.