Skip to content

Commit

Permalink
Fix typos in dedent code (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored and leebyron committed Jan 12, 2018
1 parent 1158cd4 commit 6f15123
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/jsutils/dedent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
*/

/**
* fixes identation by removing leading spaces from each line
* fixes indentation by removing leading spaces from each line
*/
function fixIdent(str: string): string {
const indent = /^\n?( *)/.exec(str)[1]; // figure out ident
function fixIndent(str: string): string {
const indent = /^\n?( *)/.exec(str)[1]; // figure out indent
return str
.replace(RegExp('^' + indent, 'mg'), '') // remove ident
.replace(RegExp('^' + indent, 'mg'), '') // remove indent
.replace(/^\n*/m, '') // remove leading newline
.replace(/ *$/, ''); // remove trailing spaces
}

/**
* An ES6 string tag that fixes identation. Also removes leading newlines
* An ES6 string tag that fixes indentation. Also removes leading newlines
* but keeps trailing ones
*
* Example usage:
Expand All @@ -45,5 +45,5 @@ export default function dedent(
}
}

return fixIdent(res);
return fixIndent(res);
}

0 comments on commit 6f15123

Please sign in to comment.