"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var buffer_1 = require("buffer");
var StringConverter = /** @class */ (function () {
    function StringConverter(encoding) {
        if (encoding === void 0) { encoding = "ascii"; }
        this.encoding = encoding;
    }
    StringConverter.prototype.encode = function (value) {
        var buffer = buffer_1.Buffer.from(value, this.encoding);
        return Uint8Array.from(buffer);
    };
    StringConverter.prototype.decode = function (value) {
        return buffer_1.Buffer.from(value).toString(this.encoding);
    };
    /**
     * Get ascii instance
     * @deprecated use constructor instead
     */
    StringConverter.instance = function () {
        return StringConverter.ascii();
    };
    /**
     * Get ascii instance
     * @deprecated use constructor instead
     */
    StringConverter.ascii = function () {
        if (!StringConverter._ascii) {
            StringConverter._ascii = new StringConverter("ascii");
        }
        return StringConverter._ascii;
    };
    return StringConverter;
}());
exports.StringConverter = StringConverter;
