"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Returns handler object to wrap `addFunction` and `removeFunction`
 */
const getFnPtrHandler = ({ addFunction, removeFunction }) => {
    let count = 0;
    return {
        add: (fn) => {
            if (count === 20) {
                throw new Error('Maximum number of function pointer added');
            }
            count++;
            return addFunction(fn);
        },
        remove: (fnPtr) => {
            if (count > 0) {
                count--;
                removeFunction(fnPtr);
            }
        }
    };
};
exports.getFnPtrHandler = getFnPtrHandler;
//# sourceMappingURL=fnPtrHandler.js.map