Skip to content

Commit

Permalink
Merge pull request #1618 from DavidSouther/feat/clean-deps/memoizee
Browse files Browse the repository at this point in the history
feat(reporter): Replace memoizee library with a trivial solution.
  • Loading branch information
zzo committed Oct 12, 2015
2 parents 3ca7d2f + 58340b1 commit 297eef6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var log = require('./logger').create('reporter')
var MultiReporter = require('./reporters/multi')
var baseReporterDecoratorFactory = require('./reporters/base').decoratorFactory
var SourceMapConsumer = require('source-map').SourceMapConsumer
var memoizeWeak = require('memoizee/weak')

var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {
var lastServedFiles = []
Expand All @@ -29,9 +28,15 @@ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {
'(\\:(\\d+))?' + // column
'', 'g')

var getSourceMapConsumer = memoizeWeak(function (sourceMap) {
return new SourceMapConsumer(sourceMap)
})
var getSourceMapConsumer = (function () {
var cache = {}
return function (sourceMap) {
if (!(sourceMap in cache)) {
cache[sourceMap] = new SourceMapConsumer(sourceMap)
}
return cache[sourceMap]
}
}())

return function (msg, indentation) {
// remove domain and timestamp from source files
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
"http-proxy": "^1.11.1",
"lodash": "^3.8.0",
"log4js": "^0.6.25",
"memoizee": "^0.3.8",
"mime": "^1.3.4",
"minimatch": "^2.0.7",
"optimist": "^0.6.1",
Expand Down

0 comments on commit 297eef6

Please sign in to comment.