feat(Convert to File Node): Operation to convert a string in a plain text file, option to format JSON when creating file (#8620)

This commit is contained in:
Michael Kret
2024-02-13 16:52:37 +02:00
committed by GitHub
parent e597fbc78f
commit d18cba37a4
7 changed files with 530 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ export type JsonToBinaryOptions = {
mimeType?: string;
dataIsBase64?: boolean;
itemIndex?: number;
format?: boolean;
};
type PdfDocument = Awaited<ReturnType<Awaited<typeof readPDF>>['promise']>;
@@ -102,7 +103,11 @@ export async function createBinaryFromJson(
if (typeof value === 'object') {
options.mimeType = 'application/json';
valueAsString = JSON.stringify(value);
if (options.format) {
valueAsString = JSON.stringify(value, null, 2);
} else {
valueAsString = JSON.stringify(value);
}
}
buffer = iconv.encode(valueAsString, options.encoding || 'utf8', {