"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GCPin = void 0;
/**
 * Pins an object, preventing it from being cleaned up by the GC.
 * @internal
 */
class GCPin {
    /**
     * Creates a GCPin object.
     * @param object - the object to pin
     * @internal
     */
    constructor(object) {
        this.object = object;
        // well howdy, i'm sure you're here because you're wondering how we actually GC pin objects in node.
        // since that's not directly possible, we (ab)use an interval with an extremely long window in the
        // hopes that it won't actually ever fire, but instead will keep the captured object alive.
        //
        // If this _does_ fire it should be no big deal as it's a no-op, and runs super infrequently.
        this.id = setInterval(() => {
            object;
        }, 3600000 /* 1h */);
    }
    /**
     * Releases the object
     */
    release() {
        clearInterval(this.id);
        return this.object;
    }
}
exports.GCPin = GCPin;
//# sourceMappingURL=gc-pin.js.map