npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

istanbul-traceur

v1.0.7

Published

Provides alternative version of Istanbul which supports Traceur.

Readme

istanbul-traceur

NPM version Build status Coveralls status Support us

Istanbul is a robust code coverage tool, could be run on both Node.js and browsers, provides many report formats (HTML, LCOV, etc.) to have testing and continuous integration done right. But Istanbul could not understand JavaScript of the future (e.g. ECMCScript 6). The next JavaScript provides new language features which help development process goes faster and produces less bugs.

Fortunately, we have Traceur, which is a transpiler (source-to-source compiler) which could convert JavaScript of the future to current JavaScript.

This module is here to help connecting these two awesome thing together. It stands as an alternative to Istanbul, enables you to use Traceur to write applications in modern JavaScript without worrying about code coverage.

Installation

This module can be installed easily with npm:

$ npm install istanbul-traceur

Usage

Directly

main.js:

var fs = require('fs');

var istanbul = require('istanbul-traceur');
var instrumenter = new istanbul.Instrumenter();

var content = fs.readFileSync('es6.js', 'utf8');
var code = instrumenter.instrumentSync(content, '/path/to/file.js');

eval(code);
//=> prints "You have done right!"

es6.js:

import assert from 'assert';

export var isOdd = (n) => {
  return !!(n & 1);
};

assert(isOdd(7), '7 is odd.');
assert(!isOdd(4), '4 is even.');

console.log('You have done right!');

With Gulp

gulpfile.js:

var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');

var istanbulTraceur = require('istanbul-traceur');

gulp.task('test', function (cb) {
  var usedIstanbul = require('gulp-istanbul/node_modules/istanbul');
  var Instrumenter = usedIstanbul.Instrumenter;

  // Overrides `Instrumenter`
  usedIstanbul.Instrumenter = istanbulTraceur.Instrumenter;

  gulp.src([ 'lib/**/*.js' ])
    .pipe(istanbul())
    .on('finish', function () {
      gulp.src([ 'test/**/*.js' ])
        .pipe(mocha())
        .pipe(istanbul.writeReports())
        .on('end', function (err) {
          // Restores original `Instrumenter`
          usedIstanbul.Instrumenter = Instrumenter;
          cb(err);
        });
    });
});

gulp test in Terminal:

gulp test in Terminal

HTML report:

HTML report

With Grunt

Gruntfile.js:

var istanbulTraceur = require('istanbul-traceur');

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-istanbul');

  grunt.initConfig({
    instrument: {
      files: 'lib/**/*.js',
      options: {
        basePath: 'coverage/instrumented',
        lazy: true
      }
    },
    mochaTest: [
      'test/**/*.js'
    ],
    storeCoverage: {
      options: {
        dir: 'coverage/reports'
      }
    },
    makeReport: {
      src: 'coverage/reports/**/*.json',
      options: {
        type: 'lcov',
        dir: 'coverage/reports',
        print: 'detail'
      }
    }
  });

  var usedIstanbul;
  var Instrumenter;

  grunt.registerTask('istanbul:override', function () {
    usedIstanbul = require('grunt-istanbul/node_modules/istanbul');
    Instrumenter = usedIstanbul.Instrumenter;

    // Overrides `Instrumenter`
    usedIstanbul.Instrumenter = istanbulTraceur.Instrumenter;
  });

  grunt.registerTask('istanbul:restore', function () {
    // Restores original `Instrumenter`
    usedIstanbul.Instrumenter = Instrumenter;
  });

  grunt.registerTask('test', [
    'istanbul:override',
    'instrument',
    'mochaTest',
    'storeCoverage',
    'makeReport',
    'istanbul:restore',
  ]);
};

When using with Grunt:

NOTE: Because instrumented copies of your source files lie in different directory, you have to make sure all require methods in your test files pointing to correct source file's locations.

grunt test in Terminal:

grunt test in Terminal

HTML report is also available when using with Grunt.

Command-line usage

This feature is not available at the moment and will be implemented soon. If you want to give a hand, create a pull request.

Compatibility

  • This module has been tested to run properly with Traceur version 0.0.61 (latest version at the time of writing). It could be broken in the future if Traceur introduces non backward-compatible changes. In that circumstance, feel free to create new issue or create a pull request.

Contributing

Before create a pull request, make sure that you:

To execute all tests, simply run:

$ npm test

Contributors

License

This module is released under MIT license.