Skip to content

Instantly share code, notes, and snippets.

@hesher
Last active June 7, 2017 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hesher/1b323231a400bb22949b81a511ac2329 to your computer and use it in GitHub Desktop.
Save hesher/1b323231a400bb22949b81a511ac2329 to your computer and use it in GitHub Desktop.
// 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