Socket
Socket
Sign inDemoInstall

v8-to-istanbul

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8-to-istanbul - npm Package Compare versions

Comparing version 8.1.0 to 9.0.0-candidate.0

lib/range.js

2

lib/line.js

@@ -7,2 +7,3 @@ module.exports = class CovLine {

this.startCol = startCol
this.minCol = startCol + lineStr.length - lineStr.trimStart().length

@@ -14,2 +15,3 @@ // the line length itself does not include the newline characters,

this.endCol = startCol + lineStr.length - newLineLength
this.maxCol = startCol + lineStr.trimEnd().length

@@ -16,0 +18,0 @@ // we start with all lines having been executed, and work

16

lib/source.js
const CovLine = require('./line')
const { sliceRange } = require('./range')
const { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND } = require('source-map').SourceMapConsumer

@@ -78,5 +79,3 @@

offsetToOriginalRelative (sourceMap, startCol, endCol) {
const lines = this.lines.filter((line, i) => {
return startCol <= line.endCol && endCol >= line.startCol
})
const lines = sliceRange(this.lines, startCol, endCol)
if (!lines.length) return {}

@@ -89,2 +88,6 @@

)
if (!(start && start.source)) {
return {}
}
let end = originalEndPositionFor(

@@ -95,11 +98,6 @@ sourceMap,

)
if (!(start && end)) {
if (!(end && end.source)) {
return {}
}
if (!(start.source && end.source)) {
return {}
}
if (start.source !== end.source) {

@@ -106,0 +104,0 @@ return {}

@@ -8,2 +8,3 @@ const assert = require('assert')

const CovSource = require('./source')
const { sliceRange, trimRange } = require('./range')
const compatError = Error(`requires Node.js ${require('../package.json').engines.node}`)

@@ -46,2 +47,3 @@ let readFile = () => { throw compatError }

const rawSource = this.sources.source || await readFile(this.path, 'utf8')
this.rawSource = rawSource
this.rawSourceMap = this.sources.sourceMap ||

@@ -117,18 +119,20 @@ // if we find a source-map (either inline, or a .map file) we load

}
const lines = covSource.lines.filter(line => {
// Upstream tooling can provide a block with the functionName
// (empty-report), this will result in a report that has all
// lines zeroed out.
if (block.functionName === '(empty-report)') {
// (empty-report), this will result in a report that has all
// lines zeroed out.
if (block.functionName === '(empty-report)') {
this.all = true
covSource.lines.forEach(line => {
line.count = 0
this.all = true
return true
}
})
}
return startCol < line.endCol && endCol >= line.startCol
})
const lines = this.all ? covSource.lines : sliceRange(covSource.lines, startCol, endCol)
if (!lines.length) {
return
}
const startLineInstance = lines[0]
const endLineInstance = lines[lines.length - 1]
if (block.isBlockCoverage && lines.length) {
if (block.isBlockCoverage) {
this.branches[path] = this.branches[path] || []

@@ -144,3 +148,3 @@ // record branches.

// if block-level granularity is enabled, we we still create a single
// if block-level granularity is enabled, we still create a single
// CovFunction tracking object for each set of ranges.

@@ -158,3 +162,3 @@ if (block.functionName && i === 0) {

}
} else if (block.functionName && lines.length) {
} else if (block.functionName) {
this.functions[path] = this.functions[path] || []

@@ -172,2 +176,7 @@ // record functions.

const {
startCol: minCol,
endCol: maxCol
} = this._maybeRemapStartColEndCol(trimRange(this.rawSource, range))
// record the lines (we record these as statements, such that we're

@@ -185,3 +194,3 @@ // compatible with Istanbul 2.0).

if (startCol <= line.startCol && endCol >= line.endCol && !line.ignore) {
if (minCol <= line.minCol && maxCol >= line.maxCol && !line.ignore) {
line.count = range.count

@@ -188,0 +197,0 @@ }

{
"name": "v8-to-istanbul",
"version": "8.1.0",
"version": "9.0.0-candidate.0",
"description": "convert from v8 coverage format to istanbul's format",

@@ -37,4 +37,4 @@ "main": "index.js",

"should": "13.2.3",
"standard": "^16.0.0",
"tap": "^15.0.0"
"standard": "^16.0.4",
"tap": "^15.0.10"
},

@@ -41,0 +41,0 @@ "engines": {

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