-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrunner.js
40 lines (33 loc) · 868 Bytes
/
runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var searchers =[
require('./searcher-flipkart'),
require('./searcher-landmarkonthenet'),
require('./searcher-rediff')
];
var count = 0;
// Export searcher
module.exports = Runner;
function Runner(error, data, done) {
for (var i=0; i<searchers.length; i++){
console.log('Registering searcher: ' + searchers[i].toString());
searchers[i].on('item', function(item){
data (item);
});
searchers[i].on('error', function(param){
//console.log(param.searcher.toString() + " Error: " + param.error);
error(param);
});
searchers[i].on('complete', function(param){
console.log("Finished .. " + param.searcher.toString());
count++;
if (count == searchers.length) {
count = 0;
done();
}
});
}
}
Runner.prototype.search = function (query) {
for (var i=0; i<searchers.length; i++){
searchers[i].search(query);
}
}