Common helper for emitting all three object shapes
function emitObject() {
    var body = bodec.join(parts);
    if (body.length !== length) {
      throw new Error("Body length mismatch");
    }
    var item = {
      type: numToType[type],
      size: length,
      body: body,
      offset: start
    };
    if (ref) item.ref = ref;
    parts.length = 0;
    start = 0;
    offset = 0;
    type = 0;
    length = 0;
    ref = null;
    emit(item);
  }