Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # Lazy Streams
  2. > *Create streams lazily when they are read from or written to.*
  3. > `lazystream: 1.0.0` [![Build Status](https://travis-ci.org/jpommerening/node-lazystream.png?branch=master)](https://travis-ci.org/jpommerening/node-lazystream)
  4. ## Why?
  5. Sometimes you feel the itch to open *all the files* at once. You want to pass a bunch of streams around, so the consumer does not need to worry where the data comes from.
  6. From a software design point-of-view this sounds entirely reasonable. Then there is that neat little function `fs.createReadStream()` that opens a file and gives you a nice `fs.ReadStream` to pass around, so you use what the mighty creator deities of node bestowed upon you.
  7. > `Error: EMFILE, too many open files`
  8. > ─ *node*
  9. This package provides two classes based on the node's Streams3 API (courtesy of `readable-stream` to ensure a stable version).
  10. ## Class: lazystream.Readable
  11. A wrapper for readable streams. Extends [`stream.PassThrough`](http://nodejs.org/api/stream.html#stream_class_stream_passthrough).
  12. ### new lazystream.Readable(fn [, options])
  13. * `fn` *{Function}*
  14. The function that the lazy stream will call to obtain the stream to actually read from.
  15. * `options` *{Object}*
  16. Options for the underlying `PassThrough` stream, accessible by `fn`.
  17. Creates a new readable stream. Once the stream is accessed (for example when you call its `read()` method, or attach a `data`-event listener) the `fn` function is called with the outer `lazystream.Readable` instance bound to `this`.
  18. If you pass an `options` object to the constuctor, you can access it in your `fn` function.
  19. ```javascript
  20. new lazystream.Readable(function (options) {
  21. return fs.createReadStream('/dev/urandom');
  22. });
  23. ```
  24. ## Class: lazystream.Writable
  25. A wrapper for writable streams. Extends [`stream.PassThrough`](http://nodejs.org/api/stream.html#stream_class_stream_passthrough).
  26. ### new lazystream.Writable(fn [, options])
  27. * `fn` *{Function}*
  28. The function that the lazy stream will call to obtain the stream to actually write to.
  29. * `options` *{Object}*
  30. Options for the underlying `PassThrough` stream, accessible by `fn`.
  31. Creates a new writable stream. Just like the one above but for writable streams.
  32. ```javascript
  33. new lazystream.Writable(function () {
  34. return fs.createWriteStream('/dev/null');
  35. });
  36. ```
  37. ## Install
  38. ```console
  39. $ npm install lazystream --save
  40. lazystream@1.0.0 node_modules/lazystream
  41. └── readable-stream@2.0.5
  42. ```
  43. ## Changelog
  44. ### v1.0.0
  45. - [#2](https://github.com/jpommerening/node-lazystream/pull/2): [unconditionally](https://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html) use `readable-stream` _2.x_.
  46. ### v0.2.0
  47. - [#1](https://github.com/jpommerening/node-lazystream/pull/1): error events are now propagated
  48. ### v0.1.0
  49. - _(this was the first release)_
  50. ## Contributing
  51. Fork it, branch it, send me a pull request. We'll work out the rest together.
  52. ## Credits
  53. [Chris Talkington](https://github.com/ctalkington) and his [node-archiver](https://github.com/ctalkington/node-archiver) for providing a use-case.
  54. ## [License](LICENSE-MIT)
  55. Copyright (c) 2013 J. Pommerening, contributors.
  56. Permission is hereby granted, free of charge, to any person
  57. obtaining a copy of this software and associated documentation
  58. files (the "Software"), to deal in the Software without
  59. restriction, including without limitation the rights to use,
  60. copy, modify, merge, publish, distribute, sublicense, and/or sell
  61. copies of the Software, and to permit persons to whom the
  62. Software is furnished to do so, subject to the following
  63. conditions:
  64. The above copyright notice and this permission notice shall be
  65. included in all copies or substantial portions of the Software.
  66. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  67. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  68. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  69. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  70. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  71. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  72. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  73. OTHER DEALINGS IN THE SOFTWARE.