aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/obj-multiplex.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-09-08 12:17:49 +0800
committerkumavis <aaron@kumavis.me>2017-09-08 12:17:49 +0800
commit57e4805c621155cd86169064f4aaba34b73644c6 (patch)
tree8743a9621d2f4596c42df1ede748fa1b69aa8691 /app/scripts/lib/obj-multiplex.js
parent440a42bbc38ed53b64dc017fd56bd3281355df33 (diff)
downloadtangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.gz
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.zst
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.zip
streams - use pump and published obj-multiplex
Diffstat (limited to 'app/scripts/lib/obj-multiplex.js')
-rw-r--r--app/scripts/lib/obj-multiplex.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/app/scripts/lib/obj-multiplex.js b/app/scripts/lib/obj-multiplex.js
deleted file mode 100644
index 0034febe0..000000000
--- a/app/scripts/lib/obj-multiplex.js
+++ /dev/null
@@ -1,48 +0,0 @@
-const through = require('through2')
-
-module.exports = ObjectMultiplex
-
-function ObjectMultiplex (opts) {
- opts = opts || {}
- // create multiplexer
- const mx = through.obj(function (chunk, enc, cb) {
- const name = chunk.name
- const data = chunk.data
- if (!name) {
- console.warn(`ObjectMultiplex - Malformed chunk without name "${chunk}"`)
- return cb()
- }
- const substream = mx.streams[name]
- if (!substream) {
- console.warn(`ObjectMultiplex - orphaned data for stream "${name}"`)
- } else {
- if (substream.push) substream.push(data)
- }
- return cb()
- })
- mx.streams = {}
- // create substreams
- mx.createStream = function (name) {
- const substream = mx.streams[name] = through.obj(function (chunk, enc, cb) {
- mx.push({
- name: name,
- data: chunk,
- })
- return cb()
- })
- mx.on('end', function () {
- return substream.emit('end')
- })
- if (opts.error) {
- mx.on('error', function () {
- return substream.emit('error')
- })
- }
- return substream
- }
- // ignore streams (dont display orphaned data warning)
- mx.ignoreStream = function (name) {
- mx.streams[name] = true
- }
- return mx
-}