Skip to content

Instantly share code, notes, and snippets.

@exuanbo
Last active October 24, 2020 14:38
Show Gist options
  • Save exuanbo/f51acf9b633855a031d3f7851380ae91 to your computer and use it in GitHub Desktop.
Save exuanbo/f51acf9b633855a031d3f7851380ae91 to your computer and use it in GitHub Desktop.
// https://stackoverflow.com/a/34152244/13346012
export const hasSubArray = <T>(master: T[], sub: T[]): boolean =>
sub.every(
((index: number) => (value: T) =>
(index = master.indexOf(value, index) + 1))(0)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment