const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-';
const charactersLength = characters.length;
const makeId = (length) => {
    let result = '';
    for (let i = 0; i < length; i += 1) {
        result += characters.charAt(Math.floor(Math.random() * charactersLength));
    }
    return result;
};
export default class NodeRegistry {
    constructor() {
        this.idLength = 4;
        this.registry = {};
    }
    generateId() {
        let id = makeId(this.idLength);
        let count = 0;
        while (this.registry[id]) {
            count += 1;
            if (count > 10) {
                this.idLength += 1;
            }
            id = makeId(this.idLength);
        }
        return id;
    }
    set(id, node) {
        this.registry[id] = node;
    }
    get(id) {
        return this.registry[id];
    }
}
//# sourceMappingURL=NodeRegistry.js.map