mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
24 lines
440 B
JavaScript
24 lines
440 B
JavaScript
|
"use strict";
|
||
|
|
||
|
class ChunkCache
|
||
|
{
|
||
|
constructor()
|
||
|
{
|
||
|
this.cache = new Map();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Adds the given chunk to the chunk cache.
|
||
|
* @param {Chunk} chunkData The chunk to add to the cache.
|
||
|
*/
|
||
|
add(chunkData)
|
||
|
{
|
||
|
if(this.cache.contains(chunkData.chunkRef.toString()))
|
||
|
throw new Error("Error: We already have a chunk at that location stored.");
|
||
|
|
||
|
this.cache.set(chunkData.toString(), chunkData);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default ChunkCache;
|