Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit c534b26

Browse files
Fixing stock server example
1 parent 2479c33 commit c534b26

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

examples/stockserver/fileserver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require('path');
22
var fs = require('fs');
33

4-
var getFiles = function () {
4+
function getFiles() {
55
var dir = process.cwd();
66
var symbols = [
77
'AAPL',

examples/stockserver/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ var source = getStockData(fileserver.loadData()).share();
8383

8484
var groupedTickStream = source
8585
.flatMap(function (value) {
86-
var data = JSON.parse(value.data),
87-
date = new Date().getTime();
86+
var date = new Date().getTime();
8887

89-
return Observable.from(data).tap(function(x) {
88+
return Observable.from(value).tap(function(x) {
9089
x.timestamp = date;
9190
});
9291
})
@@ -139,7 +138,9 @@ var spikes = groupedTickStream
139138
return Math.abs(x.spike) >= 0.1;
140139
})
141140
.subscribe(function (x) {
142-
console.log('Symbol: ' + x.symbol + ' had a price spike of ' + x.spike + ' on ' + x.timestamp + ' with close of ' + x.lastClose);
141+
console.log('Symbol:' , x.symbol , 'had a price spike of '
142+
, Math.round(x.spike * 100) , '% on'
143+
, new Date(x.timestamp) , 'with close of $' , x.lastClose);
143144
}, function (err) {
144-
console.log(err);
145+
console.log(err.stack);
145146
});

0 commit comments

Comments
 (0)