Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multi-part-stream-parser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-part-stream-parser

Multi-part form data stream parser

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
127
decreased by-61.16%
Maintainers
1
Weekly downloads
 
Created
Source

Multi-Part-Stream-Parser

Parse multi-part form data streams

About

Multi-Part-Stream-Parser provides a capture mechanism for parsing multi-part encoded streams, allowing consumers to listen for each section (split by boundary) of a multi-part document.

Installation

Simply install by running npm install multi-part-stream-parser --save.

Compatible with NodeJS 18 and up.

Usage

Pass a readable stream of multi-part data to parseMultiPartStream:

import { ParseEvent, parseMultiPartStream } from "multi-part-stream-parser";

// ...

const stream = getMultiPartStream(); // get a stream somehow

const emitter = parseMultiPartStream(stream);
emitter.on(ParseEvent.SectionHeaders, (sectionName, headers) => {
    // sectionName is a string, or null of not specified
    // headers is an object containing lower-cased headers
});
emitter.on(ParseEvent.SectionContent, (sectionName, contentBuffer) => {
    // contentBuffer is a buffer that contains the full
    // contents of the section
});
emitter.on(ParseEvent.SectionContentStream, (sectionName, contentStream) => {
    // contentStream is a readable stream of the section
    // contents
});

// ...

// Cleanup
emitter.destroy();
await emitter.whenComplete();

Keywords

FAQs

Package last updated on 05 Apr 2024

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