Skip to content

Instantly share code, notes, and snippets.

@abraham
Created August 8, 2018 21:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abraham/302cb95aa58c13917a604aa846b0b520 to your computer and use it in GitHub Desktop.
Save abraham/302cb95aa58c13917a604aa846b0b520 to your computer and use it in GitHub Desktop.
import { one, two, pipe } from './utils';
class Main {
public sentence() {
return pipe<string>('word',
addPeriod,
capitalize);
}
}
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