lib/unpack.js
function unpackQuestion(buf, offset) {
  var bytes = 0;
  var question = {};

  //  - variable length compressed question name
  var nbname = NBName.fromBuffer(buf, offset + bytes);
  if (nbname.error) {
    return {error: nbname.error};
  }

  question.nbname = nbname;
  bytes += nbname.bytesRead;

  // Ensure we have enough space left before proceeding to avoid throwing
  if (offset + bytes + 4 > buf.length) {
    return {
      error: new Error('Question section is too large to fit in remaining ' +
                       'packet bytes.')
    };
  }

  //  - 16-bit question type
  var t = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  question.type = con.QUESTION_TYPE_TO_STRING[t];
  if (question.type === undefined) {
    return {
      error: new Error('Unexpected question type [' + t + '] for name [' +
                       question.nbname + '];  should be either [nb] or ' +
                       '[nbstat]')
    };
  }

  //  - 16-bit question class
  var clazz = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  if (clazz !== con.CLASS_IN) {
    return {
      error: new Error('Unexpected question class [' + clazz +
                       '] for name [' + question.nbname + '];  should be [' +
                       CLASS_IN + ']')
    };
  }

  return {bytesRead: bytes, record: question};
}
function unpackQuestion(buf, offset) {
  var bytes = 0;
  var question = {};

  //  - variable length compressed question name
  var nbname = NBName.fromBuffer(buf, offset + bytes);
  if (nbname.error) {
    return {error: nbname.error};
  }

  question.nbname = nbname;
  bytes += nbname.bytesRead;

  // Ensure we have enough space left before proceeding to avoid throwing
  if (offset + bytes + 4 > buf.length) {
    return {
      error: new Error('Question section is too large to fit in remaining ' +
                       'packet bytes.')
    };
  }

  //  - 16-bit question type
  var t = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  question.type = con.QUESTION_TYPE_TO_STRING[t];
  if (question.type === undefined) {
    return {
      error: new Error('Unexpected question type [' + t + '] for name [' +
                       question.nbname + '];  should be either [nb] or ' +
                       '[nbstat]')
    };
  }

  //  - 16-bit question class
  var clazz = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  if (clazz !== con.CLASS_IN) {
    return {
      error: new Error('Unexpected question class [' + clazz +
                       '] for name [' + question.nbname + '];  should be [' +
                       CLASS_IN + ']')
    };
  }

  return {bytesRead: bytes, record: question};
}
function unpackQuestion ( buf , offset ) { var bytes = 0 ; var question = { } ; //  - variable length compressed question name var nbname = NBName . fromBuffer ( buf , offset + bytes ) ; if ( nbname . error ) { return { error : nbname . error } ; } question . nbname = nbname ; bytes += nbname . bytesRead ; // Ensure we have enough space left before proceeding to avoid throwing if ( offset + bytes + 4 > buf . length ) { return { error : new Error ( 'Question section is too large to fit in remaining ' + 'packet bytes.' ) } ; } //  - 16-bit question type var t = buf . readUInt16BE ( offset + bytes ) ; bytes += 2 ; question . type = con . QUESTION_TYPE_TO_STRING [ t ] ; if ( question . type === undefined ) { return { error : new Error ( 'Unexpected question type [' + t + '] for name [' + question . nbname + '];  should be either [nb] or ' + '[nbstat]' ) } ; } //  - 16-bit question class var clazz = buf . readUInt16BE ( offset + bytes ) ; bytes += 2 ; if ( clazz !== con . CLASS_IN ) { return { error : new Error ( 'Unexpected question class [' + clazz + '] for name [' + question . nbname + '];  should be [' + CLASS_IN + ']' ) } ; } return { bytesRead : bytes , record : question } ; }
Parse question section - variable length compressed question name - 16-bit question type - 16-bit question class
Parse question section - variable length compressed question name - 16 - bit question type - 16 - bit question class