Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80600 views
1
/**
2
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
3
*
4
* This source code is licensed under the BSD-style license found in the
5
* LICENSE file in the root directory of this source tree. An additional grant
6
* of patent rights can be found in the PATENTS file in the same directory.
7
*/
8
'use strict';
9
10
var istanbul = require('istanbul');
11
12
function IstanbulCollector(sourceText, filename) {
13
var instr = new istanbul.Instrumenter();
14
this._coverageDataStore = {};
15
this._instrumentor = instr;
16
this._origSourceText = sourceText;
17
this._instrumentedSourceText = instr.instrumentSync(sourceText, filename);
18
}
19
20
IstanbulCollector.prototype.getCoverageDataStore = function() {
21
return this._coverageDataStore;
22
};
23
24
IstanbulCollector.prototype.getInstrumentedSource = function(storageVarName) {
25
return this._instrumentedSourceText + storageVarName + '.coverState=' +
26
this._instrumentor.currentState.trackerVar + ';';
27
};
28
29
IstanbulCollector.prototype.extractRuntimeCoverageInfo = function() {
30
return this._coverageDataStore.coverState;
31
};
32
33
module.exports = IstanbulCollector;
34
35