"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncV = exports.AsyncVRef = exports.AsyncVWatch = exports.AsyncVCall = exports.AsyncVGet = void 0;
const stringify_1 = require("../../../spec/stringify");
const AsyncVGet = (value) => {
    return {
        async $read({}, callback) {
            let data;
            try {
                data = await value.read();
            }
            catch (err) {
                return callback(undefined, err.message);
            }
            const _data = (0, stringify_1.stringify)(data);
            callback(_data);
        },
    };
};
exports.AsyncVGet = AsyncVGet;
const AsyncVCall = (value) => {
    return {
        async $write({ data }, callback) {
            await value.write(data);
            callback();
        },
    };
};
exports.AsyncVCall = AsyncVCall;
const AsyncVWatch = (value) => {
    return {};
};
exports.AsyncVWatch = AsyncVWatch;
const AsyncVRef = (value) => {
    return {};
};
exports.AsyncVRef = AsyncVRef;
const AsyncV = (value) => {
    return {
        ...(0, exports.AsyncVGet)(value),
        ...(0, exports.AsyncVCall)(value),
        ...(0, exports.AsyncVWatch)(value),
        ...(0, exports.AsyncVRef)(value),
    };
};
exports.AsyncV = AsyncV;
//# sourceMappingURL=AsyncV.js.map