Created
August 8, 2018 21:01
-
-
Save abraham/302cb95aa58c13917a604aa846b0b520 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { one, two, pipe } from './utils'; | |
class Main { | |
public sentence() { | |
return pipe<string>('word', | |
addPeriod, | |
capitalize); | |
} | |
} |
This file contains hidden or 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
export function pipe<T>(state: T, ...fns): T { | |
return fns.reduce(function (state: T, fn: (T) => T) { | |
return fn(state) | |
}, state); | |
} | |
export function addPeriod(value: string) { | |
return value + '.'; | |
} | |
export function capitalize(value: string) { | |
return value.charAt(0).toUpperCase() + value.substr(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment