aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/stream-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/stream-utils.js')
-rw-r--r--app/scripts/lib/stream-utils.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js
new file mode 100644
index 000000000..12560ffd8
--- /dev/null
+++ b/app/scripts/lib/stream-utils.js
@@ -0,0 +1,21 @@
+const Through = require('through2')
+
+
+module.exports = {
+ jsonParseStream: jsonParseStream,
+ jsonStringifyStream: jsonStringifyStream,
+}
+
+function jsonParseStream(){
+ return Through.obj(function(serialized, encoding, cb){
+ this.push(JSON.parse(serialized))
+ cb()
+ })
+}
+
+function jsonStringifyStream(){
+ return Through.obj(function(obj, encoding, cb){
+ this.push(JSON.stringify(obj))
+ cb()
+ })
+}