docs: function readTo(stream, needle, options) {
    const endOK = Boolean(options && (options.endOK || options.endOk));
    let needleForIndexOf;
    let needleLength;
    function until(result, chunk, ended) {
      if (ended) {
        return endOK ? (result ? result.length : 0) : -1;
      }
  
      if (Array.isArray(result)) {
        // objectMode.  Use strict equality, like Array.prototype.indexOf
        return chunk === needle ? result.length : -1;
      }
  
      // Calculate the length of the needle, as used by indexOf and perform the
      // type conversion done by indexOf once, to avoid converting on every call
      if (needleLength === undefined) {
        if (typeof result === 'string') {
          needleForIndexOf = String(needle);
          needleLength = needleForIndexOf.length;
        } else if (result instanceof Buffer) {
          if (typeof needle === 'number') {
            // buffertools requires a Buffer or string
            // buffer-indexof-polyfill converts number to Buffer on each call
            needleForIndexOf = result.indexOf ? needle
              : Buffer.from ? Buffer.from([needle])
                // eslint-disable-next-line no-buffer-constructor
                : new Buffer([needle]);
            needleLength = 1;
          } else if (typeof needle === 'string') {
            needleForIndexOf = needle;
            needleLength = Buffer.byteLength(needle);
          } else if (needle instanceof Buffer) {
            needleForIndexOf = needle;
            needleLength = needle.length;
          }
        }
  
        if (needleLength === undefined) {
          throw new TypeError(`Unsupported indexOf argument types: ${
            Object.prototype.toString.call(result)}.indexOf(${
            Object.prototype.toString.call(needle)})`);
        }
  
        // Buffer.prototype.indexOf returns -1 for 0-length string/Buffer.
        // To be consistent with string, we return 0.
        // Note:  If removing this check, remove + 1 from start calc when 0.
        if (needleLength === 0) {
          return 0;
        }
      }
  
      const start =
        Math.max((result.length - chunk.length - needleLength) + 1, 0);
      const needleIndex = result.indexOf(needleForIndexOf, start);
      if (needleIndex < 0) {
        return -1;
      }
  
      return needleIndex + needleLength;
    }
    return readInternal(stream, undefined, until, options);
  }