Socket
Socket
Sign inDemoInstall

v8-to-istanbul

Package Overview
Dependencies
1
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 3.0.0

lib/pathutils.js

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

# [3.0.0](https://github.com/bcoe/v8-to-istanbul/compare/v2.0.2...v3.0.0) (2019-04-29)
### Features
* initial support for source-maps ([#19](https://github.com/bcoe/v8-to-istanbul/issues/19)) ([ab0fcdd](https://github.com/bcoe/v8-to-istanbul/commit/ab0fcdd))
### BREAKING CHANGES
* v8-to-istanbul is now async, making it possible to use the latest source-map library
# [2.1.0](https://github.com/bcoe/v8-to-istanbul/compare/v2.0.5...v2.1.0) (2019-04-21)

@@ -7,0 +18,0 @@

4

index.js

@@ -1,5 +0,5 @@

const Script = require('./lib/script')
const V8ToIstanbul = require('./lib/v8-to-istanbul')
module.exports = function (path, wrapperLength) {
return new Script(path, wrapperLength)
return new V8ToIstanbul(path, wrapperLength)
}

@@ -12,8 +12,8 @@ module.exports = class CovBranch {

start: {
line: this.startLine.line,
column: this.startCol - this.startLine.startCol
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine.line,
column: this.endCol - this.endLine.startCol
line: this.endLine,
column: this.endCol
}

@@ -23,3 +23,3 @@ }

type: 'branch',
line: this.line,
line: this.startLine,
loc: location,

@@ -26,0 +26,0 @@ locations: [Object.assign({}, location)]

@@ -13,8 +13,8 @@ module.exports = class CovFunction {

start: {
line: this.startLine.line,
column: this.startCol - this.startLine.startCol
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine.line,
column: this.endCol - this.endLine.startCol
line: this.endLine,
column: this.endCol
}

@@ -26,5 +26,5 @@ }

loc: loc,
line: this.startLine.line
line: this.startLine
}
}
}
module.exports = class CovLine {
constructor (line, startCol, endCol) {
constructor (line, startCol, lineStr) {
this.line = line
// note that startCol and endCol are absolute positions
// within a file, not relative to the line.
this.startCol = startCol
this.endCol = endCol
this.count = 0
// the line length itself does not include the newline characters,
// these are however taken into account when enumerating absolute offset.
const matchedNewLineChar = lineStr.match(/\r?\n$/u)
const newLineLength = matchedNewLineChar ? matchedNewLineChar[0].length : 0
this.endCol = startCol + lineStr.length - newLineLength
// we start with all lines having been executed, and work
// backwards zeroing out lines based on V8 output.
this.count = 1
}

@@ -8,0 +18,0 @@ toIstanbul () {

{
"name": "v8-to-istanbul",
"version": "2.1.0",
"version": "3.0.0",
"description": "convert from v8 coverage format to istanbul's format",

@@ -32,2 +32,3 @@ "main": "index.js",

"should": "^13.2.3",
"source-map": "^0.7.3",
"standard": "^12.0.1",

@@ -39,3 +40,6 @@ "standard-version": "^5.0.2",

"node": ">=10.10.0"
},
"dependencies": {
"convert-source-map": "^1.6.0"
}
}

@@ -13,8 +13,8 @@ # v8-to-istanbul

const v8toIstanbul = require('v8-to-istanbul')
// create a script object from a source-file. the source file
// is loaded from disk and this is used to determine the original
// line count.
const script = v8toIstanbul('./path-to-instrumented-file.js')
// the path to the original source-file is required, as its contents are
// used during the conversion algorithm.
const converter = v8toIstanbul('./path-to-instrumented-file.js')
await converter.load() // this is required due to the async source-map dependency.
// provide an array of coverage information in v8 format.
script.applyCoverage([
converter.applyCoverage([
{

@@ -35,3 +35,3 @@ "functionName": "",

// be consumed by Istanbul.
console.info(JSON.stringify(script.toIstanbul()))
console.info(JSON.stringify(converter.toIstanbul()))
```

@@ -38,0 +38,0 @@

@@ -9,4 +9,5 @@ /* global describe, it */

module.exports = (fixture) => {
module.exports = async (fixture) => {
const script = toIstanbul(fixture.coverageV8.url)
await script.load()
script.applyCoverage(fixture.coverageV8.functions)

@@ -20,4 +21,2 @@

describe(fixture.describe, () => {
// run with DEBUG=true to output coverage information to
// terminal; this is useful when writing new tests.
it('matches snapshot', () => {

@@ -24,0 +23,0 @@ t.matchSnapshot(coverageIstanbul)

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