"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const react_dom_1 = require("react-dom");
const BatchUpdate = (fn) => {
    let fns = [];
    if (fn) {
        fns.push(fn);
    }
    const didCommit = false;
    const queue = (fn) => {
        fns.push(fn);
    };
    queue.commit = (lastFn) => {
        if (didCommit) {
            return;
        }
        if (lastFn) {
            fns.push(lastFn);
        }
        (0, react_dom_1.unstable_batchedUpdates)(() => {
            fns.forEach((fn) => fn());
            fns = undefined;
        });
    };
    return queue;
};
exports.default = BatchUpdate;
