@atomist/automation-client
Version:
Atomist API for software low-level client
65 lines • 1.95 kB
JavaScript
;
/*
* Copyright © 2018 Atomist, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/** Test if an object is an ActionResult */
function isActionResult(a) {
return a.target !== undefined && a.success !== undefined;
}
exports.isActionResult = isActionResult;
/**
* @deprecated
* Convenient implementation of ActionResult
*/
class SimpleActionResult {
constructor(target, success) {
this.target = target;
this.success = success;
}
}
exports.SimpleActionResult = SimpleActionResult;
/**
* Helper to create a successful ActionResult object.
*
* @param t Target for action
* @return {ActionResult<T>} with success: true
*/
function successOn(t) {
return {
success: true,
target: t,
};
}
exports.successOn = successOn;
/**
* Helper to create a failed ActionResult object.
*
* @param t Target for action
* @param err Error that occurred.
* @param f Function that failed, should have a name property.
* @return {ActionResult<T>} with success: true
*/
function failureOn(t, err, f /* function */) {
return {
success: false,
target: t,
error: err,
errorStep: (f && f.name) ? f.name : undefined,
};
}
exports.failureOn = failureOn;
//# sourceMappingURL=ActionResult.js.map