Skip to content

luke358/last-lines

Repository files navigation

last-lines

Read the last N lines from a file without loading the entire file into memory.

Install

pnpm add last-lines

Usage

import { lastLines, lastLinesSync } from 'last-lines'

const recent = await lastLines('app.log', 10)
const recentSync = lastLinesSync('app.log', 10)

Both APIs return string[].

API

interface LastLinesOptions {
  chunkSize?: number
  encoding?: BufferEncoding
}

declare function lastLines(
  path: PathLike,
  count: number,
  options?: LastLinesOptions,
): Promise<string[]>

declare function lastLinesSync(
  path: PathLike,
  count: number,
  options?: LastLinesOptions,
): string[]

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors