How to use the code-block-writer.default function in code-block-writer

To help you get started, we’ve selected a few code-block-writer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsherret / server-bridge / dist / code-generator / get-code-from-classes.js View on Github external
function getCodeFromClasses(options) {
    var importWriter = new code_block_writer_1.default();
    var writer = new code_block_writer_1.default();
    var types = new types_dictionary_1.TypesDictionary();
    var libraryName = options.libraryName, classes = options.classes, importMapping = options.importMapping;
    classes.forEach(function (c, classIndex) {
        if (classIndex > 0) {
            writer.newLine();
        }
        var classWriter = new class_writer_1.ClassWriter(c, types, options.classMapping[c.name] || c.name);
        classWriter.writeToWriter(writer);
    });
    importWriter.writeLine("import {" + CLIENT_BASE_NAME + "} from \"" + libraryName + "\";");
    Object.keys(types.getTypes()).forEach(function (typeName) {
        if (typeName === CLIENT_BASE_NAME) {
            throw new Error("Having a type with the name ClientBase is currently not supported. Please use a different type name.");
        }
        else if (importMapping[typeName] == null) {
github dsherret / server-bridge / dist / code-generator / get-code-from-classes.js View on Github external
function getCodeFromClasses(options) {
    var importWriter = new code_block_writer_1.default();
    var writer = new code_block_writer_1.default();
    var types = new types_dictionary_1.TypesDictionary();
    var libraryName = options.libraryName, classes = options.classes, importMapping = options.importMapping;
    classes.forEach(function (c, classIndex) {
        if (classIndex > 0) {
            writer.newLine();
        }
        var classWriter = new class_writer_1.ClassWriter(c, types, options.classMapping[c.name] || c.name);
        classWriter.writeToWriter(writer);
    });
    importWriter.writeLine("import {" + CLIENT_BASE_NAME + "} from \"" + libraryName + "\";");
    Object.keys(types.getTypes()).forEach(function (typeName) {
        if (typeName === CLIENT_BASE_NAME) {
            throw new Error("Having a type with the name ClientBase is currently not supported. Please use a different type name.");
        }
        else if (importMapping[typeName] == null) {
            throw new Error("An import mapping needs to be specified on the options parameter for '" + typeName + "' when calling getGeneratedCode()");

code-block-writer

A simple code writer that assists with formatting and visualizing blocks of code.

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis

Popular code-block-writer functions