New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

textlinestream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlinestream

Split a Text Stream into a Line Stream, using the Stream API

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-3.22%
Maintainers
1
Weekly downloads
 
Created
Source

TextLineStream - Split WHATWG streams into lines

Transform a stream into a stream where each chunk is divided by a newline, be it \n or \r\n. \r can be enabled via the allowCR option.

Returning empty lines can be enabled using the returnEmptyLines option.

This is a slightly extended version of Deno's TextLineStream.

import { TextLineStream } from "textlinestream";
const res = await fetch("https://example.com");
const lines = res.body
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(new TextLineStream());

Installation

npm i textlinestream

NDJSON - Newline Delimited JSON

Each line may be transformed by specifying a mapper function (mapperFun) in the options argument.

import { TextLineStream } from "textlinestream";
const res = await fetch("https://example.com");
const lines = res.body
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(new TextLineStream({
    mapperFun: JSON.parse
  }));

for await (const obj of lines) {
  // where obj is a js object
} 

License

MIT

FAQs

Package last updated on 20 Jul 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc