@ima/core
Version:
IMA.js framework for isomorphic javascript application
54 lines (53 loc) • 1.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "AbstractExecution", {
enumerable: true,
get: function() {
return AbstractExecution;
}
});
const _Execution = require("./Execution");
const _GenericError = require("../error/GenericError");
const CLASS_REGEX = /^\s*class\b/;
class AbstractExecution extends _Execution.Execution {
_jobs;
constructor(jobs = []){
super();
this._jobs = jobs.filter(this._validateJob);
}
/**
* @inheritDoc
*/ append(jobs) {
if (!Array.isArray(jobs)) {
jobs = [
jobs
];
}
this._jobs = this._jobs.concat(jobs.filter(this._validateJob));
}
/**
* @inheritDoc
*/ execute(...args) {
throw new _GenericError.GenericError('The ima.core.execution.AbstractExecution.execute method is abstract ' + 'and must be overridden', {
...args
});
}
/**
* Return `true` if the given job can be executed
*/ _validateJob(job) {
if (typeof job === 'function') {
if (!CLASS_REGEX.test(job.toString())) {
return true;
}
}
if ($Debug) {
console.warn('ima.core.execution.AbstractExecution: Given job is not a callable ' + 'function therefore it will be excluded from execution.', {
job
});
}
return false;
}
}
//# sourceMappingURL=AbstractExecution.js.map
;