npm.io
5.0.0 • Published 3 months ago

first-line

Licence
MIT
Version
5.0.0
Deps
2
Size
6 kB
Vulns
0
Weekly
0
Stars
1

first-line

Get the first line of a file.

Example

import { firstLine } from 'first-line';
import { resolve } from 'node:path';

const file = resolve('fixture.txt');

const line = await firstLine(file);
console.log(line);
// => '1'

Installation

$ npm install first-line

API

import { firstLine } from 'first-line';
firstLine(file: string): Promise<string | null>

Reads the file at file and resolves with the first line as a string, or null if the file is empty or contains only newlines.

Keywords