import { createWriteStream } from "fs" ; import { Writable } from "stream" ; import { PDF_ } from "../pdf/pdf.js" ; import { PDFOptions , Data } from "../shared/types.js" ; export class PDF extends PDF_ { constructor ( data , outputPath , options ? ) ; constructor ( data , writableStream , options ? ) ; constructor ( data , outputPath , options ? , callback ? ) ; constructor ( data , writableStream , options ? , callback ? ) ; constructor ( data , outputPath , callback ? ) ; constructor ( data , writableStream , callback ? ) ; constructor ( data , outputPathOrWritableStream , optionsOrCallback ? , callbackOrUndefined ? ) { let callback = undefined ; let options = undefined ; if ( typeof optionsOrCallback === "object" ) { options = optionsOrCallback ; if ( typeof callbackOrUndefined === "function" ) { callback = callbackOrUndefined ; } } else if ( typeof optionsOrCallback === "function" ) { callback = optionsOrCallback ; } super ( data , options ) ; let stream ; if ( typeof outputPathOrWritableStream === "string" ) { stream = createWriteStream ( outputPathOrWritableStream ) ; } else { stream = outputPathOrWritableStream ; } super . pipe ( stream ) ; stream . on ( "finish" , ev => { if ( typeof callback === "function" ) { callback ( this ) ; } this . emit ( "finish" , ev ) ; } ) ; } }