npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

readeof

v1.1.0

Published

A high-performance, memory-efficient library to read large files backward (line-by-line). Optimized for Node.js and Bun log parsing.

Readme

ReadEOF

A high-performance, memory-efficient library to read large files backward (line-by-line). Zero dependencies.

Features

  • Fast file reading from the end without loading entire file into memory
  • Memory efficient using configurable buffer sizes
  • Supports various encodings
  • Real-time file tailing (like tail -f) with streaming support
  • Automatic handling of file truncation/rotation

Installation

npm install readeof

Usage

Basic Example

import { readeof } from 'readeof';

// Read last 10 lines from log file
const lastLines = await readeof('/var/log/app.log', 10);
console.log(lastLines);

Reading Recent Logs

import { readeof } from 'readeof';

// Read last 50 lines for debugging
const recentLogs = await readeof('./app.log', 50);
console.log(recentLogs);

Custom Encoding

import { readeof } from 'readeof';

// Read file with latin1 encoding
const content = await readeof('./data.txt', 20, { encoding: 'latin1' });

Custom Buffer Size

import { readeof } from 'readeof';

// Use 64KB buffer for very large files
const content = await readeof('./huge-log.log', 100, {
  encoding: 'utf8',
  bufferSize: 64 * 1024,
});

Real-time Log Streaming (tail -f)

Stream new lines as they are appended to the file. First reads the last N lines, then continues watching for new content.

import { readeof } from 'readeof';

// Stream with AbortController for manual control
const controller = new AbortController();

for await (const line of readeof('/var/log/app.log', 10, {
  enabled: true,
  signal: controller.signal,
})) {
  console.log(line);

  // Stop streaming when needed
  if (line.includes('SHUTDOWN')) {
    controller.abort();
  }
}

Streaming with Timeout

import { readeof } from 'readeof';

// Stream for 30 seconds then stop automatically
for await (const line of readeof('/var/log/app.log', 10, {
  enabled: true,
  signal: AbortSignal.timeout(30_000),
})) {
  console.log(line);
}

Streaming with Custom Poll Interval

import { readeof } from 'readeof';

// Check for new content every 500ms instead of default 1000ms
for await (const line of readeof('/var/log/app.log', 10, {
  enabled: true,
  pollInterval: 500,
  signal: AbortSignal.timeout(60_000),
})) {
  console.log(line);
}

Error Analysis

import { readeof } from 'readeof';

async function findRecentErrors(logPath: string) {
  const recentLogs = await readeof(logPath, 1000);
  const errors = recentLogs
    .split('\n')
    .filter(line => line.includes('ERROR'));
  
  console.log(`Found ${errors.length} errors in last 1000 lines`);
}

API Reference

readeof(filePath, maxLines, options?)

Reads the last N lines from a file efficiently.

Parameters

| Parameter | Type | Description | |-----------|------|-------------| | filePath | string | Path to the file to read from | | maxLines | number | Total lines to read from the end of the file | | options | ReadOptions \| StreamOptions | Optional configuration options |

ReadOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | encoding | BufferEncoding | 'utf8' | File encoding | | bufferSize | number | 16384 | Buffer size for reading (16KB) |

StreamOptions (extends ReadOptions)

| Option | Type | Default | Description | |--------|------|---------|-------------| | enabled | boolean | - | Enable streaming mode | | pollInterval | number | 1000 | Polling interval in milliseconds | | signal | AbortSignal | - | Signal to stop streaming |

Returns

  • Without streaming: Promise<string> - The last N lines as a single string
  • With streaming: AsyncGenerator<string> - Yields each line as it appears

License

See LICENSE file for details.

Author

Ashary Vermaysha ([email protected])