index.js 377 B

1234567891011121314
  1. 'use strict';
  2. module.exports = string => string.replace(/^[\r\n]+/, '').replace(/[\r\n]+$/, '');
  3. module.exports.start = string => string.replace(/^[\r\n]+/, '');
  4. module.exports.end = string => {
  5. let end = string.length;
  6. while (end > 0 && (string[end - 1] === '\r' || string[end - 1] === '\n')) {
  7. end--;
  8. }
  9. return end < string.length ? string.slice(0, end) : string;
  10. };