aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/stream-utils.js
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-04-16 23:29:43 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-04-19 04:30:22 +0800
commit603c1310ffc0cdb61a66f68b8240e76c2ae7cb04 (patch)
treee555cd0a7d6269adc636d14ee3650aac133fdc77 /app/scripts/lib/stream-utils.js
parent061975cd4a92dfcff7c98c2ab34290b8680c5545 (diff)
downloadtangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar.gz
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar.bz2
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar.lz
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar.xz
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.tar.zst
tangerine-wallet-browser-603c1310ffc0cdb61a66f68b8240e76c2ae7cb04.zip
Add a few missing docblocks to background files
Diffstat (limited to 'app/scripts/lib/stream-utils.js')
-rw-r--r--app/scripts/lib/stream-utils.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js
index 8bb0b4f3c..3dbc064b5 100644
--- a/app/scripts/lib/stream-utils.js
+++ b/app/scripts/lib/stream-utils.js
@@ -8,20 +8,34 @@ module.exports = {
setupMultiplex: setupMultiplex,
}
+/**
+ * Returns a stream transform that parses JSON strings passing through
+ * @return {stream.Transform}
+ */
function jsonParseStream () {
- return Through.obj(function (serialized, encoding, cb) {
+ return Through.obj(function (serialized, _, cb) {
this.push(JSON.parse(serialized))
cb()
})
}
+/**
+ * Returns a stream transform that calls {@code JSON.stringify}
+ * on objects passing through
+ * @return {stream.Transform} the stream transform
+ */
function jsonStringifyStream () {
- return Through.obj(function (obj, encoding, cb) {
+ return Through.obj(function (obj, _, cb) {
this.push(JSON.stringify(obj))
cb()
})
}
+/**
+ * Sets up stream multiplexing for the given stream
+ * @param {any} connectionStream - the stream to mux
+ * @return {stream.Stream} the multiplexed stream
+ */
function setupMultiplex (connectionStream) {
const mux = new ObjectMultiplex()
pump(