var self = this, globals = ["document", "window", "navigator", "CSSStyleDeclaration", "d3"], globalValues = {}; globals.forEach(function(global) { if (global in self) globalValues[global] = self[global]; }); document = require("jsdom").jsdom(""); window = document.createWindow(); navigator = window.navigator; CSSStyleDeclaration = window.CSSStyleDeclaration; require("./d3.v2"); module.exports = d3; globals.forEach(function(global) { if (global in globalValues) self[global] = globalValues[global]; else delete self[global]; });