Skip to content

Commit

Permalink
simplify cover variable naming (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored and bcoe committed Sep 13, 2016
1 parent 0b20bcc commit 887a5fe
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ const SOURCE_MAP_RE = /[#@]\s*sourceMappingURL=(.*)\s*$/m;

// generate a variable name from hashing the supplied file path
function genVar(filename) {
var hash = createHash(SHA),
suffix;
var hash = createHash(SHA);
hash.update(filename);
suffix = hash.digest('base64');
//trim trailing equal signs, turn identifier unsafe chars to safe ones + => _ and / => $
suffix = suffix.replace(new RegExp('=', 'g'), '')
.replace(new RegExp('\\+', 'g'), '_')
.replace(new RegExp('/', 'g'), '$');
return '__cov_' + suffix;
return 'cov_' + parseInt(hash.digest('hex').substr(0, 12), 16).toString(36);
}

// VisitState holds the state of the visitor, provides helper functions
Expand Down

0 comments on commit 887a5fe

Please sign in to comment.