blob: a17d0afd33fee8d56cda15fe58e49c8cc385596b [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2module.exports = function (x) {
3 var lf = typeof x === 'string' ? '\n' : '\n'.charCodeAt();
4 var cr = typeof x === 'string' ? '\r' : '\r'.charCodeAt();
5
6 if (x[x.length - 1] === lf) {
7 x = x.slice(0, x.length - 1);
8 }
9
10 if (x[x.length - 1] === cr) {
11 x = x.slice(0, x.length - 1);
12 }
13
14 return x;
15};