New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require Node.js 8, add TypeScript definition #6
Merged
sindresorhus
merged 2 commits into
sindresorhus:master
from
BendingBender:typescript-defs
Apr 17, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' | ||
- '4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
Strip leading whitespace from each line in a string. | ||
|
||
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove. | ||
|
||
@example | ||
``` | ||
import stripIndent = require('strip-indent'); | ||
|
||
const string = '\tunicorn\n\t\tcake'; | ||
// unicorn | ||
// cake | ||
|
||
stripIndent(string); | ||
//unicorn | ||
// cake | ||
``` | ||
*/ | ||
declare function stripIndent(string: string): string; | ||
|
||
export = stripIndent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
'use strict'; | ||
const minIndent = require('min-indent'); | ||
|
||
module.exports = str => { | ||
const indent = minIndent(str); | ||
module.exports = string => { | ||
const indent = minIndent(string); | ||
|
||
if (indent === 0) { | ||
return str; | ||
return string; | ||
} | ||
|
||
const re = new RegExp(`^[ \\t]{${indent}}`, 'gm'); | ||
const regExp = new RegExp(`^[ \\t]{${indent}}`, 'gm'); | ||
|
||
return str.replace(re, ''); | ||
return string.replace(regExp, ''); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {expectType} from 'tsd'; | ||
import stripIndent = require('.'); | ||
|
||
expectType<string>(stripIndent('\tunicorn\n\t\tcake')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import test from 'ava'; | ||
import m from '.'; | ||
import stripIndent from '.'; | ||
|
||
test(t => { | ||
t.is(m('\nunicorn\n'), '\nunicorn\n'); | ||
t.is(m('\n unicorn\n'), '\nunicorn\n'); | ||
t.is(m('\t\t<!doctype html>\n\t\t<html>\n\t\t\t<body>\n\n\n\n\t\t\t\t<h1>Hello world!</h1>\n\t\t\t</body>\n\t\t</html>'), '<!doctype html>\n<html>\n\t<body>\n\n\n\n\t\t<h1>Hello world!</h1>\n\t</body>\n</html>'); | ||
t.is(m('\n\t\n\t\tunicorn\n\n\n\n\t\t\tunicorn'), '\n\t\nunicorn\n\n\n\n\tunicorn', 'ignore whitespace only lines'); | ||
test('main', t => { | ||
t.is(stripIndent('\nunicorn\n'), '\nunicorn\n'); | ||
t.is(stripIndent('\n unicorn\n'), '\nunicorn\n'); | ||
t.is(stripIndent('\t\t<!doctype html>\n\t\t<html>\n\t\t\t<body>\n\n\n\n\t\t\t\t<h1>Hello world!</h1>\n\t\t\t</body>\n\t\t</html>'), '<!doctype html>\n<html>\n\t<body>\n\n\n\n\t\t<h1>Hello world!</h1>\n\t</body>\n</html>'); | ||
t.is(stripIndent('\n\t\n\t\tunicorn\n\n\n\n\t\t\tunicorn'), '\n\t\nunicorn\n\n\n\n\tunicorn', 'ignore whitespace only lines'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open an issue on VS Code about supporting either
/* */
comments unescaped inside codeblocks in doc comments (preferred) or alternatively/additionally support escaped\/* */
comments inside doc comments (meaning it's not displayed as escaped). It's silly that we have to use line comments like this. It makes it harder to read the example output.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened an issue.