hexo/node_modules/trim-newlines/index.js

14 lines
390 B
JavaScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
'use strict';
module.exports = string => string.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, '');
module.exports.start = string => string.replace(/^[\r\n]+/, '');
module.exports.end = string => {
let end = string.length;
while (end > 0 && (string[end - 1] === '\r' || string[end - 1] === '\n')) {
end--;
}
return end < string.length ? string.slice(0, end) : string;
};