multiple_objects_error.js 694 B

1234567891011121314151617181920212223242526272829
  1. var fs = require ('fs');
  2. var net = require('net');
  3. var join = require('path').join;
  4. var file = join(__dirname, 'fixtures','all_npm.json');
  5. var it = require('it-is');
  6. var JSONStream = require('../');
  7. var str = fs.readFileSync(file);
  8. var server = net.createServer(function(client) {
  9. var data_calls = 0;
  10. var parser = JSONStream.parse();
  11. parser.on('error', function(err) {
  12. console.log(err);
  13. server.close();
  14. });
  15. parser.on('end', function() {
  16. console.log('END');
  17. server.close();
  18. });
  19. client.pipe(parser);
  20. });
  21. server.listen(9999);
  22. var client = net.connect({ port : 9999 }, function() {
  23. var msgs = str + '}';
  24. client.end(msgs);
  25. });