We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 786ebf1 + 235cfd4 commit 4db7cc0Copy full SHA for 4db7cc0
index.js
@@ -1,10 +1,16 @@
1
/*!
2
* word-wrap <https://github.com/jonschlinkert/word-wrap>
3
*
4
- * Copyright (c) 2014-2017, Jon Schlinkert.
+ * Copyright (c) 2014-2023, Jon Schlinkert.
5
* Released under the MIT License.
6
*/
7
8
+function trimTabAndSpaces(str) {
9
+ const lines = str.split('\n');
10
+ const trimmedLines = lines.map((line) => line.trimEnd());
11
+ return trimmedLines.join('\n');
12
+}
13
+
14
module.exports = function(str, options) {
15
options = options || {};
16
if (str == null) {
@@ -36,7 +42,7 @@ module.exports = function(str, options) {
36
42
}).join(newline);
37
43
38
44
if (options.trim === true) {
39
- result = result.replace(/[ \t]*$/gm, '');
45
+ result = trimTabAndSpaces(result);
40
46
}
41
47
return result;
48
};
0 commit comments