-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.js
More file actions
63 lines (56 loc) · 1.32 KB
/
types.js
File metadata and controls
63 lines (56 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @typedef {object} Block
* @property {string} content
* @property {boolean} isTarget
*/
/**
* Creates a Block object.
* @param {string} content
* @param {boolean} isTarget
* @returns {Block}
*/
function createBlock(content, isTarget) {
return { content, isTarget };
}
/**
* @typedef {object} Submatch
* @property {number} start - The starting byte offset of the match.
* @property {number} end - The ending byte offset of the match.
*/
/**
* @typedef {object} ResultLine
* @property {Block[]} line
* @property {number} line_number
* @property {Submatch[]} submatches
*/
/**
* Creates a ResultLine object.
* @param {Block[]} [line=[]]
* @param {number} [line_number=0]
* @param {Submatch[]} [submatches=[]]
* @returns {ResultLine}
*/
function createResultLine(line = [], line_number = 0, submatches = []) {
return { line, line_number, submatches };
}
/**
* @typedef {object} FileResult
* @property {string} path
* @property {string} filename
* @property {ResultLine[]} results
*/
/**
* Creates a FileResult object.
* @param {string} path
* @param {string} filename
* @param {ResultLine[]} [results=[]]
* @returns {FileResult}
*/
function createFileResult(path, filename, results = []) {
return { path, filename, results };
}
module.exports = {
createBlock,
createResultLine,
createFileResult
};