0.6.0 • Published 12 years ago

flower v0.6.0

Weekly downloads
22
License
-
Repository
github
Last release
12 years ago

#flowers

flowers is a collection of stream helpers.

Installation

npm install flowers

##API documentation

flowers.relayReadStream()

Also available as javascript constructor at flowers.RelayReadStream()

Will return a ReadStream object there does except for relaying pipe output.

The main usercase is that you expose function there don't have a callback but returns a stream. However you have to do an async operation before createing the readstream, so you can't return the stream object directly.

exports.read = function () {
  var relay = flowers.relayReadStream();

  process.nextTick(function () {
    fs.createReadStream('file.txt').pipe(relay);
  });

  return relay;
};

flowers.buffer2stream(buffer, options)

Also available as javascript constructor at flowers.Buffer2stream()

Takes a buffer or string and splits it up intro chunks there is emitted in a ReadStream object.

The options object takes a chunkSize property there tell how big each chunk should be in bytes. By default this is 64 * 1024.

var stream = flowers.buffer2stream(buffer);

stream.pipe(fs.createWriteStream('file.txt'));
};

flowers.stream2buffer(stream, callback)

Takes a ReadStream and buffer it up until the stream is closed or an error occurred. The buffer is then send as a callback argument.

The callback have two arguments error and buffer.

The options object takes a chunkSize property there tell how big each chunk should be in bytes. By default this is 64 * 1024.

var stream = fs.createReadStream('file.txt');

flowers.stream2buffer(stream, function (error, buffer) {

});

##License

The software is license under "MIT"

Copyright (c) 2012 Andreas Madsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.6.0

12 years ago

0.5.5

12 years ago

0.5.4

12 years ago

0.5.3

12 years ago

0.5.2

12 years ago

0.5.1

12 years ago

0.5.0

12 years ago

0.4.2

12 years ago

0.4.1

12 years ago

0.4.0

12 years ago

0.3.1

12 years ago

0.3.0

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago