Update ava to 4.3.3

The [release notes](https://github.com/avajs/ava/releases/tag/v4.3.3)
mention compatibility with Node 18.8.
This commit is contained in:
Henry Mercer 2022-09-02 18:02:07 +01:00
parent 21530f507f
commit bea5e4b220
160 changed files with 2647 additions and 2263 deletions

9
node_modules/code-excerpt/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,9 @@
interface Options {
around?: number;
}
export interface CodeExcerpt {
line: number;
value: string;
}
declare const codeExcerpt: (source: string, line: number, options?: Options) => CodeExcerpt[] | undefined;
export default codeExcerpt;

27
node_modules/code-excerpt/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,27 @@
import tabsToSpaces from '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;
};
const codeExcerpt = (source, line, options = {}) => {
var _a;
if (typeof source !== 'string') {
throw new TypeError('Source code is missing.');
}
if (!line || line < 1) {
throw new TypeError('Line number must start from `1`.');
}
const lines = tabsToSpaces(source).split(/\r?\n/);
if (line > lines.length) {
return;
}
return generateLineNumbers(line, (_a = options.around) !== null && _a !== void 0 ? _a : 3)
.filter(line => lines[line - 1] !== undefined)
.map(line => ({ line, value: lines[line - 1] }));
};
export default codeExcerpt;

44
node_modules/code-excerpt/index.d.ts generated vendored
View file

@ -1,44 +0,0 @@
declare namespace codeExcerpt {
interface Options {
/**
* Number of surrounding lines to extract.
*
* @default 3
*/
readonly around?: number;
}
interface ExcerptLine {
/**
* Line number
*/
readonly line: number;
/**
* Line itself
*/
readonly value: string;
}
}
/**
* Extract code excerpts
*/
declare function codeExcerpt(
/**
* Source code
*/
source: string,
/**
* Line number to extract excerpt for.
*/
line: number,
/**
* Options
*/
options?: codeExcerpt.Options
): codeExcerpt.ExcerptLine[] | undefined;
export = codeExcerpt;

40
node_modules/code-excerpt/index.js generated vendored
View file

@ -1,40 +0,0 @@
'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;
}
options = {
around: 3,
...options
};
return generateLineNumbers(line, options.around)
.filter(line => source[line - 1] !== undefined)
.map(line => ({line, value: source[line - 1]}));
};

View file

@ -1,6 +1,6 @@
{
"name": "code-excerpt",
"version": "3.0.0",
"version": "4.0.0",
"description": "Extract code excerpts",
"license": "MIT",
"repository": "vadimdemedes/code-excerpt",
@ -9,22 +9,35 @@
"email": "vdemedes@gmail.com",
"url": "github.com/vadimdemedes"
},
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "tsd && xo && ava"
"build": "tsc",
"dev": "tsc --watch",
"prepare": "npm run build",
"pretest": "npm run build",
"test": "xo && ava"
},
"files": [
"index.js",
"index.d.ts"
"dist"
],
"dependencies": {
"convert-to-spaces": "^1.0.1"
"convert-to-spaces": "^2.0.1"
},
"devDependencies": {
"ava": "^3.9.0",
"tsd": "^0.11.0",
"xo": "^0.32.0"
}
"@sindresorhus/tsconfig": "^2.0.0",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^4.0.1",
"prettier": "^2.5.1",
"typescript": "^4.5.5",
"xo": "^0.47.0"
},
"xo": {
"prettier": true
},
"prettier": "@vdemedes/prettier-config"
}

View file

@ -11,7 +11,7 @@ $ npm install --save code-excerpt
## Usage
```js
const codeExcerpt = require('code-excerpt');
import codeExcerpt from 'code-excerpt';
const source = `
'use strict';