好吧所以我试图使用事件流正确输出1条特定的行,但它无法正常工作
继承人我先尝试过的事情
socket.on('Image', function (fn) {
fn('Got Captcha Image');
child.stdin.setEncoding = 'utf-8';
var index = 0,
lines = [];
es.pipeline(
child.stdout,
es.split(),
es.map(function (line) {
//console.log(line);
lines[index++] = line;
console.log(lines[0]);
console.log(lines[1]);
console.log(lines[2]);
})
);
});
我得到了这个输出,它显示了9行而不是3行
Captchadone
undefined
undefined
Captchadone
https://c9.io/image.asp?1396969818
undefined
Captchadone
https://c9.io/image.asp?1396969818
Input
所以我试图输出我想要的1行
socket.on('Image', function (fn) {
fn('Got Captcha Image');
child.stdin.setEncoding = 'utf-8';
var index = 0,
lines = [];
es.pipeline(
child.stdout,
es.split(),
es.map(function (line) {
//console.log(line);
lines[index++] = line;
console.log(lines[1]);
})
);
});
但输出3次而不只是输出一次
https://c9.io/image.asp?1396969818
https://c9.io/image.asp?1396969818
https://c9.io/image.asp?1396969818
我需要它看起来像这样
https://c9.io/image.asp?1396969818
我怎么能这样做它只输出一次而不是每次console.log();言。