From 5bc9e13ac3062e5dd63c3e05c29df6442ad13392 Mon Sep 17 00:00:00 2001 From: Mike van Rossum <mike@mikevanrossum.nl> Date: Tue, 3 Feb 2015 01:00:23 +0100 Subject: [PATCH] use external stringify-stream for example --- core/util.js | 16 ---------------- docs/internals/budfox.md | 2 +- gekko.js | 2 +- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/core/util.js b/core/util.js index d55fc108b..22b870e11 100644 --- a/core/util.js +++ b/core/util.js @@ -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'; diff --git a/docs/internals/budfox.md b/docs/internals/budfox.md index 23e812c0d..544ab5037 100644 --- a/docs/internals/budfox.md +++ b/docs/internals/budfox.md @@ -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); diff --git a/gekko.js b/gekko.js index 1bf736d0b..f0f135a6a 100644 --- a/gekko.js +++ b/gekko.js @@ -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;