git.wincent.com
/
dented.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ac441a0
)
Deal with entirely unindented input
0.0.1
author
Greg Hurrell <greg@hurrell.net>
Thu, 17 Jan 2019 23:45:05 +0000
(
00:45
+0100)
committer
Greg Hurrell <greg@hurrell.net>
Thu, 17 Jan 2019 23:45:05 +0000
(
00:45
+0100)
src/dedent.js
patch
|
blob
|
history
diff --git
a/src/dedent.js
b/src/dedent.js
index 99d4637c05eb98eeef345febbab258203af4eca9..41319b0b9ba9f1995d71846fef51344e95979d82 100644
(file)
--- a/
src/dedent.js
+++ b/
src/dedent.js
@@
-39,9
+39,9
@@
function dedent(
}, Infinity);
// Strip out minimum indent from every line.
- const dedented = lines.map(line =>
+ const dedented =
isFinite(minimum) ?
lines.map(line =>
line.replace(new RegExp(`^${' '.repeat(minimum)}`, 'g'), ''),
- );
+ )
: lines
;
// Trim first and last line if empty.
if (dedented[0] === '') {