@royalschedule/input-analyzer
v3.0.6
Published
A script that analyzes the json input to be processed by the scheduling algorithm.
Downloads
267
Readme
Input analyzer
A script that analyzes the json input to be processed by the scheduling algorithm.
Installation
npm i -S @royalschedule/input-analyzer
Usage
import { Analyzer } from '@royalschedule/input-analyzer';
// Analyze the json input
let analyzer = new Analyzer({ ... });
// The analyzer first verifies the input using the input-verifier npm
// package (@royalschedule/input-verifier) since it may encounter
// critical errors making the analysis impossible
if (analyzer.errors.length) {
throw `The analyzer ran into ${analyzer.errors.length} error(s).`;
}
// The analyzer has information about areas, dependencies, etc.
console.log(`No. areas: ${analyzer.areas.size} `);
console.log(`No. dependencies: ${analyzer.dependencies.size}`);
console.log(`No. groups: ${analyzer.groups.size} `);
console.log(`No. collections: ${analyzer.collections.size} `);
console.log(`No. events: ${analyzer.events.length} `);
// We can for example check how many events are guaranteed to overlap
// (this method merely returns a lower bound)
const overlaps = analyzer.computeOverlaps();
console.log(`${overlaps.length} event(s) are guaranteed to overlap.`);