UNPKG

@forzalabs/remora

Version:

A powerful CLI tool for seamless data translation.

35 lines (34 loc) 1.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Affirm_1 = __importDefault(require("../../core/Affirm")); const Environment_1 = __importDefault(require("../Environment")); class FileContentBuilderClass { constructor() { /** * Converts an array of string to a single string separated with the separator. * In the V8 engine there is a maximum length to a string so I can't just join it all. * I use this to create chunks that are not too long. */ this.compose = (lines, separator) => { Affirm_1.default.hasValue(lines, 'Invalid lines'); Affirm_1.default.hasValue(lines, 'Invalid separator'); const maxStringLength = parseInt(Environment_1.default.get('STRING_MAX_CHARACTERS_LENGTH')); const chunks = []; let currentChunk = ''; for (const line of lines) { currentChunk += (line + separator); if (currentChunk.length >= maxStringLength) { chunks.push(currentChunk); currentChunk = ''; } } chunks.push(currentChunk); return chunks; }; } } const FileContentBuilder = new FileContentBuilderClass(); exports.default = FileContentBuilder;