code: function packVector(vector, includeMetadata) {
    includeMetadata = isUndefined(includeMetadata) ? true : includeMetadata;
    var dtype = vector.dtype;
    if (vector.dtype === 'date') {
      vector = vector.toDtype('number');
    }
    var values = (vector.dtype !== 'number') ?
      vector.values.slice() :
      vector.values.map(function(x) {
        return Number.isNaN(x) ? null : x;
      });
  
    var result = {dtype: dtype, values: values};
    if (includeMetadata) {
      result.version = jd.version;
      result.type = vectorProto.type;
    }
    return result;
  }
docs: Helper for packing the given vector, including metadata by default