mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #59510 Added types for lcov-parse by @roccivic
This commit is contained in:
85
types/lcov-parse/index.d.ts
vendored
Normal file
85
types/lcov-parse/index.d.ts
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
// Type definitions for lcov-parse 1.0
|
||||
// Project: https://github.com/davglass/lcov-parse
|
||||
// Definitions by: Rouslan Placella <https://github.com/roccivic>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace parse {
|
||||
/**
|
||||
* Line coverage detail
|
||||
*/
|
||||
interface LcovLine {
|
||||
line: number;
|
||||
hit: number;
|
||||
}
|
||||
/**
|
||||
* Function coverage detail
|
||||
*/
|
||||
interface LcovFunc {
|
||||
name: string;
|
||||
line: number;
|
||||
hit: number;
|
||||
}
|
||||
/**
|
||||
* Branch coverage detail
|
||||
*/
|
||||
interface LcovBranch {
|
||||
line: number;
|
||||
block: number;
|
||||
branch: number;
|
||||
taken: number;
|
||||
}
|
||||
/**
|
||||
* Code coverage for lines, functions or branches in a file
|
||||
*/
|
||||
interface LcovPart<T> {
|
||||
hit: number;
|
||||
found: number;
|
||||
details: T[];
|
||||
}
|
||||
/**
|
||||
* Code coverage for a file
|
||||
*/
|
||||
interface LcovFile {
|
||||
title: string;
|
||||
file: string;
|
||||
lines: LcovPart<LcovLine>;
|
||||
functions: LcovPart<LcovFunc>;
|
||||
branches: LcovPart<LcovBranch>;
|
||||
}
|
||||
/**
|
||||
* Parses an LCOV code coverage string:
|
||||
* ```
|
||||
* parse(lcovString, function(err, data) {
|
||||
* //process the data here
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param str LCOV string to parse
|
||||
* @param cb Callback: first arg is `null` or error string,
|
||||
* second arg is parsed data or `undefined` if an error occurred
|
||||
*/
|
||||
function source(str: string, cb: (err: null | string, data: LcovFile[] | undefined) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an LCOV code coverage file:
|
||||
* ```
|
||||
* parse('./path/to/file.info', function(err, data) {
|
||||
* //process the data here
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The first argument can also be an LCOV string to parse:
|
||||
* ```
|
||||
* parse(lcovString, function(err, data) {
|
||||
* //process the data here
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param file Path to the LCOV file or string to parse
|
||||
* @param cb Callback: first arg is `null` or error string,
|
||||
* second arg is parsed data or `undefined` if an error occurred
|
||||
*/
|
||||
declare function parse(file: string, cb: (err: null | string, data: parse.LcovFile[] | undefined) => void): void;
|
||||
|
||||
export = parse;
|
||||
38
types/lcov-parse/lcov-parse-tests.ts
Normal file
38
types/lcov-parse/lcov-parse-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import parse = require('lcov-parse');
|
||||
|
||||
const sample = `TN:
|
||||
SF:src/most.js
|
||||
FN:1,sum
|
||||
FN:5,product
|
||||
FNF:2
|
||||
FNH:1
|
||||
FNDA:1,sum
|
||||
FNDA:0,product
|
||||
DA:2,1
|
||||
DA:6,0
|
||||
DA:9,1
|
||||
LF:3
|
||||
LH:2
|
||||
BRF:0
|
||||
BRH:0
|
||||
end_of_record`;
|
||||
|
||||
parse('', (err, data) => {
|
||||
err; // $ExpectedType string
|
||||
data; // $ExpectedType undefined
|
||||
});
|
||||
|
||||
parse(sample, (err, data) => {
|
||||
err; // $ExpectedType null
|
||||
data; // $ExpectedType LcovFile[]
|
||||
});
|
||||
|
||||
parse.source('', (err, data) => {
|
||||
err; // $ExpectedType string
|
||||
data; // $ExpectedType undefined
|
||||
});
|
||||
|
||||
parse.source(sample, (err, data) => {
|
||||
err; // $ExpectedType null
|
||||
data; // $ExpectedType LcovFile[]
|
||||
});
|
||||
23
types/lcov-parse/tsconfig.json
Normal file
23
types/lcov-parse/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lcov-parse-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/lcov-parse/tslint.json
Normal file
1
types/lcov-parse/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user