aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/stream-utils.js
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-04-19 06:37:50 +0800
committerGitHub <noreply@github.com>2018-04-19 06:37:50 +0800
commit4544d57f2632ce5a00dc8780a7b360ab9b2657c3 (patch)
treecc7acf6302befb1e898571c800f873d670cf7cd5 /app/scripts/lib/stream-utils.js
parent6742a5b2722da7af9320f46b18e9f4b59c5666ba (diff)
parent603c1310ffc0cdb61a66f68b8240e76c2ae7cb04 (diff)
downloadtangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar.gz
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar.bz2
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar.lz
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar.xz
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.tar.zst
tangerine-wallet-browser-4544d57f2632ce5a00dc8780a7b360ab9b2657c3.zip
Merge pull request #3984 from whymarrh/3941-jsdoc
Add a few 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(