New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

streaming-lines

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streaming-lines

Efficiently process text files line-by-line.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

streaming-lines

Build Status Requirements Status

Efficiently process text files line-by-line.

Streams are more efficient than reading an entire file into memory, especially when reading large files - some files are too large to do this. This package enables users to efficiently process large text files line-by-line.

NOTE: streaming-lines only handles utf-8 encode text.

Install

Install the package, including TypeScript declarations.

npm i streaming-lines

Use

Let's read from a file in the current directory and capitalize each line in the file.

Using JavaScript

const readlines = require('streaming-lines').readlines;

(async function () {
    await readlines(__dirname + '/myfile.txt', (line) => {
        line.toUpperCase();
    });
})

Using TypeScript

import { readlines } from 'streaming-lines';

(async function () {
    await readlines(__dirname + '/myfile.txt', (line: string) => {
        line.toUpperCase();
    });
})

Test

Tests can be found in the test/ directory. They can be run with the following command:

npm run test

Each file with a .test.ts extension will be executed using the mocha testing framework.

Keywords

stream

FAQs

Package last updated on 11 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts