docs: def write_result_stream(result_stream, filename_prefix=None,
                          results_per_file=None, **kwargs):
      """
      Wraps a ``ResultStream`` object to save it to a file. This function will still
      return all data from the result stream as a generator that wraps the
      ``write_ndjson`` method.
  
      Args:
          result_stream (ResultStream): the unstarted ResultStream object
          filename_prefix (str or None): the base name for file writing
          results_per_file (int or None): the maximum number of tweets to write
          per file. Defaults to having no max, which means one file. Multiple
          files will be named by datetime, according to
          ``<prefix>_YYY-mm-ddTHH_MM_SS.json``.
  
      """
      if isinstance(result_stream, types.GeneratorType):
          stream = result_stream
      else:
          stream = result_stream.stream()
  
      file_time_formatter = "%Y-%m-%dT%H_%M_%S"
      if filename_prefix is None:
          filename_prefix = "twitter_search_results"
  
      if results_per_file:
          logger.info("chunking result stream to files with {} tweets per file"
                      .format(results_per_file))
          chunked_stream = partition(stream, results_per_file, pad_none=True)
          for chunk in chunked_stream:
              chunk = filter(lambda x: x is not None, chunk)
              curr_datetime = (datetime.datetime.utcnow()
                               .strftime(file_time_formatter))
              _filename = "{}_{}.json".format(filename_prefix, curr_datetime)
              yield from write_ndjson(_filename, chunk)
  
      else:
          curr_datetime = (datetime.datetime.utcnow()
                           .strftime(file_time_formatter))
          _filename = "{}.json".format(filename_prefix)
          yield from write_ndjson(_filename, stream)