Codeship Status for albertyw/varsnap.js

Python Varsnap Client. For use in both browser and node.js


Install from NPM - npm install --save varsnap


The varsnap decorator needs to be configured with a config object with these variables:

  • varsnap - Should be either true or false. Varsnap will be disabled if the variable is anything other than true.
  • env - If set to development, the client will receive events from production. If set to production, the client will emit events.
  • producerToken - Only clients with this token may emit production snapshots. Copied from
  • consumerToken - Only clients with this token may emit development snapshots. Copied from

If you’re deploying varsnap to a browser, note that Varsnap needs unmangled code in production to work correctly.


Wrap your functions with the varsnap decorator for any function you’d like to make better:

// Node.js
var varsnap = require('varsnap');

// Browser
var varsnap = window.varsnap;

// Configuration
varsnap.config = {
  varsnap: 'true',
  env: 'production',
  producerToken: 'producer-abcd'

// Integration
function example(x, y, z) {
  // ...
example = varsnap(example);

example(1, 2, 3);

See example/example.js for example usage.


Import and call the included Varsnap mocha test case. (You must run the script with mocha instead of node):

var varsnap = require('varsnap');

// Load the modules where varsnap is being used
// Assume that Varsnap config is set in here, otherwise see the configuration
// options above

// If you have your own test suite that you'd like to integrate with, run tests
// and get a boolean back as the result
const testsSucceed = await varsnap.runTests();

// Set up the mocha test case (if you're using the mocha test framework)

See example/test.js for example usage.


  1. Update Changelog with new version
  2. Update const version in core.js
  3. Update package.json version and run npm install
  4. Update .uglify.json and .uglify.min.json
  5. Run npm run package
  6. Git commit and tag
  7. npm publish
  8. Upload dist/* to