Skip to content

Instantly share code, notes, and snippets.

@maxwellb
Last active August 29, 2019 18:14
Show Gist options
  • Save maxwellb/e0608ca9ef322599ac2e63cc7af6ae27 to your computer and use it in GitHub Desktop.
Save maxwellb/e0608ca9ef322599ac2e63cc7af6ae27 to your computer and use it in GitHub Desktop.
propsApply.ts
export default function propsApply<TIn, TOut>(_: { [index: string]: TIn }, fn: { (source: TIn): TOut }) {
return Object.keys(_).reduce(
(result, i) => {
result[i] = fn(_[i]); return result;
},
{} as { [any: string]: TOut }
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment