Read a jBinary type at an offset in the buffer specified by another field.
function typeAtOffset(baseType: any, offsetFieldName: string): any {
  return jBinary.Template({
      baseType: baseType,
      read: function(context) {
        if (+context[offsetFieldName] === 0) {
          return null;
        } else {
          return this.binary.read(this.baseType, +context[offsetFieldName]);
        }
      }
    });
}