{"dist":{"shasum":"a89cba360f06236d479ea9295977a661cdd73463","tarball":"https://registry.npmjs.org/flower/-/flower-0.5.4.tgz","integrity":"sha512-gd0TWzFgivigNtEwLJz8f/6O99IJhn2BEBLFNqcSAnKuh2r3jYCjlUcTdeVlZ11nURax7RRq/Z2DDISFjJgKDw==","signatures":[{"sig":"MEQCIEFbOojX4ir4zsoA+ZsUEbnPqeMhwSkIaarjQbXHJWk9AiBcW2DtjyucpvMXT6loj/YixI69ZGjH99TRFl/AFkGKZQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./flower.js","name":"flower","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"readme":"#flowers\n\n**flowers is a collection of stream helpers.**\n\n## Installation\n\n```sheel\nnpm install flowers\n```\n\n##API documentation\n\n### flowers.relayReadStream()\n\n_Also available as javascript constructor at `flowers.RelayReadStream()`_\n\nWill return a `ReadStream` object there does except for relaying pipe output.\n\nThe main usercase is that you expose function there don't have a callback\nbut returns a stream. However you have to do an async operation before\ncreateing the readstream, so you can't return the stream object directly.\n\n```JavaScript\nexports.read = function () {\n  var relay = flowers.relayReadStream();\n\n  process.nextTick(function () {\n    fs.createReadStream('file.txt').pipe(relay);\n  });\n\n  return relay;\n};\n```\n\n### flowers.queryStream()\n\n_Also available as javascript constructor at `flowers.QueryStream()`_\n\nWill return a `ReadStream` and `WritStream` object.\n\nThe stream is much like `flower.relayReadStream()` however it is much more\ncomplex. This has both advantages and disadvantages.\n\nThe advantages are that you can write to the stream as much as you want\nbut the data chunks won't emit if it is paused. Instead they gets pulled\nto an query list. You can also apply multiply pipes to the stream, the\npreviouse piped `ReadStream` will simply be destroy to prevent race\nconditions.\n\nThe disadvantages with this stream is that you easily will end up with\na huge query stack consumeing a lot of memory.\n\n```JavaScript\nvar output = flowers.queryStream();\noutput.pause();\noutput.write('A');\noutput.write('B');\n\nvar input = fs.createWritStream('file.txt');\ninput.on('open', function () {\n  output.pipe(input);\n  output.resume();\n});\n```\n\n### flowers.memoryStream()\n\n_Also available as javascript constructor at `flowers.MemoryStream()`_\n\nreturns `WriteStream` that you can pipe to using a `ReadStream`. The data chunks\nwill be stored seperatly in the `memoryStream`, on the same time or after data are\nbeing piped to the `memoryStream` you can create a new `ReadStream` from it by using\n``memoryStream.relay()`, the returned `ReadStream` will then emit the stored an new\nchunks in propper order.\n\nNote add chunks are writen to the `memoryStream` its `size` property will increase. This\nproperty contains the total buffer size.\n\nExample of how this can be used to implement a filecache\n\n```JavaScript\nvar filecache = {};\n\nfunction request(filename) {\n  if (filecache[filename] === undefined) {\n    filecache[filename] = flower.memoryStream();\n    fs.createReadStream(filename).pipe(filecache[filename]);\n  }\n  return filecache[filename].relay();\n}\n\n// request files\nrequest('file.txt');\n\n//multiply request will share the filestream\nrequest('file.txt');\nrequest('file.txt');\n```\n\n### flowers.buffer2stream(buffer, [options])\n\n_Also available as javascript constructor at `flowers.Buffer2stream()`_\n\nTakes a buffer or string and splits it up intro chunks there is emitted in\na `ReadStream` object.\n\nThe `options` object takes a `chunkSize` property there tell how big each chunk\nshould be in bytes. By default this is `64 * 1024`.\n\n```JavaScript\nvar stream = flowers.buffer2stream(buffer);\n\nstream.pipe(fs.createWriteStream('file.txt'));\n};\n```\n\n### flowers.stream2buffer(stream, callback)\n\nTakes a `ReadStream` and buffer it up until the stream is closed or an error occurred.\nThe buffer is then send as a callback argument.\n\nThe `callback` have two arguments `error` and `buffer`.\n\nThe `options` object takes a `chunkSize` property there tell how big each chunk\nshould be in bytes. By default this is `64 * 1024`.\n\n```JavaScript\nvar stream = fs.createReadStream('file.txt');\n\nflowers.stream2buffer(stream, function (error, buffer) {\n\n});\n```\n\n##License\n\n**The software is license under \"MIT\"**\n\n> Copyright (c) 2012 Andreas Madsen\n>\n> Permission is hereby granted, free of charge, to any person obtaining a copy\n> of this software and associated documentation files (the \"Software\"), to deal\n> in the Software without restriction, including without limitation the rights\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n> copies of the Software, and to permit persons to whom the Software is\n> furnished to do so, subject to the following conditions:\n>\n> The above copyright notice and this permission notice shall be included in\n> all copies or substantial portions of the Software.\n>\n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n> THE SOFTWARE.\n","engines":{"npm":"1","node":"0.6 || 0.8"},"license":"MIT","scripts":{"test":"vows test/simple/* --spec --isolate"},"_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"keywords":["stream","buffer","pipe","convert"],"repository":{"url":"git://github.com/AndreasMadsen/flower.git","type":"git"},"_npmVersion":"1.1.24","description":"Collection of stream classes and functions","maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"_nodeVersion":"v0.6.20-pre","dependencies":{},"_defaultsLoaded":true,"devDependencies":{"vows":"0.6.x","wrench":"1.3.x"},"_engineSupported":true,"optionalDependencies":{},"_id":"flower@0.5.4","version":"0.5.4"}