-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
398 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"printWidth": 120, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { Convert } from "./types/convert"; | ||
import { defaultOptions } from "./utils/defaultOptions"; | ||
import { pdf2picCore } from "./pdf2picCore"; | ||
import { Convert } from './types/convert'; | ||
import { defaultOptions } from './utils/defaultOptions'; | ||
import { pdf2picCore } from './pdf2picCore'; | ||
|
||
export function fromPath(filePath: string, options = defaultOptions): Convert { | ||
return pdf2picCore("path", filePath, options); | ||
return pdf2picCore('path', filePath, options); | ||
} | ||
|
||
export function fromBuffer(buffer: Buffer, options = defaultOptions): Convert { | ||
return pdf2picCore("buffer", buffer, options); | ||
return pdf2picCore('buffer', buffer, options); | ||
} | ||
|
||
export function fromBase64(b64string: string, options = defaultOptions): Convert { | ||
return pdf2picCore("base64", b64string, options); | ||
return pdf2picCore('base64', b64string, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export type Options = { | |
savePath?: string; | ||
saveFilename?: string; | ||
compression?: string; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { ReadStream } from "fs"; | ||
import { bufferToStream } from "../../utils/converters/bufferToStream"; | ||
import { ReadStream } from 'fs'; | ||
import { bufferToStream } from '../../utils/converters/bufferToStream'; | ||
|
||
export function base64ToStream(base64: string): ReadStream { | ||
const buffer = Buffer.from(base64, "base64"); | ||
const buffer = Buffer.from(base64, 'base64'); | ||
|
||
return bufferToStream(buffer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { createReadStream, ReadStream } from "fs"; | ||
import { base64ToStream } from "../../utils/converters/base64ToStream"; | ||
import { bufferToStream } from "../../utils/converters/bufferToStream"; | ||
import { createReadStream, ReadStream } from 'fs'; | ||
import { base64ToStream } from '../../utils/converters/base64ToStream'; | ||
import { bufferToStream } from '../../utils/converters/bufferToStream'; | ||
|
||
export function convertToStream(source: string, file: string | Buffer): ReadStream { | ||
if (source === "buffer") { | ||
if (source === 'buffer') { | ||
return bufferToStream(file as Buffer); | ||
} | ||
|
||
if (source === "path") { | ||
if (source === 'path') { | ||
return createReadStream(file as string); | ||
} | ||
|
||
if (source === "base64") { | ||
if (source === 'base64') { | ||
return base64ToStream(file as string); | ||
} | ||
|
||
throw new Error("Cannot recognize specified source"); | ||
throw new Error('Cannot recognize specified source'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Options } from "../types/options"; | ||
import { Options } from '../types/options'; | ||
|
||
export const defaultOptions: Options = { | ||
quality: 0, | ||
format: "png", | ||
format: 'png', | ||
width: 768, | ||
height: 512, | ||
density: 72, | ||
preserveAspectRatio: false, | ||
savePath: "./", | ||
saveFilename: "untitled", | ||
compression: "jpeg" | ||
savePath: './', | ||
saveFilename: 'untitled', | ||
compression: 'jpeg', | ||
}; |
Oops, something went wrong.