Skip to content

Commit

Permalink
chore: code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Jan 27, 2024
1 parent 4904ccd commit a9f9113
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion PDFMergerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class PDFMergerBase {
// see https://developer.mozilla.org/en-US/docs/Web/API/URL
if (input instanceof URL) {
if (typeof fetch === 'undefined') {
throw new Error('fetch is not defined. You need to use a polyfill for this to work in Node.js.')
throw new Error('fetch is not defined. You need to use a polyfill for this to work.')
}
const res = await fetch(input)
const aBuffer = await res.arrayBuffer()
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This node.js library can **merge multiple PDF documents**, or parts of them, to

## Legacy notes

* If you are searching for the legacy version based on
[pdfjs](https://www.npmjs.com/package/pdfjs) please install a [v3 release](https://github.com/nbesli/pdf-merger-js/releases?q=v3&expanded=true). Since [v4](https://github.com/nbesli/pdf-merger-js/releases?q=v4&expanded=true) we use [pdf-lib](https://pdf-lib.js.org/) instead.
* If you are searching for the legacy version based on [pdfjs](https://www.npmjs.com/package/pdfjs) please install a [v3 release](https://github.com/nbesli/pdf-merger-js/releases?q=v3&expanded=true). Since [v4](https://github.com/nbesli/pdf-merger-js/releases?q=v4&expanded=true) we use [pdf-lib](https://pdf-lib.js.org/) instead.
* If you are searching for a legacy version using CommonJS modules please install a [v4 release](https://github.com/nbesli/pdf-merger-js/releases?q=v4&expanded=true). Since [v5](https://github.com/nbesli/pdf-merger-js/releases?q=v5&expanded=true) we use the modern ESM ("import") instead of the CommonJS ("require) module standard.

This library is inspired by the [PHP library PDFMerger](https://github.com/myokyawhtun/PDFMerger) and has a very similar API.
Expand All @@ -14,15 +13,15 @@ This library is inspired by the [PHP library PDFMerger](https://github.com/myoky

`npm install --save pdf-merger-js`

of global installation if you want to use the cli tool:
or global installation if you just want to use the cli tool:

`npm install -g pdf-merger-js`

## Usage

### CLI

```
```txt
Options:
-V, --version output the version number
-o, --output <outputFile> Merged PDF output file path
Expand Down
4 changes: 2 additions & 2 deletions test/PDFMerger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ describe('PDFMerger', () => {
const testIfFetch = typeof fetch !== 'undefined' ? test : test.skip
testIfFetch('provide input as URL', async () => {
const merger = new PDFMerger()
const TestfileAURL = new URL('https://raw.githubusercontent.com/nbesli/pdf-merger-js/master/test/fixtures/Testfile_A.pdf')
const TestfileAURL = new URL('https://github.com/nbesli/pdf-merger-js/raw/master/test/fixtures/Testfile_A.pdf')
expect(TestfileAURL).toBeInstanceOf(URL)
await merger.add(TestfileAURL)
const TestfileBURL = new URL('https://raw.githubusercontent.com/nbesli/pdf-merger-js/master/test/fixtures/Testfile_B.pdf')
const TestfileBURL = new URL('https://github.com/nbesli/pdf-merger-js/raw/master/test/fixtures/Testfile_B.pdf')
expect(TestfileBURL).toBeInstanceOf(URL)
await merger.add(TestfileBURL)
const diff = await pdfDiff(
Expand Down

0 comments on commit a9f9113

Please sign in to comment.