Alexandro.Net

Version 1.0.3

@stackline/blanket

Maintained Blanket.js 1.2.3 compatibility fork with directive-safe coverage instrumentation

Independent Stackline maintenance of blanket 1.2.3. The published license and original attribution are retained.

Installation

npm install --save-dev --save-exact @stackline/blanket@1.0.3

To keep the upstream import name:

npm install --save-dev --save-exact blanket@npm:@stackline/blanket@1.0.3

Usage and API

@stackline/blanket

Maintained Blanket.js 1.2.3 compatibility fork with directive-safe coverage instrumentation.

npm version license GitHub repository Docs Reddit community

Documentation | npm | Issues | Repository

Current package version: 1.0.3


Why this package?

This is a maintained compatibility fork of the MIT-licensed blanket@1.2.3 coverage instrumenter.

Version 1.0.0 fixed upstream issue #340: coverage counters no longer precede a function's directive prologue and accidentally disable strict mode. Program directives keep their order before coverage initialization; strictness does not leak between instrumented files. Ordinary string expressions, parenthesized strings, and escaped lookalikes do not become strict directives.

The implementation retains Blanket's instrumentation and coverage format. Its small MIT-licensed parser-walking and options-copying helpers are included internally, with attribution, and obsolete compatibility-shim dependencies are removed. Acorn is the single runtime dependency. The QUnit, Mocha, and Jasmine bundles, including their minified variants, are rebuilt from the same corrected source.

Compatibility

Item Value
Package @stackline/blanket@1.0.3
Supported Node.js >=20
Module entry src/index.js (CommonJS)
Runtime dependencies 1 direct dependency

Browser bundles require ES5 array/object methods and a browser supported by the selected test framework. The default parser remains configured for ECMAScript 5; updating the parser does not make the legacy instrumenter support every newer syntax feature.

Installation

npm install --save-dev @stackline/blanket

The legacy Mocha require hook accepts the scoped name:

mocha --require @stackline/blanket

Usage

const blanket = require('@stackline/blanket')({ engineOnly: true });
const instrumented = blanket.instrumentSync({
  inputFile: "function example() { 'use strict'; return this; }",
  inputFileName: 'example.js'
});

Security

Instrumentation preserves directive prologues, including use strict. The default parser targets ECMAScript 5; newer parser dependencies do not imply support for every newer language feature.

API Surface

The full historical options and API reference are preserved in README.upstream.md. The compatibility notes above describe changes in the maintained package.

Local Development

Clone the repository and run the following commands from its root:

npm ci
npm run build
npm test

Tests cover strict-mode behavior, directive order, counters, callbacks, branch data, a real CommonJS require hook, and all six distributed browser instrumenters in VM browser contexts. Full browser-runner UI behavior and every historical framework version are not covered. The old Mocha html-cov reporter is a separate integration concern; this fork does not restore a reporter removed by Mocha.

Release Checklist

  1. Update the package version, lockfile, generated version fields, and changelog together.
  2. Run the development checks above and audit both npm audit and npm audit --omit=dev.
  3. Use the GitHub publish workflow with its Prod environment to publish the exact CI tarball.
  4. Verify public npm bytes, package identity, provenance, and the immutable GitHub release evidence.

License

MIT. Original copyright notices and upstream attribution are retained.

See UPSTREAM.md and THIRD_PARTY_NOTICES.md for the source basis and bundled helper attribution.

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

Community and Links

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.

Historical upstream configuration

Blanket.js

A seamless JavaScript code coverage library.

FYI: Please note that this repo is not actively maintained

If you're looking for a more active project for JavaScript code coverage, I recommend Istanbul.

Project home page
Blanket_js on Twitter for updates and news.

NOTE: All Pull-Requests must be made into the master branch.

Build Status Dependency Status devDependency Status

NOTE: Blanket.js will throw XHR cross domain errors if run with the file:// protocol. See Special Features Guide for more details and workarounds.

Getting Started

Please see the following guides for using Blanket.js:

Browser

Node

Configuration

Philosophy

Blanket.js is a code coverage tool for javascript that aims to be:

  1. Easy to install
  2. Easy to use
  3. Easy to understand

Blanket.js can be run seamlessly or can be customized for your needs.

Mechanism

JavaScript code coverage compliments your existing JavaScript tests by adding code coverage statistics (which lines of your source code are covered by your tests).

Blanket works in a 3 step process:

  1. Loading your source files
  2. Parsing the code using Esprima and node-falafel, and instrumenting the file by adding code tracking lines.
  3. Connecting to hooks in the test runner to output the coverage details after the tests have completed.

Grunt Integration

You've got a few options for using Grunt with Blanket:

grunt-blanket

A Grunt plugin has been created to allow you to use Blanket like a "traditional" code coverage tool (creating instrumented copies of physical files, as opposed to live-instrumenting). The plugin runs as a standlone project and can be found here.

grunt-blanket-qunit

Runs the QUnit-based Blanket report headlessly using PhantomJS. Results are displayed on the console, and the task will cause Grunt to fail if any of your configured coverage thresholds are not met. Minimum code coverage thresholds can be configured per-file, per-module, and globally.

See:

Compatibility and Features List

See the Compatiblity and Feature List including links to working examples.

Roll your own

  1. git clone git@github.com:alex-seville/blanket.git
  2. npm install
  3. Add your custom build details to the grunt.js file under concat
  4. npm run build

A minified and unminfied copy of the source can be created (see the min task).

Development

All development takes place on the master branch
Your pull request must pass all tests (run npm test to be sure) and respect all existing coverage thresholds

Contact

Feel free to add questions to the Issue tracker, or send them to @blanket_js.

Contributors

Thanks to the many people who have contributed to the project.

And thanks also to: RequireJS, Esprima, node-falafel, Mocha, Qunit.

Revision History

Feb 18-15 - 1.2.2 PR's merged, but this project is not actively maintained.

May 1-13 - 1.1.4
Loaded reverting for grunt-blanket, branch tracking reporter fixed, coverage on-the-go (displaying coverage results while a single page is being used).

Apr 28-13 - 1.1.3 YUI support added with custom adapter (and some wrapping code). CompoundJS support appears to be outside the scope of project.

... (see full revision history)

License

Copyright (c) 2012-2013 Alex Seville
Licensed under the MIT license.

Origin and compatibility notes

Upstream basis

The initial import is the exact published npm artifact. Browser distribution files are now rebuilt with a small Node.js script, using the same source and adapter ordering as the release-era Grunt configuration. The obsolete Grunt/PhantomJS development toolchain is not needed.

The directive fix addresses #340, confirmed against the published artifact. It preserves actual directive prologues and avoids carrying program-level strictness into the next file. Regression tests execute the generated code and published browser bundles.

The internal falafel helper derives from version 1.2.0, with native array/object helpers replacing old shims. The xtend helper retains the implementation from version 4.0.2. Acorn is updated while the default ecmaVersion: 5 setting remains. Full third-party license text is in THIRD_PARTY_NOTICES.md.

No vulnerability claim is made: the isolated published baseline runtime installation had no npm audit advisories on 2026-09-27. This fork has its own 1.x version series and does not imply upstream endorsement.

Published files and origin

These documents were read from the existing npm 1.0.0 archive. Its SHA-512 matches the current registry integrity value. This documentation update does not publish a new package or establish a new provenance or immutable-release verification.

Archive integrity
sha512-WNqtyPrIxS9KT1JRg2Ngrv0D6vl2bHnIJEnF/MixPNac/krres/FPRt6jfJYzTv9ZCu20YmNxHqF1uzrJdi9/Q==