Skip to content

Instantly share code, notes, and snippets.

@dir01
Last active May 14, 2019 09:33
Show Gist options
  • Save dir01/5c429c5ccb578602bffa69e0867e75eb to your computer and use it in GitHub Desktop.
Save dir01/5c429c5ccb578602bffa69e0867e75eb to your computer and use it in GitHub Desktop.
const flatten = <T>(arr: T[][]): T[] => ([] as T[]).concat(...arr);
test("flatten", () => {
expect(flatten([[1], [2], [3, 4]])).toEqual([1, 2, 3, 4]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment