Skip to content

Instantly share code, notes, and snippets.

@techieshark
Created February 22, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techieshark/d2811482567dbd2660464e3d5a41f8e4 to your computer and use it in GitHub Desktop.
Save techieshark/d2811482567dbd2660464e3d5a41f8e4 to your computer and use it in GitHub Desktop.
Flow-typed version of Object.values()
// @flow
// Flow-typed version of Object.values()
// @see: problem - https://github.com/facebook/flow/issues/2221
// @see: this solution - https://stackoverflow.com/a/51757027/1024811
export default function objectValues<A, B>(obj: {[key: A]: B}): Array<B> {
return ((Object.values(obj): any): Array<B>);
}
import objectValues from './objectValues';
test('objectValues() acts like Object.values()', () => {
const obj = { a: 1, b: 2 };
expect(objectValues(obj)).toEqual(Object.values(obj));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment