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;
  }
}

var Types = require('../constants/types');

module.exports = Field;
function Field(options) {
  options = options || {};

  this.parser = options.parser;
  this.packet = options.packet;
  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;
  }
}

Allow access to the packet object
Allow access to the packet object

I'm trying to use some field packet information in my custom "typeCast" function, but right now the Field object don't have access to it.

"RowDataPacket.prototype._typeCast" function have access to it, and I need to check the field "charsetNr" property in my custom "typeCast" function but I can't because I don't have access to it.