diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/code-excerpt/readme.md | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/code-excerpt/readme.md')
-rw-r--r-- | node_modules/code-excerpt/readme.md | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/node_modules/code-excerpt/readme.md b/node_modules/code-excerpt/readme.md new file mode 100644 index 000000000..216b6b3d5 --- /dev/null +++ b/node_modules/code-excerpt/readme.md @@ -0,0 +1,73 @@ +# code-excerpt [](https://travis-ci.org/vadimdemedes/code-excerpt) + +> Extract code excerpts + + +## Install + +``` +$ npm install --save code-excerpt +``` + + +## Usage + +```js +const codeExcerpt = require('code-excerpt'); + +const source = ` +'use strict'; + +function someFunc() {} + +module.exports = () => { + const a = 1; + const b = 2; + const c = 3; + + someFunc(); +}; +`.trim(); + +const excerpt = codeExcerpt(source, 5); +//=> [ +// {line: 2, value: ''}, +// {line: 3, value: 'function someFunc() {}'}, +// {line: 4, value: ''}, +// {line: 5, value: 'module.exports = () => {'}, +// {line: 6, value: ' const a = 1;'}, +// {line: 7, value: ' const b = 2;'}, +// {line: 8, value: ' const c = 3;'} +// ] +``` + + +## API + +### codeExcerpt(source, line, [options]) + +#### source + +Type: `string` + +Source code. + +#### line + +Type: `number` + +Line number to extract excerpt for. + +#### options + +##### around + +Type: `number`<br> +Default: `3` + +Number of surrounding lines to extract. + + +## License + +MIT © [Vadim Demedes](https://github.com/vadimdemedes) |