UNPKG

pdf-to-png-converter

Version:

Node.js utility to convert PDF file/buffer pages to PNG files/buffers. No build-time compilation required — pre-built native binaries included for all major platforms.

19 lines (18 loc) 750 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.optionsToPageMode = optionsToPageMode; /** * Pure mapping from normalized options (+ the resolved output sink, if writing to disk) to a * `PageMode`. `sink` is non-undefined exactly when an output folder is in effect; building it * requires filesystem I/O, so the caller constructs it and passes it in to keep this function pure * and table-testable. */ function optionsToPageMode(opts, sink) { if (opts.returnMetadataOnly) { return { kind: 'metadata' }; } if (sink !== undefined) { return { kind: 'file', sink, returnContent: opts.returnPageContent }; } return { kind: 'content', returnContent: opts.returnPageContent }; }