10 lines
263 B
JavaScript
10 lines
263 B
JavaScript
/** https://github.com/sindresorhus/trim-newlines */
|
|
export const trimNewlinesEnd = (str) => {
|
|
let end = str.length;
|
|
|
|
while (end > 0 && (str[end - 1] === '\r' || str[end - 1] === '\n')) {
|
|
end--;
|
|
}
|
|
|
|
return end < str.length ? str.slice(0, end) : str;
|
|
}
|