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.

WritableStream.js 730B

12345678910111213141516171819202122232425
  1. module.exports = Stream;
  2. var Parser = require("./Parser.js");
  3. var WritableStream = require("readable-stream").Writable;
  4. var StringDecoder = require("string_decoder").StringDecoder;
  5. var Buffer = require("buffer").Buffer;
  6. function Stream(cbs, options) {
  7. var parser = (this._parser = new Parser(cbs, options));
  8. var decoder = (this._decoder = new StringDecoder());
  9. WritableStream.call(this, { decodeStrings: false });
  10. this.once("finish", function() {
  11. parser.end(decoder.end());
  12. });
  13. }
  14. require("inherits")(Stream, WritableStream);
  15. Stream.prototype._write = function(chunk, encoding, cb) {
  16. if (chunk instanceof Buffer) chunk = this._decoder.write(chunk);
  17. this._parser.write(chunk);
  18. cb();
  19. };