UNPKG

d3-view

Version:

View-model d3 plugin for building interactive data-driven web interfaces

25 lines (23 loc) • 453 B
export default function Cache() { this.active = true; this.data = new Map(); } Cache.prototype = { constructor: Cache, set(key, value) { if (this.active) this.data.set(key, value); }, get(key) { if (this.active) return this.data.get(key); }, has(key) { if (this.active) return this.data.has(key); return false; }, clear() { return this.data.clear(); }, delete(key) { return this.data.delete(key); } };