Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. const getLineReader = function () {
  2. return require('readline').createInterface({
  3. input: require('fs').createReadStream('data.txt')
  4. });
  5. };
  6.  
  7. const getSystem = function () {
  8. const lineReader = getLineReader();
  9. const services = [];
  10.  
  11. lineReader.on('line', function (line) {
  12. const serviceJSON = JSON.parse(line);
  13. const tests = serviceJSON.tests.map(test => {
  14. return new ServiceTest(
  15. test.id,
  16. test.name,
  17. test.criticality);
  18. });
  19.  
  20. const service = new NewService(new UniqueID(), serviceJSON.name, tests, new Timestamp());
  21.  
  22. services.push(service);
  23. console.log(services); // prints Services { _services: [relevant data here] }
  24.  
  25. });
  26.  
  27. console.log(services); // prints Services { _services: [] }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement