UNPKG

haystack-codegen

Version:

Project Haystack Core code generation tools

28 lines (27 loc) 777 B
"use strict"; /* * Copyright (c) 2021, J2 Innovations. All Rights Reserved */ Object.defineProperty(exports, "__esModule", { value: true }); exports.HaystackCoreImportNode = void 0; /** * Generates the imports from the haystack-core library. */ class HaystackCoreImportNode { types = new Set(); newLines = 1; constructor(types = []) { for (const type of types) { this.types.add(type); } } generateCode(out) { if (this.types.size) { const types = [...this.types.values()]; out('import {'); types.forEach((type) => out(` ${type}${types.length === 1 ? '' : ','}`)); out(`} from 'haystack-core'`); } } } exports.HaystackCoreImportNode = HaystackCoreImportNode;