A Twitch.tv viewer reward and games system.
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.

31 lines
716 B

12 years ago
  1. var Types = require('../constants/types');
  2. module.exports = Field;
  3. function Field(options) {
  4. options = options || {};
  5. this.parser = options.parser;
  6. this.db = options.packet.db;
  7. this.table = options.packet.table;
  8. this.name = options.packet.name;
  9. this.type = typeToString(options.packet.type);
  10. this.length = options.packet.length;
  11. }
  12. Field.prototype.string = function () {
  13. return this.parser.parseLengthCodedString();
  14. };
  15. Field.prototype.buffer = function () {
  16. return this.parser.parseLengthCodedBuffer();
  17. };
  18. Field.prototype.geometry = function () {
  19. return this.parser.parseGeometryValue();
  20. };
  21. function typeToString(t) {
  22. for (var k in Types) {
  23. if (Types[k] == t) return k;
  24. }
  25. }