mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-07-21 12:20:42 +08:00
Initial work on the server
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
var Types = require('../constants/types');
|
||||
|
||||
module.exports = Field;
|
||||
function Field(options) {
|
||||
options = options || {};
|
||||
|
||||
this.parser = options.parser;
|
||||
this.db = options.packet.db;
|
||||
this.table = options.packet.table;
|
||||
this.name = options.packet.name;
|
||||
this.type = typeToString(options.packet.type);
|
||||
this.length = options.packet.length;
|
||||
}
|
||||
|
||||
Field.prototype.string = function () {
|
||||
return this.parser.parseLengthCodedString();
|
||||
};
|
||||
|
||||
Field.prototype.buffer = function () {
|
||||
return this.parser.parseLengthCodedBuffer();
|
||||
};
|
||||
|
||||
Field.prototype.geometry = function () {
|
||||
return this.parser.parseGeometryValue();
|
||||
};
|
||||
|
||||
function typeToString(t) {
|
||||
for (var k in Types) {
|
||||
if (Types[k] == t) return k;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user