Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / istanbul / lib / store / memory.js
1 /*
2  Copyright (c) 2012, Yahoo! Inc.  All rights reserved.
3  Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
4  */
5
6 var util = require('util'),
7     Store = require('./index');
8
9 /**
10  * a `Store` implementation using an in-memory object.
11  *
12  * Usage
13  * -----
14  *
15  *      var store = require('istanbul').Store.create('memory');
16  *
17  *
18  * @class MemoryStore
19  * @extends Store
20  * @module store
21  * @constructor
22  */
23 function MemoryStore() {
24     Store.call(this);
25     this.map = {};
26 }
27
28 MemoryStore.TYPE = 'memory';
29 util.inherits(MemoryStore, Store);
30
31 Store.mix(MemoryStore, {
32     set: function (key, contents) {
33         this.map[key] = contents;
34     },
35
36     get: function (key) {
37         if (!this.hasKey(key)) {
38             throw new Error('Unable to find entry for [' + key + ']');
39         }
40         return this.map[key];
41     },
42
43     hasKey: function (key) {
44         return this.map.hasOwnProperty(key);
45     },
46
47     keys: function () {
48         return Object.keys(this.map);
49     },
50
51     dispose: function () {
52         this.map = {};
53     }
54 });
55
56 module.exports = MemoryStore;