forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvenient_hunk.js
More file actions
38 lines (33 loc) · 867 Bytes
/
Copy pathconvenient_hunk.js
File metadata and controls
38 lines (33 loc) · 867 Bytes
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
var NodeGit = require("../");
var ConvenientLine = NodeGit.ConvenientLine;
function ConvenientHunk(raw, i) {
this.raw = raw;
this.i = i;
}
/**
* Diff header string that represents the context of this hunk
* of the diff. Something like `@@ -169,14 +167,12 @@ ...`
* @return {String}
*/
ConvenientHunk.prototype.header = function() {
return this.raw.getHunk(this.i).hunk.header();
};
/**
* Number of lines in this hunk
* @return {Number}
*/
ConvenientHunk.prototype.size = function() {
return this.raw.numLinesInHunk(this.i);
};
/**
* The lines in this hunk
* @return {[String]} array of strings
*/
ConvenientHunk.prototype.lines = function() {
var result = [];
for (var i = 0; i < this.size(); i++) {
result.push(new ConvenientLine(this.raw.getLineInHunk(this.i, i), i));
}
return result;
};
NodeGit.ConvenientHunk = ConvenientHunk;