npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

multipart-raw-parser-legacy

v1.0.1

Published

[![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![coverages][coverage-image]][coverage-url] [![downloads][downloads-image]][downloads-url] [![Commitizen friendly][cf-image]][cf-url] [![semantic-release][sm-image]][sm-url]

Downloads

4

Readme

Multipart Raw Parser

travis npm coverages downloads Commitizen friendly semantic-release

The multipart raw parser is a helper function to parse a multipart/whatever Content-Type from any HttpRequest response.

Installation

Install the npm module:

  $ npm install multipart-raw-parser --save

Documentation

Arguments

  • contentType: The response header Content-Type.
  • body: The response body as a string containing all multipart data parts.

A multipart/whatever response is composed for each content of a boundary identifier, headers and contents:

--uuid:2e6eb930-a6da-43e2-850c-ce98e3bbdb16
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    ...
  </soap:Body>
</soap:Envelope>

--uuid:2e6eb930-a6da-43e2-850c-ce98e3bbdb16
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

sdbjkcndsjkvbdjs...

NOTE: The function will not process any form which do not contain a boundary identifier (--id:...).

Returns

An array of objects composed of an index representing the position of the part in the body parameters, the part value and a array of object containing parsed headers.

Example

Here is a simple way to use the library:

import fetch from 'fetch'
import { parse } from 'multipart-raw-parser'

try {
  const response = await fetch('https://wh.at/raw')
  const multipartDataArray = parse(response, response.headers.get('Content-Type'))
  console.log(multipartDataArray)
  // [...{
  //    index: 1,
  //    headers: [{
  //      name: 'Content-Type',
  //      value: 'application/octet-stream'
  //    }, ...],
  //    value: 'sdbjkcndsjkvbdjs...'
  // }]
} catch (e) {
  throw (e)
}

Development

To run the function locally:

npm install
npm run dev

Keep CI tests passing by running npm run test or npm run test:watch and npm run lint often.

Change Log

This project adheres to Semantic Versioning.

You can find every release documented on the Releases page.

License

MIT