1.0.2 • Published 8 years ago

cti-checks-aggregator v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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 */
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago