0.1.3 • Published 7 years ago
gtop-parser v0.1.3
NodeJS GTOP Parser
A streaming nodejs GTOP parser, which validates every message against the JSON schema. Currently up to GTOP spec draft 01/
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
The GTOP parser assumes a NodeJS environment. So go ahead and make sure you've got that setup, as well as yarn.
Installing
Add GTOP parser as a dependency:
$ yarn add gtop-parser
Cool. Now, use it:
const Parser = require('gtop-parser');
const gtopParser = new Parser();
gtopParser.on('testStarted', testStarted => {
console.log(testStarted);
})
gtopParser.write(JSON.stringify({
testStarted: {
name: "This is my test!",
id: "5226c9ce-0dc8-4ca5-95f7-23016716be70"
}
}));
The parser may emit three different types of event:
testStarted
: the complete GTOP messagetestResult
: the complete GTOP messageinvalidMessage
: a TypeError (which your consumer may then throw, if needed).
Running the tests
$ yarn test
Contributing
Pull requests welcome!
Versioning
We use SemVer for versioning.
License
This project is licensed under the MIT License - see the LICENSE file for details