Remove duplicate lines of a text document
JavaScript
const removeDuplicateLines = (str) => Array.from(new Set(str.split(/\r?\n/))).join('\n')
TypeScript
const removeDuplicateLines = (str: string): string => Array.from(new Set(str.split(/\r?\n/))).join('\n')
Examples
removeDuplicateLines(`one
three
two
three
one
four`)
/* Output */
/*
one
three
two
four
*/