all files / dist/writers/ ParameterWithDestructuringWriter.js

100% Statements 36/36
100% Branches 2/2
100% Functions 11/11
100% Lines 36/36
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  13× 13× 13× 13×                            
"use strict";
var ParameterWithDestructuringWriter = (function () {
    function ParameterWithDestructuringWriter(writer, baseDefinitionWriter, defaultExpressionedWriter, typeWriter) {
        this.writer = writer;
        this.baseDefinitionWriter = baseDefinitionWriter;
        this.defaultExpressionedWriter = defaultExpressionedWriter;
        this.typeWriter = typeWriter;
    }
    ParameterWithDestructuringWriter.prototype.write = function (param, flags) {
        var _this = this;
        this.baseDefinitionWriter.writeWrap(param, function () {
            _this.writeLeftSide(param, flags);
            _this.writer.write(": ");
            _this.writeRightSide(param);
        });
    };
    ParameterWithDestructuringWriter.prototype.writeLeftSide = function (param, flags) {
        var _this = this;
        this.surroundInBrances(function () {
            param.destructuringProperties.forEach(function (p, i) {
                _this.writer.conditionalWrite(i > 0, ", ");
                _this.writer.write(p.name);
                if (_this.defaultExpressionedWriter.getShouldWriteDefaultExpression(p, flags))
                    _this.defaultExpressionedWriter.writeWithEqualsSign(p, flags);
            });
        });
    };
    ParameterWithDestructuringWriter.prototype.writeRightSide = function (param) {
        var _this = this;
        this.surroundInBrances(function () {
            param.destructuringProperties.forEach(function (p, i) {
                _this.writer.conditionalWrite(i > 0, " ");
                _this.writer.conditionalWrite(p.isReadonly, "readonly ");
                _this.writer.write(p.name);
                _this.writer.conditionalWrite(p.isOptional, "?");
                _this.typeWriter.writeWithColon(p.type, "any");
                _this.writer.write(";");
            });
        });
    };
    ParameterWithDestructuringWriter.prototype.surroundInBrances = function (func) {
        this.writer.write("{ ");
        func();
        this.writer.write(" }");
    };
    return ParameterWithDestructuringWriter;
}());
exports.ParameterWithDestructuringWriter = ParameterWithDestructuringWriter;
 
//# sourceMappingURL=ParameterWithDestructuringWriter.js.map