forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseCache.js
More file actions
54 lines (39 loc) · 981 Bytes
/
Copy pathBaseCache.js
File metadata and controls
54 lines (39 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var Class = require('../utils/Class');
var EventDispatcher = require('../events/EventDispatcher');
var Events = require('./events');
// Phaser.Cache.BaseCache
var BaseCache = new Class({
initialize:
function BaseCache ()
{
this.entries = new Map();
this.events = new EventDispatcher();
},
add: function (key, data)
{
this.entries.set(key, data);
this.events.dispatch(new Events.CACHE_ADD_EVENT(this, key, data));
},
has: function (key)
{
return this.entries.has(key);
},
get: function (key)
{
return this.entries.get(key);
},
remove: function (key)
{
var entry = this.get(key);
if (entry)
{
this.entries.delete(key);
this.events.dispatch(new Events.CACHE_REMOVE_EVENT(this, key, entry.data));
}
},
destroy: function ()
{
this.entries.clear();
}
});
module.exports = BaseCache;