UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

33 lines (32 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InjectPreprocessParameterPlugin = void 0; const tslib_1 = require("tslib"); class InjectPreprocessParameterPlugin { constructor(parameter, type, step) { this.name = 'InjectPreprocessParameterPlugin'; this.type = type; this.parameter = parameter; this.step = step; } preProcess(item, _meta) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.step === 'preProcess' ? this.inject(item) : item; }); } postProcess(item, _meta) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.step === 'postProcess' ? this.inject(item) : item; }); } processError(error, _meta) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.step === 'processError' ? this.inject(error) : error; }); } inject(item) { const updatedItem = Object.assign(Object.assign({}, item), this.parameter); return updatedItem; } } exports.InjectPreprocessParameterPlugin = InjectPreprocessParameterPlugin;