-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (29 loc) · 1.01 KB
/
index.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
#!/usr/bin/env node
var cl = require('corelocation'),
wmataClient = require('wmata-client'),
colors = require('colors'),
lpad = require('leftpad'),
request = require('request');
var ll = cl.getLocation();
console.log('searching around ', ll.join(',') + '\n');
var stations = wmataClient.rail.findStop(ll);
var codes = stations.map(function(s) { return s.code; });
var all = request({ uri: 'http://secret-wildwood-1777.herokuapp.com/rail/station/all/prediction', json: true }, function(err, data, body) {
var valid = [];
codes.forEach(function(c) {
valid.push(body[c]);
});
valid.forEach(function(v) {
console.log(v[0].LocationName);
v.forEach(function(t) {
var c = {
RD: 'red',
GR: 'green',
YL: 'yellow',
BL: 'blue'
}[t.Line];
console.log('', lpad(t.Min, 4, ' '), ' min ', (c ? t.Line[c] : t.Line), ' → ', t.DestinationName);
});
console.log();
});
});