{"_id":"stream-switch","_rev":"2834559","name":"stream-switch","description":"Stream condition for switch/case","dist-tags":{"latest":"0.1.1"},"maintainers":[{"name":"popomore","email":""}],"time":{"modified":"2022-09-06T15:29:39.000Z","created":"2014-06-27T15:29:14.473Z","0.1.1":"2014-12-11T10:10:53.652Z","0.1.0":"2014-06-27T15:29:14.473Z"},"users":{},"author":{"name":"popomore","email":"sakura9515@gmail.com"},"repository":{"type":"git","url":"https://github.com/popomore/stream-switch"},"versions":{"0.1.1":{"name":"stream-switch","version":"0.1.1","description":"Stream condition for switch/case","main":"index","dependencies":{"duplexer2":"~0.0.2","through2":"~0.5.1","pedding":"~1.0.0"},"devDependencies":{"coveralls":"2","istanbul":"0","mocha":"1","should":"4"},"repository":{"type":"git","url":"https://github.com/popomore/stream-switch"},"keyword":["stream","switch","case","condition","gulp"],"homepage":"https://github.com/popomore/stream-switch","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"test":"make test"},"bugs":{"url":"https://github.com/popomore/stream-switch/issues"},"_id":"stream-switch@0.1.1","dist":{"shasum":"1bc746a99a9e67e17ab93b394f0eb8b904d0d002","size":28879,"noattachment":false,"key":"/stream-switch/-/stream-switch-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-switch/download/stream-switch-0.1.1.tgz"},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"maintainers":[{"name":"popomore","email":""}],"directories":{},"publish_time":1418292653652,"_hasShrinkwrap":false,"_cnpm_publish_time":1418292653652,"_cnpmcore_publish_time":"2021-12-16T13:58:47.547Z"},"0.1.0":{"name":"stream-switch","version":"0.1.0","description":"Stream condition for switch/case","main":"index","dependencies":{"duplexer2":"~0.0.2","through2":"~0.5.1"},"devDependencies":{"coveralls":"2","istanbul":"0","mocha":"1","should":"4"},"repository":{"type":"git","url":"https://github.com/popomore/stream-switch"},"keyword":["stream","switch","case","condition","gulp"],"homepage":"https://github.com/popomore/stream-switch","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"test":"make test"},"bugs":{"url":"https://github.com/popomore/stream-switch/issues"},"_id":"stream-switch@0.1.0","dist":{"shasum":"f094ce99163143339df9f18170e72b319426a04b","size":1595,"noattachment":false,"key":"/stream-switch/-/stream-switch-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-switch/download/stream-switch-0.1.0.tgz"},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"maintainers":[{"name":"popomore","email":""}],"directories":{},"publish_time":1403882954473,"_hasShrinkwrap":false,"_cnpm_publish_time":1403882954473,"_cnpmcore_publish_time":"2021-12-16T13:58:47.755Z"}},"readme":"# stream-switch [![Build Status](https://travis-ci.org/popomore/stream-switch.png?branch=master)](https://travis-ci.org/popomore/stream-switch) [![Coverage Status](https://coveralls.io/repos/popomore/stream-switch/badge.png?branch=master)](https://coveralls.io/r/popomore/stream-switch?branch=master) \n\nStream condition for switch/case, just like [ternary-stream](https://github.com/robrich/ternary-stream) for if/else\n\n---\n\n## Install\n\n```\n$ npm install stream-switch -g\n```\n\n## Usage\n\n![](https://raw.githubusercontent.com/popomore/stream-switch/master/img/switch.png)\n\n```\nvar switchStream = require('stream-switch');\n\nprocess.in\n.pipe(switchStream(function(buf) {\n  if (buf > 0) {\n    return 'case1';\n  } else if (buf < 0) {\n    return 'case2'\n  }\n}, {\n  'case1': streamA,\n  'case2': streamB\n}))\n.pipe(process.stdout)\n```\n\nIf buf great than 0, then pipe to streamA. If buf less than 0, then pipe to streamB. Otherwise buf equal to 0, pipe to output directly.\n\n## API\n\nswitchStream(switch, cases)\n\n#### switch\n\nSwitch condition determine which case will be choose.\n\nSwitch can be any type, if switch is function, it will be called.\n\n#### cases\n\nChoose which stream will be piped to by key switch return.\n\n## LISENCE\n\nCopyright (c) 2014 popomore. Licensed under the MIT license.\n","_attachments":{},"homepage":"https://github.com/popomore/stream-switch","bugs":{"url":"https://github.com/popomore/stream-switch/issues"},"license":"MIT"}