Skip to content

Instantly share code, notes, and snippets.

@sallar sallar/ts-curry.ts
Created Nov 20, 2017

Embed
What would you like to do?
Typescript Module Curry
module Cart {
export function test1() {
console.log('hi');
}
export function test2() { }
}
function curryModule<T>(mod: T): T {
return Object
.keys(mod)
.map(method => ({ method, fn: mod[method] }))
.reduce((all: T, curr) => {
all[curr.method] = curr.fn;
return all;
}, {} as T);
}
curryModule(Cart).test1();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.