• Stream a File Chunk by Chunk (or Line by Line)

    Parameters

    • file: PathLike
    • Optional options: {
          slice?: {
              end?: number;
              start?: number;
          };
      }
      • Optional slice?: {
            end?: number;
            start?: number;
        }
        • Optional end?: number
        • Optional start?: number

    Returns AsyncIterable<Buffer> & {
        lines(): AsyncIterable<string, any, any>;
    }

    Example

    import { filesystem } from "@rjweb/utils"

    for await (const chunk of filesystem.stream('./file.txt')) {
    process.stdout.write(chunk.toString())
    }

    for await (const line of filesystem.stream('./file.txt').lines()) {
    console.log('Line: ', line)
    }

    Since

    1.9.0

    Supports

    nodejs