index.js 368 B

12345678910111213141516
  1. 'use strict';
  2. module.exports = input => {
  3. const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
  4. const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
  5. if (input[input.length - 1] === LF) {
  6. input = input.slice(0, input.length - 1);
  7. }
  8. if (input[input.length - 1] === CR) {
  9. input = input.slice(0, input.length - 1);
  10. }
  11. return input;
  12. };