Skip to content

Instantly share code, notes, and snippets.

@abraham
Created Aug 8, 2018
Embed
What would you like to do?
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