Skip to content

Commit

Permalink
fix: Blob might be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Jan 27, 2024
1 parent 42b0302 commit fb50319
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 113 deletions.
2 changes: 1 addition & 1 deletion PDFMergerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class PDFMergerBase {
}

// see https://developer.mozilla.org/en-US/docs/Web/API/Blob
if (input instanceof Blob) {
if (Blob && input instanceof Blob) {
const aBuffer = await input.arrayBuffer()
return new Uint8Array(aBuffer)
}
Expand Down
109 changes: 0 additions & 109 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"pdf-lib": "^1.17.1"
},
"devDependencies": {
"cross-blob": "^3.0.2",
"fs-extra": "^11.2.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Expand Down
4 changes: 2 additions & 2 deletions test/PDFMerger.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from 'path'

import fs from 'fs-extra'
import Blob from 'cross-blob'
import pdfDiff from 'pdf-diff'
import { PDFDocument } from 'pdf-lib'
import { jest } from '@jest/globals'
Expand Down Expand Up @@ -103,7 +102,8 @@ describe('PDFMerger', () => {
expect(diff).toBeFalsy()
})

test('provide input as Blob', async () => {
const testIfBlob = typeof Blob !== 'undefined' ? test : test.skip
testIfBlob('provide input as Blob', async () => {
const merger = new PDFMerger()
const TestfileAUint8Array = await fs.readFile(path.join(FIXTURES_DIR, 'Testfile_A.pdf'))
const TestfileABlob = new Blob([TestfileAUint8Array])
Expand Down

0 comments on commit fb50319

Please sign in to comment.