replace jest with ava
This commit is contained in:
parent
27cc8b23fe
commit
0347b72305
11775 changed files with 84546 additions and 1440575 deletions
38
node_modules/code-excerpt/index.js
generated
vendored
Normal file
38
node_modules/code-excerpt/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
const tabsToSpaces = require('convert-to-spaces');
|
||||
|
||||
const generateLineNumbers = (line, around) => {
|
||||
const lineNumbers = [];
|
||||
|
||||
const min = line - around;
|
||||
const max = line + around;
|
||||
|
||||
for (let lineNumber = min; lineNumber <= max; lineNumber++) {
|
||||
lineNumbers.push(lineNumber);
|
||||
}
|
||||
|
||||
return lineNumbers;
|
||||
};
|
||||
|
||||
module.exports = (source, line, options) => {
|
||||
if (typeof source !== 'string') {
|
||||
throw new TypeError('Source code is missing.');
|
||||
}
|
||||
|
||||
if (!line || line < 1) {
|
||||
throw new TypeError('Line number must start from `1`.');
|
||||
}
|
||||
|
||||
source = tabsToSpaces(source).split(/\r?\n/);
|
||||
|
||||
if (line > source.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
options = Object.assign({around: 3}, options);
|
||||
|
||||
return generateLineNumbers(line, options.around)
|
||||
.filter(line => source[line - 1] !== undefined)
|
||||
.map(line => ({line, value: source[line - 1]}));
|
||||
};
|
||||
21
node_modules/code-excerpt/license
generated
vendored
Normal file
21
node_modules/code-excerpt/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) vdemedes <vdemedes@gmail.com> (github.com/vdemedes)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
31
node_modules/code-excerpt/package.json
generated
vendored
Normal file
31
node_modules/code-excerpt/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "code-excerpt",
|
||||
"version": "2.1.1",
|
||||
"description": "Extract code excerpts",
|
||||
"license": "MIT",
|
||||
"repository": "vadimdemedes/code-excerpt",
|
||||
"author": {
|
||||
"name": "vdemedes",
|
||||
"email": "vdemedes@gmail.com",
|
||||
"url": "github.com/vadimdemedes"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"convert-to-spaces": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.16.0",
|
||||
"xo": "^0.17.1"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
||||
73
node_modules/code-excerpt/readme.md
generated
vendored
Normal file
73
node_modules/code-excerpt/readme.md
generated
vendored
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue