Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
bindme
Advanced tools
Readme
is a helper to bind a list of methods to an object reference
Installation | Motivation | Usage | License
npm install bindme
I was reading some interesting articles about a React poerformance tip: creating functions in render() is not recommended.
I was looking for a way to autobind methods but none was enough convincingly in my opinion, so I created this minimal package that is implemented in 6 lines of good old ES5 code and requires really few lines of code on the user side to be imported and invoked.
Consider also that, at the time of this writing, decorator syntax is
not final yet. Furthermore, this bindme
helper has no dependency at all
and probably will not require updates.
API is bindme(this, 'method1', 'method2', ..., 'methodN')
.
For example
import bindme from 'bindme'
// Also CommonJS is available:
// const bindme = require('bindme')
class MyButton extends Component {
constructor(props) {
super(props)
this.state = { clicked: false }
bindme(this, 'handleClick')
}
handleClick() {
this.setState({ clicked: true })
}
}
Since super
returns an instance, the following snippet works too
constructor(props) {
bindme(super(props),
'onClick',
'onMouseOver'
)
}
Code is written in ES5 for compatibility, it is equivalent to the following ES6 code
const bindme = (self, ...funcs) => {
funcs.forEach(func => {
if (self[func]) {
self[func] = self[func].bind(self)
} else {
console.error(`Method ${func} is not defined`)
}
})
}
FAQs
is a helper to bind a list of methods to an object reference
The npm package bindme receives a total of 17 weekly downloads. As such, bindme popularity was classified as not popular.
We found that bindme 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.