Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
mixin-decorator
Advanced tools
This is a simple decorator function for mixing in behaviors from other sources. It can be called multiple times or passed multiple behaviors. It is useful for React components because it allows multiple definitions of the same method for methods that return undefined. So you can have mixins that tap into the component life cycle without breaking each other.
npm install -S mixin-decorator
// behaviors/hello.js
export const hello = {
hello(){
console.log("hello world")
}
}
import mixin from "mixin-decorator"
import hello from "./behaviors/hello.js"
@mixin(hello)
class Hello{
}
var obj = new Hello()
obj.hello() //output: hello world
@mixin(...behaviors)
It accepts one or more objects full of behaviors to mix in. If your mixins have definitions of the same method and you care about the order they are called in, use this style as they will be called in the order specified.
@mixin(helloWorld, edit)
class Hello {
It can also be stacked. If your mixins declare the same method be aware that
they will be called in reverse order when using this style. This is because it
is equivalent to this mixin(edit)(Hello); mixin(helloWorld)(Hello)
@mixin(helloWorld)
@mixin(edit)
class Hello {
FAQs
A decorator for mixins that doesn't overwrite existing methods
The npm package mixin-decorator receives a total of 10 weekly downloads. As such, mixin-decorator popularity was classified as not popular.
We found that mixin-decorator 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.