Skip to content

Instantly share code, notes, and snippets.

@carbonrobot
Created September 12, 2013 17:11
Show Gist options
  • Select an option

  • Save carbonrobot/6540870 to your computer and use it in GitHub Desktop.

Select an option

Save carbonrobot/6540870 to your computer and use it in GitHub Desktop.
var Ticker = function () {
var decay = 5.0;
var growth = 7.0;
var stocks = [
{ name: "Apple", price: 4.50 },
{ name: "Microsoft", price: 4.00 },
{ name: "Facebook", price: 3.75 }
];
var _state = 'Not Started';
this.execute = function () {
_state = 'Processing';
stocks.forEach(function (p, i) {
p.Price -= p.Price / decay;
});
process.send({ stocks: stocks });
if(_state !== 'Cancelled')
setTimeout(this.execute, 1000);
};
this.stop = function () {
_state = 'Cancelled';
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment