functional/objects.ts

9 lines
159 B
TypeScript
Raw Normal View History

2020-05-11 22:34:57 +00:00
/**
* Attribute getter
*/
export function attr<K extends string>(
name: K,
): <O extends Record<K, O[K]>>(obj: O) => O[K] {
return (obj) => obj[name];
}