Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Last active March 8, 2019 01:40
Show Gist options
  • Save MeetMartin/c7bd7add088e59ffc176a511b23b2d13 to your computer and use it in GitHub Desktop.
Save MeetMartin/c7bd7add088e59ffc176a511b23b2d13 to your computer and use it in GitHub Desktop.
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
export const trim = text => text.trim();
export const toLowerCase = text => text.toLowerCase();
export const capitalize = text => text.charAt(0).toUpperCase() + text.slice(1);
export const addExclamationMark = text => text + '!';
export const addPunctuation = text => text + '.';
export const makeImportant = compose(addExclamationMark, capitalize, toLowerCase, trim);
export const makeUnimportant = compose(addPunctuation, toLowerCase, trim);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment