@dmail/mixin
v6.0.0
Published
[![npm](https://badge.fury.io/js/%40dmail%2Fmixin.svg)](https://badge.fury.io/js/%40dmail%2Fmixin) [![build](https://travis-ci.org/dmail/mixin.svg?branch=master)](http://travis-ci.org/dmail/mixin) [![codecov](https://codecov.io/gh/dmail/mixin/branch/maste
Downloads
4
Readme
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