🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@piadina/fetch-jsonl

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@piadina/fetch-jsonl

Stream and parse (**JSON Lines**)[https://jsonlines.org/] directly with fetch. Yields parsed JSON objects one line at a time.

Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Fetch Lines

Stream and parse (JSON Lines)[https://jsonlines.org/] directly with fetch. Yields parsed JSON objects one line at a time.

Install

npm install @piadina/fetch-jsonl

Usage

import fetchJSONLines from "@piadina/fetch-jsonl";

type Item = { id: number; name: string };

for await (const obj of fetchJSONLines<Item>("https://example.com/data.jsonl")) {
  console.log(obj.id, obj.name);
}

API

fetchJSONLines<T = unknown, TError extends Error = Error>(input: RequestInfo | URL, init?: RequestInit): AsyncGenerator<T>
  • T – type of parsed objects (default unknown)
  • TError – error type thrown on invalid JSON (default Error)
  • input – fetch input (URL or Request)
  • init – optional fetch init options

Returns an async generator that yields one parsed JSON object per line.

Example: Handling errors

try {
  for await (const obj of fetchJSONLines("https://example.com/data.jsonl")) {
    console.log(obj);
  }
} catch (err) {
  console.error("Invalid JSON line:", err);
}

Why JSON Lines?

  • Works well for streaming APIs and large datasets
  • You can start processing before the entire file downloads
  • Friendly for incremental logs, events, and messages

Keywords

jsonl

FAQs

Package last updated on 16 Sep 2025

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