Skip to content

Commit

Permalink
use external stringify-stream for example
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Feb 3, 2015
1 parent 944ce44 commit 5bc9e13
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
16 changes: 0 additions & 16 deletions core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,6 @@ var util = {
makeEventEmitter: function(dest) {
util.inherit(dest, require('events').EventEmitter);
},

// @link https://stackoverflow.com/questions/21124701/creating-a-node-js-readable-stream-from-a-javascript-object-the-simplest-possi#answer-21127245
StringifyStream: (function() {
var StringifyStream = function() {
require('stream').Transform.call(this);
this._readableState.objectMode = false;
this._writableState.objectMode = true;
}
require('util').inherits(StringifyStream, require('stream').Transform);
StringifyStream.prototype._transform = function(obj, encoding, cb){
this.push(JSON.stringify(obj) + '\n');
cb();
};

return StringifyStream;
})(),
// TODO:
gekkoMode: function() {
return 'realtime';
Expand Down
2 changes: 1 addition & 1 deletion docs/internals/budfox.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BudFox is a small part of Gekko's core that aggregates realtime market data from
new BudFox(config)
.start()
// convert JS objects to JSON string
.pipe(new util.StringifyStream())
.pipe(new require('stringify-stream')())
// output to standard out
.pipe(process.stdout);

Expand Down
2 changes: 1 addition & 1 deletion gekko.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ StringifyStream.prototype._transform = function(obj, encoding, cb){

new BudFox(config.watch)
.start()
.pipe(new util.StringifyStream())
.pipe(new require('stringify-stream')())
.pipe(process.stdout);

return;
Expand Down

0 comments on commit 5bc9e13

Please sign in to comment.