cti-checks-aggregator
v1.0.2
Published
Library to aggregate results/errors while performing checks
Downloads
2
Maintainers
Readme
cti-checks-aggregator
Library to aggregate results/errors while performing checks
Usage
const ChecksAggregator = require( 'cti-checks-aggregator' );
const Promise = require( 'bluebird' );
const aggregator = new ChecksAggregator();
aggregator.addCheckResult( 'testTopic', 'testCheck1', true );
aggregator.addCheckResult( 'testTopic', 'testCheck2', true );
aggregator.addCheckResult( 'testTopic2', 'testCheck', false, { message: 'something went wrong' } );
const error = new Error( 'something went wrong' );
const operationalError = new Promise.OperationalError( error );
aggregator.addCheckResult( 'testTopic3', 'testCheck', false, operationalError );
console.log( aggregator.results );
/*
{
testTopic: {
testCheck1: true,
testCheck2: true
},
testTopic2: {
testCheck: false,
testCheckError: {
message: 'something went wrong'
}
},
testTopic3: {
testCheck: false,
testCheckError: [Error: something went wrong]
}
}
*/
console.log( aggregator.allSucceeded );
/* false */