cr
Version:
Strip windows carriage returns, or convert carriage returns to newlines.
23 lines (19 loc) • 465 B
JavaScript
/*!
* cr <https://github.com/jonschlinkert/cr>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
;
module.exports = function(str) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
return str.replace(/\r\n|\r/g, '\n');
};
module.exports.strip = function(str) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
return str.split('\r').join('');
};