UNPKG

docutils-ts

Version:

Port of the Python Docutils library to TypeScript

14 lines (13 loc) 786 B
import Reporter from './reporter.js'; import { ApplicationError } from './exceptions.js'; export default function newReporter(labeled, settings) { const keys = ['reportLevel', 'haltLevel', //'warningStream', 'debug', 'errorEncoding', 'errorEncodingErrorHandler']; const core = settings || {}; const missingKeys = keys.filter((key) => !Object.prototype.hasOwnProperty.call(core, key)); if (missingKeys.length) { throw new ApplicationError(`Missing required keys from settings object to instantiate reporter. Missing keys ${missingKeys.map((key) => `"${key}"`).join(', ')}.`); } return new Reporter(labeled.sourcePath, core.reportLevel, core.haltLevel, core.warningStream, core.debug, core.errorEncoding, core.errorEncodingErrorHandler); }