{"id":27954352,"url":"https://github.com/htoooth/mississippi2","last_synced_at":"2026-02-22T04:32:55.179Z","repository":{"id":57298364,"uuid":"55696172","full_name":"htoooth/mississippi2","owner":"htoooth","description":"A collection of useful stream utility modules for writing better code using streams","archived":false,"fork":false,"pushed_at":"2018-01-15T13:34:07.000Z","size":56,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T10:56:15.118Z","etag":null,"topics":["readable-streams","stream","writable-streams"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htoooth.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-07T13:19:38.000Z","updated_at":"2023-11-03T17:12:18.000Z","dependencies_parsed_at":"2022-09-06T04:20:45.721Z","dependency_job_id":null,"html_url":"https://github.com/htoooth/mississippi2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/htoooth/mississippi2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htoooth%2Fmississippi2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htoooth%2Fmississippi2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htoooth%2Fmississippi2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htoooth%2Fmississippi2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htoooth","download_url":"https://codeload.github.com/htoooth/mississippi2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htoooth%2Fmississippi2/sbom","scorecard":{"id":471188,"data":{"date":"2025-08-11","repo":{"name":"github.com/htoooth/mississippi2","commit":"475e83afc5d460231c2b3e5e1d74042e3b98503e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T13:55:50.899Z","repository_id":57298364,"created_at":"2025-08-19T13:55:50.899Z","updated_at":"2025-08-19T13:55:50.899Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["readable-streams","stream","writable-streams"],"created_at":"2025-05-07T17:25:40.841Z","updated_at":"2026-02-22T04:32:55.169Z","avatar_url":"https://github.com/htoooth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mississippi2\n\n[![NPM](https://nodei.co/npm/mississippi2.png?downloads=true)](https://nodei.co/npm/mississippi2/)\n\nThis module was inspired from [mississippi](https://github.com/maxogden/mississippi).\n\n## usage\n\n```bash\nnpm install mississippi2 --save\n```\n\n```js\nvar miss = require('mississippi2')\n```\n\n## methods\n\n- [pipe](#pipe)\n- [merge](#merge) *\n- [condition](#condition) *\n- [each](#each)\n- [map](#map) *\n- [filter](#filter) *\n- [reduce](#reduce) *\n- [split](#split) *\n- [spy](#spy) *\n- [pipeline](#pipeline)\n- [duplex](#duplex)\n- [through](#through)\n- [from](#from)\n- [fromValue](#fromvalue) *\n- [fromPromise](#frompromise) *\n- [fromObservable](#fromobservable) *\n- [to](#to)\n- [toString](#tostring) *\n- [toArray](#toarray) *\n- [toPromise](#topromise) *\n- [toObservable](#toobservable) *\n- [concat](#concat)\n- [unique](#unique) *\n- [toJSON](#tojson) *\n- [stringify](#stringify) *\n- [child](#child) *\n- [finished](#finished)\n- [throttle](#throttle) *\n- [Parser](#parser) *\n\n### pipe\n\n##### `miss.pipe(stream1, stream2, stream3, ..., cb)`\n\nPipes streams together and destroys all of them if one of them closes. Calls `cb` with `(error)` if there was an error in any of the streams.\n\nWhen using standard `source.pipe(destination)` the source will _not_ be destroyed if the destination emits close or error. You are also not able to provide a callback to tell when the pipe has finished.\n\n`miss.pipe` does these two things for you, ensuring you handle stream errors 100% of the time (unhandled errors are probably the most common bug in most node streams code)\n\n#### original module\n\n`miss.pipe` is provided by [`require('pump')`](https://npmjs.org/pump)\n\n#### example\n\n```js\n// lets do a simple file copy\nvar fs = require('fs')\n\nvar read = fs.createReadStream('./original.zip')\nvar write = fs.createWriteStream('./copy.zip')\n\n// use miss.pipe instead of read.pipe(write)\nmiss.pipe(read, write, function (err) {\n  if (err) return console.error('Copy error!', err)\n  console.log('Copied successfully')\n})\n```\n\n### merge\n\n##### `miss.merge(streams, [options])`\n\nReturn a streams that merged alll streams together and emmit parallely events. When merge readable streams, return a readable stream that reads from multiple readable streams at the same time. If you want to emits multiple other streams one after another, use [merge2](https://github.com/teambition/merge2). When merge writable streams, retrun a writable stream that writes to multiple other writeable streams.\n\n#### original module\n\n`miss.merge` is provided by [`require('multi-duplex-stream')`](https://github.com/emilbayes/multi-duplex-stream)\n\n#### example\n\n```js\n// merge readable stream\nvar multiRead = miss.merge([\n  miss.fromValue(\"hello\"),\n  miss.fromValue(\"world\")\n]);\n\nmultiRead.on(\"data\", function(data){\n  console.log(data); // \"hello\" \"world\" or \"world\" \"hello\"\n});\n\nmultiRead.on(\"end\", function(){\n  console.log(\"no more data\");\n});\n\n// merge writable stream\nvar read = miss.fromValue('hello, world');\nvar write1 = fs.createWriteStream('./file1.txt');\nvar write2 = fs.createWriteStream('./file2.txt');\n\nvar multiWrite = miss.merge([write1,write2]);\n\nread.pipe(multiWrite).on(\"end\",function(){\n  // both file1 and file2 now contains \"hello, world\"\n});\n```\n\n### condition\n\n##### `miss.condition(condition, stream, [elseStream])`\n\nCondition stream can conditionally control the flow of stream data.\n\nCondition stream will pipe data to `stream` whenever `condition` is truthy.\n\nIf `condition` is falsey and `elseStream` is passed, data will pipe to `elseStream`.\n\nAfter data is piped to `stream` or `elseStream` or neither, data is piped down-stream.\n\n#### original module\n\n`miss.condition` is provided by [`require('ternary-stream')`](https://github.com/robrich/ternary-stream)\n\n#### example\n\n```js\n// if the condition returns truthy, data is piped to the child stream\nvar condition = function (data) {\n  return true;\n};\n\nprocess.stdin\n  .pipe(miss.condition(condition, process.stdout))\n  .pipe(fs.createWriteStream('./out.txt'));\n\n// Data will conditionally go to stdout, and always go to the file\nvar through2 = require('through2');\n\nvar count = 0;\nvar condition = function (data) {\n  count++;\n  return count % 2;\n};\n\nprocess.stdin\n  .pipe(miss.condition(condition, fs.createWriteStream('./truthy.txt'), fs.createWriteStream('./falsey.txt')))\n  .pipe(process.stdout);\n```\n\n### each\n\n##### `miss.each(stream, each, [done])`\n\nIterate the data in `stream` one chunk at a time. Your `each` function will be called with `(data, next)` where data is a data chunk and next is a callback. Call `next` when you are ready to consume the next chunk.\n\nOptionally you can call `next` with an error to destroy the stream. You can also pass the optional third argument, `done`, which is a function that will be called with `(err)` when the stream ends. The `err` argument will be populated with an error if the stream emitted an error.\n\n#### original module\n\n`miss.each` is provided by [`require('stream-each')`](https://npmjs.org/stream-each)\n\n#### example\n\n```js\nvar fs = require('fs')\nvar split = require('split2')\n\nvar newLineSeparatedNumbers = fs.createReadStream('numbers.txt')\n\nvar pipeline = miss.pipeline(newLineSeparatedNumbers, split())\nvar each = miss.each(pipeline, eachLine, done)\nvar sum = 0\n\nfunction eachLine (line, next) {\n  sum += parseInt(line.toString())\n  next()\n}\n\nfunction done (err) {\n  if (err) throw err\n  console.log('sum is', sum)\n}\n```\n\n### map\n\n##### `miss.map([options,] fn)`\n\nReturn a `stream.Transfrom` instance that will call `fn(chunk, index)` on each stream segment.\n\nNote you will __NOT__ be able to skip chunks. This is intended for modification only. If you want filter the stream content, use `miss.filter`. This transform also does not have a flush function.\n\n#### original module\n\n`miss.map` is provided by [`require('through2-map')`](https://github.com/brycebaril/through2-map)\n\n#### example\n\n```js\nvar truncate = miss.map(function (chunk) {\n  return chunk.slice(0, 10)\n});\n\n// Then use your map:\nsource.pipe(truncate).pipe(sink)\n\n```\n\n### filter\n\n##### `miss.filter([options], fn)`\n\nCreate a  `through2-filter`  instance that will call `fn(chunk)`. If `fn(chunk)` returns \"true\" the chunk will be passed downstream. Otherwise it will be dropped.\n\nNote you will __NOT__ be able to alter the content of the chunks. This is intended for filtering only. If you want to modify the stream content, use either  `miss.through`  or `miss.map`.\n\n#### original module\n\n`miss.filter` is provided by [`require('through2-filter')`](https://github.com/brycebaril/through2-filter)\n\n#### example\n\n```js\nvar skip = miss.filter(function (chunk) {\n  // skip buffers longer than 100\n  return chunk.length \u003c 100\n})\n\n// Then use your filter:\nsource.pipe(skip).pipe(sink)\n```\n\n### reduce\n\n##### `miss.reduce([options,] fn [,initial])`\n\nCreate a Reduce *instance*. Works like `Array.prototype.reduce` meaning you can specify a `fn` function that takes up to *three* arguments: fn(previous, current, index) and you can specify an `initial` value.\n\nThis stream will only ever emit a *single* chunk. For more traditional `stream.Transform` filters or transforms, consider `miss.through` `miss.filter` or `miss.map`.\n\n#### original module\n\n`miss.reduce` is provided by [`require('through2-reduce')`](https://github.com/brycebaril/through2-reduce)\n\n#### example\n\n```js\nvar sum = miss.reduce({objectMode: true}, function (previous, current) { return previous + current })\n\n// Then use your reduce: (e.g. source is an objectMode stream of numbers)\nsource.pipe(sum).pipe(sink)\n```\n\n### split\n\n##### `miss.split([matcher, mapper, options])`\n\nBreak up a stream and reassemble it so that each line is a chunk.\n\n`matcher` may be a `String`, or a `RegExp`.\n\n#### original module\n\n`miss.split` is provided by [`require('split2')`](https://github.com/mcollina/split2)\n\n#### example\n\n```js\n fs.createReadStream(file)\n    .pipe(miss.split())\n    .on('data', function (line) {\n      //each chunk now is a seperate line!\n    })\n```\n\n### spy \n\n##### `miss.spy([options], fn)`\n\nCreate a `miss.spy` instance that will call `fn(chunk)` and then silently pass through data downstream.\n\nNote you will **NOT** be able to do anything but spy and abort the stream pipeline. To do any filtering or transformations you should consider `miss.through` `miss.filter` or `miss.map`.\n\n#### original module\n\n`miss.spy` is provided by [`require('through2-spy')`](https://github.com/brycebaril/through2-spy)\n\n#### example\n\n```js\nvar count = 0;\nvar countChunks = miss.spy(function (chunk) {\n  count++\n});\n\n// Then use your spy:\nsource.pipe(countChunks).pipe(sink);\n```\n\n### pipeline\n\n##### `var pipeline = miss.pipeline(stream1, stream2, stream3, ...)`\n\nBuilds a pipeline from all the transform streams passed in as arguments by piping them together and returning a single stream object that lets you write to the first stream and read from the last stream.\n\nIf any of the streams in the pipeline emits an error or gets destroyed, or you destroy the stream it returns, all of the streams will be destroyed and cleaned up for you.\n\n#### original module\n\n`miss.pipeline` is provided by [`require('pumpify')`](https://npmjs.org/pumpify)\n\n#### example\n\n```js\n// first create some transform streams (note: these two modules are fictional)\nvar imageResize = require('image-resizer-stream')({width: 400})\nvar pngOptimizer = require('png-optimizer-stream')({quality: 60})\n\n// instead of doing a.pipe(b), use pipelin\nvar resizeAndOptimize = miss.pipeline(imageResize, pngOptimizer)\n// `resizeAndOptimize` is a transform stream. when you write to it, it writes\n// to `imageResize`. when you read from it, it reads from `pngOptimizer`.\n// it handles piping all the streams together for you\n\n// use it like any other transform stream\nvar fs = require('fs')\n\nvar read = fs.createReadStream('./image.png')\nvar write = fs.createWriteStream('./resized-and-optimized.png')\n\nmiss.pipe(read, resizeAndOptimize, write, function (err) {\n  if (err) return console.error('Image processing error!', err)\n  console.log('Image processed successfully')\n})\n```\n\n### duplex\n\n##### `var duplex = miss.duplex([writable, readable, opts])`\n\nTake two separate streams, a writable and a readable, and turn them into a single [duplex (readable and writable) stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).\n\nThe returned stream will emit data from the readable. When you write to it it writes to the writable.\n\nYou can either choose to supply the writable and the readable at the time you create the stream, or you can do it later using the `.setWritable` and `.setReadable` methods and data written to the stream in the meantime will be buffered for you.\n\n#### original module\n\n`miss.duplex` is provided by [`require('duplexify')`](https://npmjs.org/duplexify)\n\n#### example\n\n```js\n// lets spawn a process and take its stdout and stdin and combine them into 1 stream\nvar child = require('child_process')\n\n// @- tells it to read from stdin, --data-binary sets 'raw' binary mode\nvar curl = child.spawn('curl -X POST --data-binary @- http://foo.com')\n\n// duplexCurl will write to stdin and read from stdout\nvar duplexCurl = miss.duplex(curl.stdin, curl.stdout)\n```\n\n### through\n\n#####`var transformer = miss.through([options, transformFunction, flushFunction])`\n\nMake a custom [transform stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform).\n\nThe `options` object is passed to the internal transform stream and can be used to create an `objectMode` stream (or use the shortcut `miss.through.obj([...])`)\n\nThe `transformFunction` is called when data is available for the writable side and has the signature `(chunk, encoding, cb)`. Within the function, add data to the readable side any number of times with `this.push(data)`. Call `cb()` to indicate processing of the `chunk` is complete. Or to easily emit a single error or chunk, call `cb(err, chunk)`\n\nThe `flushFunction`, with signature `(cb)`, is called just before the stream is complete and should be used to wrap up stream processing.\n\n#### original module\n\n`miss.through` is provided by [`require('through2')`](https://npmjs.org/through2)\n\n#### example\n\n```js\nvar fs = require('fs')\n\nvar read = fs.createReadStream('./boring_lowercase.txt')\nvar write = fs.createWriteStream('./AWESOMECASE.TXT')\n\n// Leaving out the options object\nvar uppercaser = miss.through(\n  function (chunk, enc, cb) {\n    cb(null, chunk.toString().toUpperCase())\n  },\n  function (cb) {\n    cb(null, 'ONE LAST BIT OF UPPERCASE')\n  }\n)\n\nmiss.pipe(read, uppercaser, write, function (err) {\n  if (err) return console.error('Trouble uppercasing!')\n  console.log('Splendid uppercasing!')\n})\n```\n\n### from\n\n#####`miss.from([opts], read)`\n\nMake a custom [readable stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_readable).\n\n`opts` contains the options to pass on to the ReadableStream constructor e.g. for creating a readable object stream (or use the shortcut `miss.from.obj([...])`).\n\nReturns a readable stream that calls `read(size, next)` when data is requested from the stream.\n\n- `size` is the recommended amount of data (in bytes) to retrieve.\n- `next(err, chunk)` should be called when you're ready to emit more data.\n\n#### original module\n\n`miss.from` is provided by [`require('from2')`](https://npmjs.org/from2)\n\n#### example\n\n```js\nfunction fromString(string) {\n  return miss.from(function(size, next) {\n    // if there's no more content\n    // left in the string, close the stream.\n    if (string.length \u003c= 0) return next(null, null)\n\n    // Pull in a new chunk of text,\n    // removing it from the string.\n    var chunk = string.slice(0, size)\n    string = string.slice(size)\n\n    // Emit \"chunk\" from the stream.\n    next(null, chunk)\n  })\n}\n\n// pipe \"hello world\" out\n// to stdout.\nfromString('hello world').pipe(process.stdout)\n```\n\n### fromValue\n\n#####`miss.fromValue(value)`\n\nCreate streams from (single) arbitrary Javascript values like `strings`, `functions`, `arrays`, etc. \n\nPlease __Note__ miss.fromValue are [Readable](http://nodejs.org/api/stream.html#stream_class_stream_readable_1) streams.\n\n#### original module\n\n`miss.fromValue` is provided by [`require('stream-from-value')`](https://github.com/schnittstabil/stream-from-value)\n\n#### example\n\n```js\nmiss.fromValue('some string')\n  .pipe(process.stdout); // output: some string\n\nmiss.fromValue(new Buffer('some string'))\n  .pipe(process.stdout); // output: some string\n\n// Stream of (arbitrary) Javascript Value\nmiss.fromValue.obj(['some', 'mixed', 'array', 42]).on('data', function(data){\n    console.log(data); // output: [ 'some', 'mixed', 'array', 42 ]\n  });\n```\n\n### fromPromise\n\n#####`miss.fromPromise(promise)`\n\nMake a [Readable](http://nodejs.org/api/stream.html#stream_class_stream_readable_1) streams from `ECMAScript 2015 Promises` that return Javascript values like numbers, strings, objects, functions.\n\n#### original module\n\n`miss.fromPromise` is provided by [`require('stream-from-promise')`](https://github.com/schnittstabil/stream-from-promise)\n\n#### example\n\n```js\n// `String promises\nvar stringPromise = new Promise(function(resolve, reject){\n  setTimeout(function(){\n    resolve('strrrring!');\n  }, 500);\n});\n\nmiss.fromPromise(stringPromise).pipe(process.stdout); // =\u003e output: strrrring!\n\n// Buffer promises\nvar bufferPromise = new Promise(function(resolve, reject){\n  setTimeout(function(){\n    resolve(new Buffer('buff!'));\n  }, 500);\n});\n\nStreamFromPromise(bufferPromise)\n  .pipe(process.stdout); // output: buff!\n\n```\n\n### fromObservable\n\n#####`miss.fromObservable(observable, stream, [encoding])`\n\nWrites an observable sequence to a writable stream.\n\n__Arguments__\n\n- `observable` *(Observable)*: Observable sequence to write to a stream.\n- `stream` *(Stream)*: The stream to write to.\n- `[encoding]` *(String)*: The encoding of the item to write.\n\n__Returns__\n- *(Disposable)*: The subscription handle.\n\n#### original module\n\n`miss.fromObsesrvable` is provided by [`require(\"rx-node\").writeToStream`](https://github.com/Reactive-Extensions/rx-node)\n\n#### example\n\n```js\nvar Rx = require('rx');\nvar source = Rx.Observable.range(0, 5);\n\nvar subscription = miss.fromObsesrvable(source, process.stdout, 'utf8');\n// =\u003e 01234\n```\n\n### to\n\n#####`miss.to([options], write, [flush])`\n\nMake a custom [writable stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_writable).\n\n`opts` contains the options to pass on to the WritableStream constructor e.g. for creating a readable object stream (or use the shortcut `miss.to.obj([...])`).\n\nReturns a writable stream that calls `write(data, enc, cb)` when data is written to the stream.\n\n- `data` is the received data to write the destination.\n- `enc` encoding of the piece of data received.\n- `next(err, chunk)` should be called when you're ready to write more data, or encountered an error.\n\n`flush(cb)` is called before `finish` is emitted and allows for cleanup steps to occur.\n\n#### original module\n\n`miss.to` is provided by [`require('flush-write-stream')`](https://npmjs.org/flush-write-stream)\n\n#### example\n\n```js\nvar ws = miss.to(write, flush)\n\nws.on('finish', function () {\n  console.log('finished')\n})\n\nws.write('hello')\nws.write('world')\nws.end()\n\nfunction write (data, enc, cb) {\n  // i am your normal ._write method\n  console.log('writing', data.toString())\n  cb()\n}\n\nfunction flush (cb) {\n  // i am called before finish is emitted\n  setTimeout(cb, 1000) // wait 1 sec\n}\n```\n\nIf you run the above it will produce the following output\n\n```\nwriting hello\nwriting world\n(nothing happens for 1 sec)\nfinished\n```\n\n### toString\n\n#####`miss.toString(stream [, callback])`\n\nPipe a stream into a string, collect value with callback or promise.\n\nCollects stream data into a string. Executes optional `callback(err, string)`. Returns a promise.\n\n#### original module\n\n`miss.toString` is provided by [`require('stream-to-string')`](https://github.com/jasonpincin/stream-to-string)\n\n#### example\n\n```js\n// with callback\nvar stream = miss.through();\n\nmiss.toString(stream, function (err, msg) {\n    console.log(msg)\n})\n\n// or with promises\nmiss.toString(stream).then(function (msg) {\n    console.log(msg)\n})\n\nstream.write('this is a')\nstream.write(' test')\nstream.end()\n```\n\n### toArray\n\n#####`miss.toArray([stream], [callback(err, arr)])`\n\nConcatenate a readable stream's data into a single array.\n\nReturns all the data objects in an array. This is useful for streams in object mode if you want to just use an array.\n\n#### original module\n\n`miss.toArray` is provided by [`require('stream-to-array')`](https://github.com/stream-utils/stream-to-array)\n\n#### example\n\n```js\n// with callback\nvar stream = miss.through();\n\nmiss.toArray(stream, function (err, msg) {\n    console.log(msg)\n})\n\n// or with promises\nmiss.toArray(stream).then(function (msg) {\n    console.log(msg)\n})\n\nstream.write('this is a')\nstream.write(' test')\nstream.end()\n```\n\n### toPromise\n\n#####`miss.toPromise(stream)`\n\nConvert streams (readable or writable) to promises.\n\n#### original module\n\n`miss.toPromise` is provided by [`require('stream-to-promise2')`](https://github.com/htoooth/stream-to-promise2)\n\n#### example\n\n```js\nmiss.toPromise(readableStream).then(function (buffer) {\n  // buffer.length === 3\n});\nreadableStream.emit('data', new Buffer());\nreadableStream.emit('data', new Buffer());\nreadableStream.emit('data', new Buffer());\nreadableStream.emit('end'); // promise is resolved here\n```\n\n### toObservable\n\n#####`miss.toObservable(stream, finishEventName, dataEventName)`\n\nConverts a flowing readable to an Observable sequence.\n\n__Arguments__\n\n- `stream` *(Stream)*: A stream to convert to a observable sequence.\n- `[dataEventName]` *(String)*: Event that notifies about incoming data. (\"data\" by default)\n\n__Returns__\n\n- *(Observable)*: An observable sequence which fires on each 'data' event as well as handling 'error' and 'end' events.\n\n#### original module\n\n`miss.toObservable` is provided by [`require(\"rx-node\").writeToStream`](https://github.com/Reactive-Extensions/rx-node)\n\n#### example\n\n```js\nvar subscription = miss.toObservable(process.stdin)\n    .subscribe(function (x) { console.log(x); });\n\n// =\u003e r\u003cBuffer 72\u003e\n// =\u003e x\u003cBuffer 78\u003e\n```\n\n### concat\n\n#####`var concat = miss.concat(cb)`\n\nReturns a writable stream that concatenates all data written to the stream and calls a callback with the single result.\n\nCalling `miss.concat(cb)` returns a writable stream. `cb` is called when the writable stream is finished, e.g. when all data is done being written to it. `cb` is called with a single argument, `(data)`, which will containe the result of concatenating all the data written to the stream.\n\nNote that `miss.concat` will not handle stream errors for you. To handle errors, use `miss.pipe` or handle the `error` event manually.\n\n#### original module\n\n`miss.concat` is provided by [`require('concat-stream')`](https://npmjs.org/concat-stream)\n\n#### example\n\n```js\nvar fs = require('fs')\nvar concat = require('concat-stream')\n\nvar readStream = fs.createReadStream('cat.png')\nvar concatStream = concat(gotPicture)\n\nreadStream.on('error', handleError)\nreadStream.pipe(concatStream)\n\nfunction gotPicture(imageBuffer) {\n  // imageBuffer is all of `cat.png` as a node.js Buffer\n}\n\nfunction handleError(err) {\n  // handle your error appropriately here, e.g.:\n  console.error(err) // print the error to STDERR\n  process.exit(1) // exit program with non-zero exit code\n}\n```\n\n### unique\n\n#####`miss.unique([fn])`\n\nFilter duplicates from a stream based on a hashing `fn(chunk)`. By default, this hashing function is:\n\n```js\nsha256sum(JSON.stringify(doc))\n```\n\n#### original module\n\n`miss.unique` is provided by [`require('unique-hash-stream')`](https://github.com/stream-utils/unique-hash-stream)\n\n#### example\n\n```js\nvar stream = miss.through();\n\nvar hashFn = function(chunk){\n  return chunk;\n};\n\nstream.pipe(miss.unique(hashFn)).pipe(process.stdout);\n\nstream.write(\"a\");\nstream.write(\"a\");\nstream.write(\"b\");\nstream.end();\n\n```\n\n### toJSON\n\n#####`miss.toJSON(stream, callback)`\n\nRead all from `stream`, then `JSON.parse` and call `callback(err, json)` with the result. If there's an Error in the stream itself, or parsing the JSON, an error will be passed.\n\n#### original module\n\n`miss.toJSON` is provided by [`require('stream-to-json')`](https://www.npmjs.com/package/stream-to-json)\n\n#### example\n\n```js\nvar request = require('request');\n \nmiss.toJSON(request('/some/url.json'), function(err, json) {\n  if (err) throw err;\n  console.log(json);\n});\n```\n\n\n### stringify\n\n#####`miss.stringify([options])`\n\nSimilar to JSONStream.stringify() except it is, by default, a binary stream, and it is a streams2 implementation.\n\nPlease __NOTE__ : The main use case for this is to stream a database query to a web client. This is meant to be used only with `arrays`, not `objects`.\n\n__Separators__\n\n- The stream always starts with '[\\n'.\n- Documents are separated by '\\n,\\n'.\n- The stream is terminated with '\\n]\\n'.\n\n#### original module\n\n`miss.stringify` is provided by [`require('streaming-json-stringify')`](https://github.com/stream-utils/streaming-json-stringify)\n\n#### example\n\n```js\napp.get('/things', function (req, res, next) {\n  res.setHeader('Content-Type', 'application/json; charset=utf-8')\n\n  db.things.find()\n  .stream()\n  .pipe(miss.stringify())\n  .pipe(res)\n})\n```\n\nwill yield something like\n\n```\n[\n{\"_id\":\"123412341234123412341234\"}\n,\n{\"_id\":\"123412341234123412341234\"}\n]\n```\n\n\n### child\n\n#####`miss.child(command, [args], [options])`\n\nSpawn a child process as a duplex stream.\n\nConvenience wrapper for:\n\n```js\nnew Child_Process().spawn(command, [args], [options])\n```\n\n#### original module\n\n`miss.child` is provided by [`require('duplex-child-process')`](https://github.com/stream-utils/duplex-child-process)\n\n#### example\n\n```js\nvar toJPEG = miss.child.spawn('convert', ['-', 'JPEG:-'])\nvar getFormat = miss.child.spawn('identify', ['-format', '%m', '-'])\n\nfs.createReadStream('img.png')\n.pipe(toJPEG)\n.pipe(getFormat)\n.once('readable', function () {\n  var format = this.read().toString('utf8')\n  assert.equal(format, 'JPEG')\n})\n```\n\n### finished\n\n#####`miss.finished(stream, cb)`\n\nWaits for `stream` to finish or error and then calls `cb` with `(err)`. `cb` will only be called once. `err` will be null if the stream finished without error, or else it will be populated with the error from the streams `error` event.\n\nThis function is useful for simplifying stream handling code as it lets you handle success or error conditions in a single code path. It's used internally `miss.pipe`.\n\n#### original module\n\n`miss.finished` is provided by [`require('end-of-stream')`](https://npmjs.org/end-of-stream)\n\n#### example\n\n```js\nvar copySource = fs.createReadStream('./movie.mp4')\nvar copyDest = fs.createWriteStream('./movie-copy.mp4')\n\ncopySource.pipe(copyDest)\n\nmiss.finished(copyDest, function(err) {\n  if (err) return console.log('write failed', err)\n  console.log('write success')\n})\n```\n\n### throttle\n\n#####`miss.throttle(n)`\n\nThis stream offers a `Throttle` passthrough stream class, which allows you to write data to it and it will be passed through in `n` bytes per second. It can be useful for throttling HTTP uploads or to simulate reading from a file in real-time, etc.\n\n#### original module\n\n`miss.throttle` is provided by [`require(\"throttle\")`](https://github.com/TooTallNate/node-throttle)\n\n#### example\n\n```js\n// throttling stdin at 1 byte per second and outputting the data to stdout:\nprocess.stdin.pipe(miss.throttle(1)).pipe(process.stdout);\n```\n\n### Parser\n\n#####`miss.Parser`\n\nThis tool offers the `stream-parser` mixin, which provides an easy-to-use API for parsing bytes from `Writable` and/or `Transform` stream instances. This module is great for implementing streaming parsers for standardized file formats.\n\nFor `Writable` streams, the parser takes control over the `_write` callback function. For Transform streams, the parser controls the `_transform` callback function.\n\n##### api\n\n  The `Parser` stream mixin works with either `Writable` or `Transform` stream\n  instances/subclasses. Provides a convenient generic \"parsing\" API:\n\n```js\n_bytes(n, cb) - buffers \"n\" bytes and then calls \"cb\" with the \"chunk\"\n_skipBytes(n, cb) - skips \"n\" bytes and then calls \"cb\" when done\n```\n\n  If you extend a `Transform` stream, then the `_passthrough()` function is also\n  added:\n\n```js\n_passthrough(n, cb) - passes through \"n\" bytes untouched and then calls \"cb\"\n```\n\n###### ._bytes(n, cb)\n\n  Buffers `n` bytes and then invokes `cb` once that amount has been collected.\n\n###### ._skipBytes(n, cb)\n\n  Skips over the next `n` bytes and then invokes `cb` once that amount has been\n  discarded.\n\n###### ._passthrough(n, cb)\n\n  Passes through `n` bytes to the readable side of this stream untouched,\n  then invokes `cb` once that amount has been passed through. This function is only defined\n  when stream-parser is extending a `Transform` stream.\n\n##### original module\n\n`miss.Parser` is provided by [`require('stream-parser')`](https://github.com/TooTallNate/node-stream-parser)\n\n#### example\n\nLet's create a quick `Transform` stream subclass that utilizes the parser's\n`_bytes()` and `_passthrough()` functions to parse a theoretical file format that\nhas an 8-byte header we want to parse, and then pass through the rest of the data.\n\n```js\nvar inherits = require('util').inherits;\nvar Transform = require('stream').Transform;\n\n// create a Transform stream subclass\nfunction MyParser () {\n  Transform.call(this);\n\n  // buffer the first 8 bytes written\n  this._bytes(8, this.onheader);\n}\ninherits(MyParser, Transform);\n\n// mixin stream-parser into MyParser's `prototype`\nmiss.Parser(MyParser.prototype);\n\n// invoked when the first 8 bytes have been received\nMyParser.prototype.onheader = function (buffer, output) {\n  // parse the \"buffer\" into a useful \"header\" object\n  var header = {};\n  header.type = buffer.readUInt32LE(0);\n  header.name = buffer.toString('utf8', 4);\n  this.emit('header', header);\n\n  // it's usually a good idea to queue the next \"piece\" within the callback\n  this._passthrough(Infinity);\n};\n\n\n// now we can *use* it!\nvar parser = new MyParser();\nparser.on('header', function (header) {\n  console.error('got \"header\"', header);\n});\nprocess.stdin.pipe(parser).pipe(process.stdout);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtoooth%2Fmississippi2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtoooth%2Fmississippi2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtoooth%2Fmississippi2/lists"}