mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
304 B
16 lines
304 B
8 years ago
|
'use strict';
|
||
|
|
||
|
module.exports = trimTrailingLines;
|
||
|
|
||
|
var line = '\n';
|
||
|
|
||
|
/* Remove final newline characters from `value`. */
|
||
|
function trimTrailingLines(value) {
|
||
|
var val = String(value);
|
||
|
var index = val.length;
|
||
|
|
||
|
while (val.charAt(--index) === line) { /* empty */ }
|
||
|
|
||
|
return val.slice(0, index + 1);
|
||
|
}
|