@dmail/mixin

6.0.0 • Public • Published

Mixin

npm build codecov

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

Readme

Keywords

none

Package Sidebar

Install

npm i @dmail/mixin

Weekly Downloads

1

Version

6.0.0

License

MIT

Last publish

Collaborators

  • dmail