mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 02:27:20 -04:00
28 lines
679 B
JavaScript
28 lines
679 B
JavaScript
|
var fs = require ('fs');
|
||
|
var net = require('net');
|
||
|
var join = require('path').join;
|
||
|
var file = join(__dirname, 'fixtures','all_npm.json');
|
||
|
var JSONStream = require('../');
|
||
|
|
||
|
|
||
|
var server = net.createServer(function(client) {
|
||
|
var parser = JSONStream.parse([]);
|
||
|
parser.on('end', function() {
|
||
|
console.log('close')
|
||
|
console.error('PASSED');
|
||
|
server.close();
|
||
|
});
|
||
|
client.pipe(parser);
|
||
|
var n = 4
|
||
|
client.on('data', function () {
|
||
|
if(--n) return
|
||
|
client.end();
|
||
|
})
|
||
|
});
|
||
|
server.listen(9999);
|
||
|
|
||
|
|
||
|
var client = net.connect({ port : 9999 }, function() {
|
||
|
fs.createReadStream(file).pipe(client).on('data', console.log) //.resume();
|
||
|
});
|