"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchPinEvent = watchPinEvent;
const stringify_1 = require("../spec/stringify");
function watchPinEvent(event, type, pinId, pin, callback) {
    // console.log(event, type, pin)
    const listener = (data) => {
        if (data !== undefined) {
            data = (0, stringify_1.stringify)(data, true);
        }
        callback({
            type,
            event,
            data: {
                type,
                pinId,
                data,
            },
        });
    };
    pin.prependListener(event, listener);
    return () => {
        pin.removeListener(event, listener);
    };
}
//# sourceMappingURL=watchPinEvent.js.map