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.

15 lines
315 B

4 years ago
  1. 'use strict';
  2. module.exports = function (x) {
  3. var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt();
  4. var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt();
  5. if (x[x.length - 1] === lf) {
  6. x = x.slice(0, x.length - 1);
  7. }
  8. if (x[x.length - 1] === cr) {
  9. x = x.slice(0, x.length - 1);
  10. }
  11. return x;
  12. };