UNPKG

833 BJavaScriptView Raw
1// Source Cache Store
2// ==================
3//
4// Used by lib/reporter
5
6// Dependencies
7// ------------
8
9var util = require('util')
10var Store = require('istanbul').Store
11
12// Constructor
13var SourceCacheStore = module.exports = function (opts) {
14 Store.call(this, opts)
15 opts = opts || {}
16 this.sourceCache = opts.sourceCache
17}
18
19// Class Constants
20// ---------------
21SourceCacheStore.TYPE = 'sourceCacheLookup'
22
23// Inherits from an Istanbul.Store
24util.inherits(SourceCacheStore, Store)
25
26// Implement needed methods
27Store.mix(SourceCacheStore, {
28 keys: function () {
29 throw new Error('Not implemented')
30 },
31 get: function (key) {
32 return this.sourceCache[key]
33 },
34 hasKey: function (key) {
35 return this.sourceCache.hasOwnProperty(key)
36 },
37 set: function (key, contents) {
38 throw new Error('Not applicable')
39 }
40})