Last active
June 7, 2017 08:06
-
-
Save hesher/1b323231a400bb22949b81a511ac2329 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
// Helper Functions | |
const wrapWith = wrapper => obj => key => val => wrapper({...obj, [key]: val}); | |
const wrapWithSiteBuilder = wrapWith(SiteBuilder); | |
// Expression Builder | |
function SiteBuilder(value) { | |
const siteBuilderWrapper = wrapWithSiteBuilder(value); | |
return { | |
withSiteName: siteBuilderWrapper('name'), | |
withDomain: siteBuilderWrapper('domain'), | |
build: () => value | |
}; | |
} | |
SiteBuilder({}).withSiteName('hello').withDomain('some-domain').build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment