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

istanbul-api

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-api

High level API for istanbul features

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
decreased by-33.71%
Maintainers
3
Weekly downloads
 
Created

What is istanbul-api?

The 'istanbul-api' npm package provides a set of APIs for working with code coverage in JavaScript projects. It is part of the Istanbul toolset, which is widely used for measuring code coverage in JavaScript applications. The package allows you to create coverage reports, manage coverage data, and instrument code for coverage analysis.

What are istanbul-api's main functionalities?

Creating Coverage Reports

This feature allows you to create coverage reports in various formats such as HTML. The code sample demonstrates how to create an HTML coverage report using the 'istanbul-api' package.

const istanbul = require('istanbul-api');
const reports = istanbul.reports;
const collector = new istanbul.Collector();
const reporter = reports.create('html', { dir: './coverage' });

collector.add(global.__coverage__);
reporter.writeReport(collector, true);

Managing Coverage Data

This feature allows you to manage and manipulate coverage data. The code sample shows how to create a coverage map and add file coverage data to it.

const istanbul = require('istanbul-api');
const coverageMap = istanbul.libCoverage.createCoverageMap();

coverageMap.addFileCoverage(global.__coverage__);
console.log(coverageMap.toJSON());

Instrumenting Code for Coverage

This feature allows you to instrument code for coverage analysis. The code sample demonstrates how to read a JavaScript file, instrument it for coverage, and write the instrumented code to a new file.

const istanbul = require('istanbul-api');
const instrumenter = istanbul.libInstrument.createInstrumenter();
const fs = require('fs');

const code = fs.readFileSync('path/to/your/file.js', 'utf8');
const instrumentedCode = instrumenter.instrumentSync(code, 'path/to/your/file.js');

fs.writeFileSync('path/to/your/instrumented-file.js', instrumentedCode);

Other packages similar to istanbul-api

Keywords

FAQs

Package last updated on 10 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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