Tail a file in Deno

This module provides facility to tail a file in Deno.

Dependencies

This module uses a single dependency from Deno's standard library:

  • readStringDelim

Usage

To tail a file, import the Tail class & create a tail object by providing the file name.

import { Tail } from "https://deno.land/x/tail@1.0.1/mod.ts";

const tail = new Tail("/var/tmp/testFile.txt");

To start tailing, use the start API that returns an async iterable:

for await (const line of tail.start()) {
  //Process line
}

To stop tailing, use the stop API:

tail.stop();

Example

Here is a complete example:

import { Tail } from "https://deno.land/x/tail@1.0.1/mod.ts";

const tail = new Tail("/var/tmp/testFile.txt");
for await (const line of tail.start()) {
  console.log("Got a line:", line);
}