Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init() {
const {
context,
logger,
retryData = [],
operationFn: op,
opConfig,
executionConfig: exConfig
} = this;
const oldStyle = (op.newReader !== undefined || op.newProcessor !== undefined);
if (!this._hasInit) {
if (oldStyle) {
if (this.isProcessor) {
const { Processor } = processorShim(op);
this.operation = new Processor(context, opConfig, exConfig);
} else {
const { Fetcher, Slicer } = readerShim(op);
if (this.isReader) this.operation = new Fetcher(context, opConfig, exConfig);
if (this.isSlicer) this.operation = new Slicer(context, opConfig, exConfig);
}
if (logger) this.operation.logger = logger;
await this.operation.initialize(retryData);
} else {
let newOp;
if (op.Processor) newOp = new op.Processor(context, opConfig, exConfig);
if (op.Fetcher) newOp = new op.Fetcher(context, opConfig, exConfig);
if (op.Slicer) newOp = new op.Slicer(context, opConfig, exConfig);
this.operation = newOp;
if (logger) this.operation.logger = logger;