@contract-case/case-plugin-base
Version:
Plugin framework for writing plugins for the ContractCase test framework
59 lines • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasNoErrors = exports.hasErrors = exports.makeNoErrorResult = exports.makeResults = exports.combineResults = exports.combineResultPromises = void 0;
/**
* Combines multiple {@link MatchResult} objects / Promises containing match results.
* @public
*
* @param results - MatchResult or `Promise<MatchResult>` objects
* @returns a Promise containing the combined Match Results.
*/
const combineResultPromises = async (...results) => (await Promise.all(results.map((r) => Promise.resolve(r)))).flat();
exports.combineResultPromises = combineResultPromises;
/**
* Combines multiple {@link MatchResult} objects into one match result object
* @public
*
* @deprecated Prefer {@link combineResultPromises}
*
* @param results - MatchResult or `Promise<MatchResult>` objects
* @returns combined Match Results.
*/
const combineResults = (...results) => results.flat();
exports.combineResults = combineResults;
/**
* Makes a {@link MatchResult} object.
* @public
*
* @param err - any {@link CaseError} objects. If none supplied, then it makes a passing {@link MatchResult} object
* @returns a {@link MatchResult} object.
*/
const makeResults = (...err) => [...err];
exports.makeResults = makeResults;
/**
* Makes a passing {@link MatchResult} object.
* @public
*
* @returns a {@link MatchResult} object that has no errors.
*/
const makeNoErrorResult = () => [];
exports.makeNoErrorResult = makeNoErrorResult;
/**
* Tests whether a given {@link MatchResult} object has any errors.
* @public
*
* @param result - a {@link MatchResult} object
* @returns true if `result` has any errors
*/
const hasErrors = (result) => result.length !== 0;
exports.hasErrors = hasErrors;
/**
* Tests whether a given {@link MatchResult} object has no errors.
* @public
*
* @param result - a {@link MatchResult} object
* @returns true if `result` has no errors (ie, is a passing {@link MatchResult})
*/
const hasNoErrors = (result) => !(0, exports.hasErrors)(result);
exports.hasNoErrors = hasNoErrors;
//# sourceMappingURL=results.js.map