Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

istanbul

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

download-escodegen-browser.sh

10

CHANGELOG.md

@@ -6,2 +6,12 @@ Changelog

<tr>
<td>v0.3.9</td>
<td>
<ul>
<li>Merge harmony branch and start adding ES6 features to istanbul</li>
<li>Arrow functions are the only feature of interest now</li>
<li>`for-of` and `yield` support exist but not present in mainline esprima yet</li>
</ul>
</td>
</tr>
<tr>
<td>v0.3.8</td>

@@ -8,0 +18,0 @@ <td>

120

lib/instrumenter.js

@@ -69,43 +69,73 @@ /*

SYNTAX = {
ArrayExpression: [ 'elements' ],
// keep in sync with estraverse's VisitorKeys
AssignmentExpression: ['left', 'right'],
BinaryExpression: ['left', 'right' ],
BlockStatement: [ 'body' ],
BreakStatement: [ 'label' ],
CallExpression: [ 'callee', 'arguments'],
AssignmentPattern: ['left', 'right'],
ArrayExpression: ['elements'],
ArrayPattern: ['elements'],
ArrowFunctionExpression: ['params', 'body'],
AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
BlockStatement: ['body'],
BinaryExpression: ['left', 'right'],
BreakStatement: ['label'],
CallExpression: ['callee', 'arguments'],
CatchClause: ['param', 'body'],
ConditionalExpression: [ 'test', 'consequent', 'alternate' ],
ContinueStatement: [ 'label' ],
DebuggerStatement: [ ],
DoWhileStatement: [ 'body', 'test' ],
ClassBody: ['body'],
ClassDeclaration: ['id', 'superClass', 'body'],
ClassExpression: ['id', 'superClass', 'body'],
ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
ConditionalExpression: ['test', 'consequent', 'alternate'],
ContinueStatement: ['label'],
DebuggerStatement: [],
DirectiveStatement: [],
DoWhileStatement: ['body', 'test'],
EmptyStatement: [],
ExpressionStatement: [ 'expression'],
ForInStatement: [ 'left', 'right', 'body' ],
ForStatement: ['init', 'test', 'update', 'body' ],
ExportAllDeclaration: ['source'],
ExportDefaultDeclaration: ['declaration'],
ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
ExportSpecifier: ['exported', 'local'],
ExpressionStatement: ['expression'],
ForStatement: ['init', 'test', 'update', 'body'],
ForInStatement: ['left', 'right', 'body'],
ForOfStatement: ['left', 'right', 'body'],
FunctionDeclaration: ['id', 'params', 'body'],
FunctionExpression: ['id', 'params', 'defaults', 'body'],
FunctionExpression: ['id', 'params', 'body'],
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
ImportDeclaration: ['specifiers', 'source'],
ImportDefaultSpecifier: ['local'],
ImportNamespaceSpecifier: ['local'],
ImportSpecifier: ['imported', 'local'],
Literal: [],
LabeledStatement: ['label', 'body'],
Literal: [],
LogicalExpression: [ 'left', 'right' ],
LogicalExpression: ['left', 'right'],
MemberExpression: ['object', 'property'],
MethodDefinition: ['key', 'value'],
ModuleSpecifier: [],
NewExpression: ['callee', 'arguments'],
ObjectExpression: [ 'properties' ],
Program: [ 'body' ],
Property: [ 'key', 'value'],
ObjectExpression: ['properties'],
ObjectPattern: ['properties'],
Program: ['body'],
Property: ['key', 'value'],
RestElement: [ 'argument' ],
ReturnStatement: ['argument'],
SequenceExpression: ['expressions'],
SwitchCase: [ 'test', 'consequent' ],
SwitchStatement: ['discriminant', 'cases' ],
SpreadElement: ['argument'],
SuperExpression: ['super'],
SwitchStatement: ['discriminant', 'cases'],
SwitchCase: ['test', 'consequent'],
TaggedTemplateExpression: ['tag', 'quasi'],
TemplateElement: [],
TemplateLiteral: ['quasis', 'expressions'],
ThisExpression: [],
ThrowStatement: ['argument'],
TryStatement: [ 'block', 'handlers', 'finalizer' ],
TryStatement: ['block', 'handler', 'finalizer'],
UnaryExpression: ['argument'],
UpdateExpression: [ 'argument' ],
VariableDeclaration: [ 'declarations' ],
VariableDeclarator: [ 'id', 'init' ],
WhileStatement: [ 'test', 'body' ],
WithStatement: [ 'object', 'body' ]
UpdateExpression: ['argument'],
VariableDeclaration: ['declarations'],
VariableDeclarator: ['id', 'init'],
WhileStatement: ['test', 'body'],
WithStatement: ['object', 'body'],
YieldExpression: ['argument']
};

@@ -128,3 +158,4 @@

postIncrement: function (obj) { return { type: SYNTAX.UpdateExpression.name, operator: '++', prefix: false, argument: obj }; },
sequence: function (one, two) { return { type: SYNTAX.SequenceExpression.name, expressions: [one, two] }; }
sequence: function (one, two) { return { type: SYNTAX.SequenceExpression.name, expressions: [one, two] }; },
returnStatement: function (expr) { return { type: SYNTAX.ReturnStatement.name, argument: expr }; }
};

@@ -148,3 +179,3 @@

postprocessor,
children = SYNTAX[type].children,
children = SYNTAX[type],
// don't run generated nodes thru custom walks otherwise we will attempt to instrument the instrumentation code :)

@@ -165,2 +196,8 @@ applyCustomWalker = !!node.loc || node.type === SYNTAX.Program.name,

if (!SYNTAX[type]) {
console.error(node);
console.error('Unsupported node type:' + type);
return;
}
children = SYNTAX[type].children;
/* istanbul ignore if: guard */

@@ -353,2 +390,3 @@ if (node.walking) { throw new Error('Infinite regress: Custom walkers may NOT call walker.apply(node)'); }

this.walker = new Walker({
ArrowFunctionExpression: [ this.arrowBlockConverter ],
ExpressionStatement: this.coverStatement,

@@ -360,3 +398,3 @@ BreakStatement: this.coverStatement,

ThrowStatement: this.coverStatement,
TryStatement: this.coverStatement,
TryStatement: [ this.paranoidHandlerCheck, this.coverStatement],
VariableDeclaration: this.coverStatement,

@@ -366,2 +404,3 @@ IfStatement: [ this.ifBlockConverter, this.coverStatement, this.ifBranchInjector ],

ForInStatement: [ this.skipLeft, this.loopBlockConverter, this.coverStatement ],
ForOfStatement: [ this.skipLeft, this.loopBlockConverter, this.coverStatement ],
WhileStatement: [ this.loopBlockConverter, this.coverStatement ],

@@ -669,2 +708,23 @@ DoWhileStatement: [ this.loopBlockConverter, this.coverStatement ],

arrowBlockConverter: function (node) {
var retStatement;
if (node.expression) { // turn expression nodes into a block with a return statement
retStatement = astgen.returnStatement(node.body);
// ensure the generated return statement is covered
retStatement.loc = node.body.loc;
node.body = this.convertToBlock(retStatement);
node.expression = false;
}
},
paranoidHandlerCheck: function (node) {
// if someone is using an older esprima on the browser
// convert handlers array to single handler attribute
// containing its first element
/* istanbul ignore next */
if (!node.handler && node.handlers) {
node.handler = node.handlers[0];
}
},
ifBlockConverter: function (node) {

@@ -671,0 +731,0 @@ node.consequent = this.convertToBlock(node.consequent);

{
"name": "istanbul",
"version": "0.3.8",
"version": "0.3.9",
"description": "Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale",

@@ -58,3 +58,3 @@ "keywords": [ "coverage", "code coverage", "JS code coverage", "JS coverage" ],

"pretest": "jshint index.js lib/ test/",
"test": "node test/run.js",
"test": "node --harmony test/run.js",
"posttest": "node ./lib/cli.js check-coverage --statements 95 --branches 80",

@@ -71,3 +71,3 @@ "docs": "npm install yuidocjs && node node_modules/yuidocjs/lib/cli.js ."

"dependencies": {
"esprima": "2.0.x",
"esprima": "2.1.x",
"escodegen": "1.3.x",

@@ -74,0 +74,0 @@ "handlebars": "1.3.x",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc