Mixin
Object composition helper
Example
import { mixin, pure } from "@dmail/mixin"
const walkTalent = ({ name }) => {
const walk = () => `${name} walk`
return {
walk,
}
}
const flyTalent = ({ name }) => {
const fly = () => `${name} fly`
return {
fly,
}
}
const dog = mixin(pure, () => ({ name: "dog" }), walkTalent)
const duck = mixin(pure, () => ({ name: "duck" }), walkTalent, flyTalent)
dog.walk() // dog walk
dog.fly // undefined
duck.walk() // duck walk
duck.fly() // duck fly