class State {
    constructor() {
        this.states = new Map();
    }

    get(key) {
        if (!this.states.has(key)) {
            return null;
        }
        return this.states.get(key);
    }

    set(key, value) {
        return this.states.set(key, value);
    }

    serialize() {
        const entries = this.states.entries();
        const entrymap = [];
        for (let state of entries) {
            entrymap.push(state);
        }
        return entrymap;
    }

    deserialize(data) {
        this.states = new Map(data);
    }
}

export default new State();