MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / writeFieldBuffered

Function writeFieldBuffered

src/packFileSerializer.ts:2514–2525  ·  view source on GitHub ↗
(file: BinaryFile, schemaFields: SchemaField[])

Source from the content-addressed store, hash-verified

2512};
2513// Optimized buffered version with reduced Promise overhead (kept for compatibility)
2514const writeFieldBuffered = async (file: BinaryFile, schemaFields: SchemaField[]) => {
2515 const accumulator = new BufferAccumulator(file);
2516 // Synchronously serialize all fields to buffers
2517 for (const schemaField of schemaFields) {
2518 const buffer = serializeSchemaFieldToBuffer(schemaField);
2519 accumulator.addBuffer(buffer);
2520 // Flush periodically to avoid memory buildup
2521 await accumulator.flushIfNeeded();
2522 }
2523 // Final flush
2524 await accumulator.flush();
2525};
2526// Original writeField function (kept for compatibility)
2527const writeField = async (file: BinaryFile, schemaField: SchemaField) => {
2528 // Use the buffered approach for single field

Callers 4

writePackAppendFastFunction · 0.85
writePackSortedFunction · 0.85
writePackLegacyFunction · 0.85
writeStartGamePackFunction · 0.85

Calls 4

addBufferMethod · 0.95
flushIfNeededMethod · 0.95
flushMethod · 0.95

Tested by

no test coverage detected