The answer provided by PointedEars is everything most of us need. But by following Mathias Bynens's answer, I went on a Wikipedia trip and found this: https://en.wikipedia.org/wiki/Newline.
The following is a drop-in function that implements everything the above Wiki page considers "new line" at the time of this answer.
If something doesn't fit your case, just remove it. Also, if you're looking for performance this might not be it, but for a quick tool that does the job in any case, this should be useful.
const replaceNewLineChars = ((someString, replacementString = ``) => {
const LF = `\u{000a}`;
const VT = `\u{000b}`;
const FF = `\u{000c}`;
const CR = `\u{000d}`;
const CRLF = `${CR}${LF}`;
const NEL = `\u{0085}`;
const LS = `\u{2028}`;
const PS = `\u{2029}`;
const lineTerminators = [LF, VT, FF, CR, CRLF, NEL, LS, PS];
let finalString = someString.normalize(`NFD`);
for (let lineTerminator of lineTerminators) {
if (finalString.includes(lineTerminator)) {
let regex = new RegExp(lineTerminator.normalize(`NFD`), `gu`);
finalString = finalString.replace(regex, replacementString);
};
};
return finalString.normalize(`NFC`);
});