function MongooseBuffer(value, encode, offset) {
  let val = value;
  if (value == null) {
    val = 0;
  }

  let encoding;
  let path;
  let doc;

  if (Array.isArray(encode)) {
    // internal casting
    path = encode[0];
    doc = encode[1];
  } else {
    encoding = encode;
  }

  let buf;
  if (typeof val === 'number' || val instanceof Number) {
    buf = Buffer.alloc(val);
  } else { // string, array or object { type: 'Buffer', data: [...] }
    buf = Buffer.from(val, encoding, offset);
  }
  utils.decorate(buf, MongooseBuffer.mixin);
  buf.isMongooseBuffer = true;

  // make sure these internal props don't show up in Object.keys()
  buf[MongooseBuffer.pathSymbol] = path;
  buf[parentSymbol] = doc;

  buf._subtype = 0;
  return buf;
}
Mongoose Buffer constructor.

Values always have to be passed to the constructor to initialize.

@param {Buffer} value
@param {String} encode
@param {Number} offset
@api private
@inherits Buffer https://nodejs.org/api/buffer.html
@see https://bit.ly/f6CnZU