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 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # BSER Binary Serialization
  2. BSER is a binary serialization scheme that can be used as an alternative to JSON.
  3. BSER uses a framed encoding that makes it simpler to use to stream a sequence of
  4. encoded values.
  5. It is intended to be used for local-IPC only and strings are represented as binary
  6. with no specific encoding; this matches the convention employed by most operating
  7. system filename storage.
  8. For more details about the serialization scheme see
  9. [Watchman's docs](https://facebook.github.io/watchman/docs/bser.html).
  10. ## API
  11. ```js
  12. var bser = require('bser');
  13. ```
  14. ### bser.loadFromBuffer
  15. The is the synchronous decoder; given an input string or buffer,
  16. decodes a single value and returns it. Throws an error if the
  17. input is invalid.
  18. ```js
  19. var obj = bser.loadFromBuffer(buf);
  20. ```
  21. ### bser.dumpToBuffer
  22. Synchronously encodes a value as BSER.
  23. ```js
  24. var encoded = bser.dumpToBuffer(['hello']);
  25. console.log(bser.loadFromBuffer(encoded)); // ['hello']
  26. ```
  27. ### BunserBuf
  28. The asynchronous decoder API is implemented in the BunserBuf object.
  29. You may incrementally append data to this object and it will emit the
  30. decoded values via its `value` event.
  31. ```js
  32. var bunser = new bser.BunserBuf();
  33. bunser.on('value', function(obj) {
  34. console.log(obj);
  35. });
  36. ```
  37. Then in your socket `data` event:
  38. ```js
  39. bunser.append(buf);
  40. ```
  41. ## Example
  42. Read BSER from socket:
  43. ```js
  44. var bunser = new bser.BunserBuf();
  45. bunser.on('value', function(obj) {
  46. console.log('data from socket', obj);
  47. });
  48. var socket = net.connect('/socket');
  49. socket.on('data', function(buf) {
  50. bunser.append(buf);
  51. });
  52. ```
  53. Write BSER to socket:
  54. ```js
  55. socket.write(bser.dumpToBuffer(obj));
  56. ```