code: function toParameter(value, encoding) {
    let type = Types.VAR_STRING;
    let length;
    let writer = function(value) {
      // eslint-disable-next-line no-invalid-this
      return Packet.prototype.writeLengthCodedString.call(this, value, encoding);
    };
    if (value !== null) {
      switch (typeof value) {
        case 'undefined':
          throw new TypeError('Bind parameters must not contain undefined');
  
        case 'number':
          type = Types.DOUBLE;
          length = 8;
          writer = Packet.prototype.writeDouble;
          break;
  
        case 'boolean':
          value = value | 0;
          type = Types.TINY;
          length = 1;
          writer = Packet.prototype.writeInt8;
          break;
  
        case 'object':
          if (Object.prototype.toString.call(value) === '[object Date]') {
            type = Types.DATETIME;
            length = 12;
            writer = Packet.prototype.writeDate;
          } else if (isJSON(value)) {
            value = JSON.stringify(value);
            type = Types.JSON;
          } else if (Buffer.isBuffer(value)) {
            length = Packet.lengthCodedNumberLength(value.length) + value.length;
            writer = Packet.prototype.writeLengthCodedBuffer;
          }
          break;
  
        default:
          value = value.toString();
      }
    } else {
      value = '';
      type = Types.NULL;
    }
    if (!length) {
      length = Packet.lengthCodedStringLength(value, encoding);
    }
    return { value, type, length, writer };
  }
docs: Converts a value to an object describing type, String/Buffer representation and length
  @param {*} value