Socket
Socket
Sign inDemoInstall

istanbul-lib-instrument

Package Overview
Dependencies
34
Maintainers
3
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.1.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

# [3.1.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@3.0.1...istanbul-lib-instrument@3.1.0) (2019-01-26)
### Features
* dont skip for loop initialization instrumentation ([#188](https://github.com/istanbuljs/istanbuljs/issues/188)) ([2e0258e](https://github.com/istanbuljs/istanbuljs/commit/2e0258e))
* New options coverageGlobalScope and coverageGlobalScopeFunc. ([#200](https://github.com/istanbuljs/istanbuljs/issues/200)) ([25509c7](https://github.com/istanbuljs/istanbuljs/commit/25509c7)), closes [#199](https://github.com/istanbuljs/istanbuljs/issues/199)
<a name="3.0.1"></a>

@@ -8,0 +20,0 @@ ## [3.0.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-instrument@3.0.0...istanbul-lib-instrument@3.0.1) (2018-12-25)

4

dist/instrumenter.js

@@ -30,2 +30,4 @@ "use strict";

coverageVariable: '__coverage__',
coverageGlobalScope: 'this',
coverageGlobalScopeFunc: true,
preserveComments: false,

@@ -117,2 +119,4 @@ compact: true,

coverageVariable: opts.coverageVariable,
coverageGlobalScope: opts.coverageGlobalScope,
coverageGlobalScopeFunc: opts.coverageGlobalScopeFunc,
ignoreClassMethods: opts.ignoreClassMethods,

@@ -119,0 +123,0 @@ inputSourceMap: inputSourceMap

1

dist/read-coverage.js

@@ -31,3 +31,2 @@ "use strict";

sourceType: 'script',
// I think ?
plugins: ['asyncGenerators', 'dynamicImport', 'objectRestSpread', 'optionalCatchBinding', 'flow', 'jsx']

@@ -34,0 +33,0 @@ });

@@ -16,2 +16,4 @@ "use strict";

var _instrumenter = require("./instrumenter");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -356,8 +358,2 @@

function skipInit(path) {
if (path.node.init) {
this.setAttr(path.node.init, 'skip-all', true);
}
}
function makeBlock(path) {

@@ -517,5 +513,5 @@ const T = this.types;

IfStatement: entries(blockProp('consequent'), blockProp('alternate'), coverStatement, coverIfBranches),
ForStatement: entries(blockProp('body'), skipInit, coverStatement),
ForInStatement: entries(blockProp('body'), skipInit, coverStatement),
ForOfStatement: entries(blockProp('body'), skipInit, coverStatement),
ForStatement: entries(blockProp('body'), coverStatement),
ForInStatement: entries(blockProp('body'), coverStatement),
ForOfStatement: entries(blockProp('body'), coverStatement),
WhileStatement: entries(blockProp('body'), coverStatement),

@@ -531,13 +527,19 @@ DoWhileStatement: entries(blockProp('body'), coverStatement),

LogicalExpression: entries(coverLogicalExpression)
}; // the template to insert at the top of the program.
};
const globalTemplateFunction = (0, _template.default)(`
var Function = (function(){}).constructor;
var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
`);
const globalTemplateVariable = (0, _template.default)(`
var global = GLOBAL_COVERAGE_SCOPE;
`); // the template to insert at the top of the program.
const coverageTemplate = (0, _template.default)(`
var COVERAGE_VAR = (function () {
var path = PATH,
hash = HASH,
Function = (function(){}).constructor,
global = (new Function('return this'))(),
gcv = GLOBAL_COVERAGE_VAR,
coverageData = INITIAL,
coverage = global[gcv] || (global[gcv] = {});
var path = PATH;
var hash = HASH;
GLOBAL_COVERAGE_TEMPLATE
var gcv = GLOBAL_COVERAGE_VAR;
var coverageData = INITIAL;
var coverage = global[gcv] || (global[gcv] = {});
if (coverage[path] && coverage[path].hash === hash) {

@@ -564,4 +566,2 @@ return coverage[path];

const defaultProgramVisitorOpts = {
coverageVariable: '__coverage__',
ignoreClassMethods: [],
inputSourceMap: undefined

@@ -586,2 +586,4 @@ };

* @param {string} [opts.coverageVariable=__coverage__] the global coverage variable name.
* @param {string} [opts.coverageGlobalScope=this] the global coverage variable scope.
* @param {boolean} [opts.coverageGlobalScopeFunc=true] use an evaluated function to find coverageGlobalScope.
* @param {Array} [opts.ignoreClassMethods=[]] names of methods to ignore by default on classes.

@@ -593,3 +595,5 @@ * @param {object} [opts.inputSourceMap=undefined] the input source map, that maps the uninstrumented code back to the

function programVisitor(types, sourceFilePath = 'unknown.js', opts = defaultProgramVisitorOpts) {
const T = types;
const T = types; // This sets some unused options but ensures all required options are initialized
opts = Object.assign({}, (0, _instrumenter.defaultOpts)(), defaultProgramVisitorOpts, opts);
const visitState = new VisitState(types, sourceFilePath, opts.inputSourceMap, opts.ignoreClassMethods);

@@ -628,4 +632,17 @@ return {

delete coverageData[_constants.MAGIC_KEY];
let gvTemplate;
if (opts.coverageGlobalScopeFunc) {
gvTemplate = globalTemplateFunction({
GLOBAL_COVERAGE_SCOPE: T.stringLiteral('return ' + opts.coverageGlobalScope)
});
} else {
gvTemplate = globalTemplateVariable({
GLOBAL_COVERAGE_SCOPE: opts.coverageGlobalScope
});
}
const cv = coverageTemplate({
GLOBAL_COVERAGE_VAR: T.stringLiteral(opts.coverageVariable),
GLOBAL_COVERAGE_TEMPLATE: gvTemplate,
COVERAGE_VAR: T.identifier(visitState.varName),

@@ -632,0 +649,0 @@ PATH: T.stringLiteral(sourceFilePath),

{
"name": "istanbul-lib-instrument",
"version": "3.0.1",
"version": "3.1.0",
"description": "Core istanbul API for JS code coverage",

@@ -21,18 +21,5 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

"@babel/types": "^7.0.0",
"istanbul-lib-coverage": "^2.0.2",
"istanbul-lib-coverage": "^2.0.3",
"semver": "^5.5.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"chai": "^4.1.2",
"clone": "^2.1.1",
"debug": "^3.1.0",
"documentation": "^7.1.0",
"js-yaml": "^3.12.0",
"mocha": "^5.2.0",
"nopt": "^4.0.1"
},
"license": "BSD-3-Clause",

@@ -55,3 +42,4 @@ "bugs": {

"node": ">=6"
}
},
"gitHead": "7875defdc3c3640787ac5d83700246de119e8b83"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc