
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@smackchat/mixable
Advanced tools
mixableMultiple inheritance library for JavaScript.
It allows you to make classes that inherit from multiple parents.
npm install @smackchat/mixable or yarn add @smackchat/mixable
MixableClasses can only inherit from other MixableClasses, and are created with createMixableClass()
Let's create an Animal class:
import { createMixableClass } from '@smackchat/mixable'
const Animal = createMixableClass({
name: 'Animal',
body: class {
static totalNumber() {
return Animal.totalNumber
}
_constructor() {
this.alive = false
if (Animal.totalNumber)
Animal.totalNumber++
else Animal.totalNumber = 1
}
die() {
this.alive = false
}
}
})
We can instantiate it like a normal class.
const animal = new Animal()
console.log(shark.is(Animal)) // true
console.log(Animal.totalNumber()) // 1
console.log(animal.alive) // true
animal.die()
console.log(animal.alive) // false
Due to ECMAScript class limitations, we use _constructor() instead of constructor().
For the same reason, properties assigned in the class body will be ignored.
export const Animal = createMixableClass({
name: 'Animal',
body: class {
// WRONG: will be ignored
alive = false
// WRONG: will be ignored
constructor() {
this.alive = false
}
// CORRECT
_constructor() {
this.alive = false
}
}
})
Now we can make a class Swimmer that inherits from Animal:
import { createMixableClass } from '@smackchat/mixable'
import { Animal } from './Animal.class'
export const Swimmer = createMixableClass({
name: 'Swimmer',
inherits: [ Animal ],
body: class {
_constructor({ typeOfWater }) {
this.typeOfWater = typeOfWater
}
getCaughtInNet() {
this.die() // method inherited from Animal
}
}
})
When we instantiate it, both _constructor() functions are called.
console.log(Swimmer.inheritsFrom(Animal)) // true
console.log(Swimmer.inheritsFrom(Swimmer)) // true
const shark = new Swimmer({ typeOfWater: 'salty' })
console.log(shark.is(Animal)) // true
console.log(shark.is(Swimmer)) // true
console.log(shark.className()) // 'Swimmer'
console.log(shark.typeOfWater) // 'salty'
console.log(shark.alive) // true
shark.getCaughtInNet()
console.log(shark.alive) // false
We can inherit from multiple classes.
const { createMixableClass } = require('@smackchat/mixable')
const { Swimmer } = require('./Swimmer.class')
const { Flyer } = require('./Flyer.class')
export const FlyingFish = createMixableClass({
name: 'FlyingFish',
inherits: [ Swimmer, Flyer ],
body: class {
avoidPredator() {
this.swimToSurface() // inherited from Swimmer
this.fly() // inherited from Flyer
this.survive() // inherited from Animal
}
}
})
FAQs
Multiple inheritance for JavaScript
We found that @smackchat/mixable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.