Last active
May 24, 2016 13:04
-
-
Save hwclass/69b306b7436c92ba397b57cb84c89389 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Composition builder wrapper | |
const Builder = (() => { | |
compose = (obj, props) => { | |
return Object.assign(obj, props) | |
} | |
return { | |
compose: compose | |
} | |
})(); | |
//test object | |
let testObj = {}; | |
//functionality as mixin | |
const mixin= { | |
drive: () => { | |
console.log('driving...') | |
} | |
}; | |
//building a new object with functionality | |
const driver = Builder.compose(testObj, mixin); | |
//drive the car | |
driver.drive(); //logs driving... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment