Skip to content

Commit

Permalink
refactor: don't use buffer consumer api
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Oct 21, 2023
1 parent 7a66e1b commit 7f162df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/utils/pdf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { mkdir, writeFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { buffer } from "node:stream/consumers";

import PDFDocument from "pdfkit";

Expand Down Expand Up @@ -29,9 +28,16 @@ export class TestDocument extends PDFDocument {
}

public snapshot = new Promise<string>(async resolve => {
const chunks = await buffer(this);

const snapshot = chunks
const chunks: Buffer[] = [];
for await (const chunk of this){
if(Buffer.isBuffer(chunk)){
chunks.push(chunk);
}
}
const data = Buffer.concat(chunks);

const snapshot = data
.toString("hex")
.replace(ID_REGEX, "");

Expand Down

0 comments on commit 7f162df

Please sign in to comment.