@rpidanny/pdf2md
Version:
A PDF to Markdown Converter
31 lines (26 loc) • 1.03 kB
JavaScript
// @flow
/*::
import ParseResult from '../../ParseResult'
*/
// A transformation from an PdfPage to an PdfPage
module.exports = class Transformation {
constructor (name, itemType) {
if (this.constructor === Transformation) {
throw new TypeError('Can not construct abstract class.')
}
if (this.transform === Transformation.prototype.transform) {
throw new TypeError("Please implement abstract method 'transform()'.")
}
this.name = name
this.itemType = itemType
}
// Transform an incoming ParseResult into an outgoing ParseResult
transform (parseResult /*: ParseResult */) /*: ParseResult */ { // eslint-disable-line no-unused-vars
throw new TypeError('Do not call abstract method foo from child.')
}
// Sometimes the transform() does only visualize a change. This methods then does the actual change.
completeTransform (parseResult /*: ParseResult */) /*: ParseResult */ { // eslint-disable-line no-unused-vars
parseResult.messages = []
return parseResult
}
}