A functional toolkit for authoring resource-leveling algorithms — compose constraint and scoring blocks, enumerate feasible schedules
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor(xlsx): keep writeWithGantt's public signature stable

The SheetSpec work had grown writeWithGantt a 4th optional parameter,
leaking composition plumbing into a pre-existing public method. The
shared body moves to a private composeGanttWorkbook that both
writeWithGantt and writeWithGanttAndSheets delegate to, and the
buffer-wrapping repeated across write/writeSheets/the empty-gantt path
collapses into one toBuffer helper.

Russ T. Fugal (Jun 12, 2026, 3:25 AM -0600) 7e85b546 021796b3

+16 -8
+16 -8
src/xlsx/XlsxWriter.ts
··· 126 126 127 127 export class XlsxWriter { 128 128 async write(project: ProjectFile, options?: XlsxWriterOptions): Promise<Uint8Array> { 129 - const workbook = this.buildWorkbook(project, options); 130 - const buffer = await workbook.xlsx.writeBuffer(); 131 - return new Uint8Array(buffer); 129 + return toBuffer(this.buildWorkbook(project, options)); 132 130 } 133 131 134 132 /** ··· 137 135 * transparent offset; series 2 is the visible duration, colored per phase. 138 136 */ 139 137 async writeWithGantt( 138 + project: ProjectFile, 139 + gantt: GanttSpec, 140 + options?: XlsxWriterOptions, 141 + ): Promise<Uint8Array> { 142 + return this.composeGanttWorkbook(project, gantt, options); 143 + } 144 + 145 + private async composeGanttWorkbook( 140 146 project: ProjectFile, 141 147 gantt: GanttSpec, 142 148 options?: XlsxWriterOptions, ··· 152 158 if (flat.length === 0) { 153 159 const workbook = this.buildWorkbook(project, options); 154 160 if (specSheets) addSpecSheets(workbook, specSheets); 155 - const buffer = await workbook.xlsx.writeBuffer(); 156 - return new Uint8Array(buffer); 161 + return toBuffer(workbook); 157 162 } 158 163 159 164 flat.sort((a, b) => { ··· 213 218 async writeSheets(sheets: SheetSpec[]): Promise<Uint8Array> { 214 219 const workbook = new ExcelJS.Workbook(); 215 220 addSpecSheets(workbook, sheets); 216 - const buffer = await workbook.xlsx.writeBuffer(); 217 - return new Uint8Array(buffer); 221 + return toBuffer(workbook); 218 222 } 219 223 220 224 /** ··· 228 232 sheets: SheetSpec[], 229 233 options?: XlsxWriterOptions, 230 234 ): Promise<Uint8Array> { 231 - return this.writeWithGantt(project, gantt, options, sheets); 235 + return this.composeGanttWorkbook(project, gantt, options, sheets); 232 236 } 233 237 234 238 private buildWorkbook(project: ProjectFile, options?: XlsxWriterOptions): ExcelJS.Workbook { ··· 301 305 302 306 return workbook; 303 307 } 308 + } 309 + 310 + async function toBuffer(workbook: ExcelJS.Workbook): Promise<Uint8Array> { 311 + return new Uint8Array(await workbook.xlsx.writeBuffer()); 304 312 } 305 313 306 314 function applyCellStyle(cell: ExcelJS.Cell, style: CellStyle): void {