Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
🧪 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.