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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thenorthmemory/multipart

v1.0.0

Published

Simple and lite of the `multipart/form-data` implementation. No dependencies.

Readme

Multipart

Simple and lite of the multipart/form-data implementation. Split from wechatpay-axios-plugin project for general usages.

Usage

npm i @thenorthmemory/multipart

import Multipart from '@thenorthmemory/multipart';

// buffer style(Synchronous)
(new Multipart())
  .append('a', 1)
  .append('b', '2')
  .append('c', Buffer.from('31'))
  .append('d', JSON.stringify({}), 'any.json')
  .append('e', require('fs').readFileSync('/path/your/file.jpg'), 'file.jpg')
  .getBuffer();

// stream style(Asynchronous)
(new Multipart())
  .append('f', require('fs').createReadStream('/path/your/file2.jpg'), 'file2.jpg')
  .pipe(require('fs').createWriteStream('./file3.jpg'));

API

new Multipart()

Create a multipart/form-data buffer container for the media(image/video) file uploading.

multipart.mimeTypes

Kind: instance property of Multipart
Access: protected
Properties

| Name | Type | Description | | --- | --- | --- | | mimeTypes | object.<string, string> | Built-in mime-type mapping |

multipart.boundary

Kind: instance property of Multipart
Read only: true
Properties

| Name | Type | Description | | --- | --- | --- | | boundary | Buffer | The boundary buffer. |

multipart.data

Kind: instance property of Multipart
Access: protected
Properties

| Name | Type | Description | | --- | --- | --- | | data | Array.<(Buffer|ReadStream)> | The Multipart's instance data storage |

multipart.indices

Kind: instance property of Multipart
Access: protected
Properties

| Name | Type | Description | | --- | --- | --- | | indices | Array.<IndexTuple.<(string|undefined), number>> | The entities' value indices whose were in data |

multipart.getBuffer() ⇒ Buffer

To retrieve the Miltipart#data buffer

Kind: instance method of Multipart
Returns: Buffer - - The payload buffer

multipart.getHeaders() ⇒ object.<string, string>

To retrieve the Content-Type multipart/form-data header

Kind: instance method of Multipart
Returns: object.<string, string> - - The Content-Type header With boundary

multipart.appendMimeTypes(things) ⇒ this

Append a customized Multipart#mimeType

Kind: instance method of Multipart
Returns: this - - The Multipart class instance self

| Param | Type | Description | | --- | --- | --- | | things | object.<string, string> | The mime-type |

Example

.appendMimeTypes({p12: 'application/x-pkcs12'})
.appendMimeTypes({txt: 'text/plain'})

multipart.append(name, value, [filename]) ⇒ this

Append data wrapped by boundary

Kind: instance method of Multipart
Returns: this - - The Multipart class instance self

| Param | Type | Description | | --- | --- | --- | | name | string | The field name | | value | string | Buffer | ReadStream | The value | | [filename] | string | Optional filename, when provided, then append the Content-Type after of the Content-Disposition |

multipart.formed(name, value, [filename]) ⇒ Array.<(Buffer|ReadStream)>

Formed a named value, a filename reported to the server, when a Buffer or FileStream is passed as the second parameter.

Kind: instance method of Multipart
Returns: Array.<(Buffer|ReadStream)> - - The part of data

| Param | Type | Description | | --- | --- | --- | | name | string | The field name | | value | string | Buffer | ReadStream | The value | | [filename] | string | Optional filename, when provided, then append the Content-Type after of the Content-Disposition |

multipart.set(name, value, [filename]) ⇒ this

Sets a new value for an existing key inside a data instance, or adds the key/value if it does not already exist.

Kind: instance method of Multipart
Returns: this - - The Multipart instance

| Param | Type | Description | | --- | --- | --- | | name | string | The field name | | value | string | Buffer | ReadStream | The value | | [filename] | string | Optional filename, when provided, then append the Content-Type after of the Content-Disposition |

multipart.delete(name) ⇒ this

Deletes a key and its value(s) from a data instance

Kind: instance method of Multipart
Returns: this - - The Multipart instance

| Param | Type | Description | | --- | --- | --- | | name | string | The field name |

multipart.get(name) ⇒ Buffer | ReadStream | undefined

Returns the first value associated with a given key from within a data instance

Kind: instance method of Multipart
Returns: Buffer | ReadStream | undefined - value - The value, undefined means none named key exists

| Param | Type | Description | | --- | --- | --- | | name | string | The field name |

multipart.getAll(name) ⇒ Array.<(Buffer|ReadStream)>

Returns all values associated with a given key from within a data instance

Kind: instance method of Multipart
Returns: Array.<(Buffer|ReadStream)> - value(s) - The value(s)

| Param | Type | Description | | --- | --- | --- | | name | string | The field name |

multipart.has(name) ⇒ boolean

Returns a boolean stating whether a data instance contains a certain key.

Kind: instance method of Multipart
Returns: boolean - - True for contains

| Param | Type | Description | | --- | --- | --- | | name | string | The field name |

multipart.entries() ⇒ Iterator.<Array.<EntryTuple.<(string|undefined), (Buffer|ReadStream)>>>

To go through all key/value pairs contained in this data instance

Kind: instance method of Multipart
Returns: Iterator.<Array.<EntryTuple.<(string|undefined), (Buffer|ReadStream)>>> - - An Array Iterator key/value pairs.

multipart.keys() ⇒ Iterator.<(string|undefined)>

To go through all keys contained in data instance

Kind: instance method of Multipart
Returns: Iterator.<(string|undefined)> - - An Array Iterator key pairs.

multipart.values() ⇒ Iterator.<(Buffer|ReadStream)>

To go through all values contained in data instance

Kind: instance method of Multipart
Returns: Iterator.<(Buffer|ReadStream)> - - An Array Iterator value pairs.

multipart.toString() ⇒ string

Kind: instance method of Multipart
Returns: string - - FormData string

multipart.flowing([end]) ⇒ Promise.<this>

Pushing data into the readable BufferList

Kind: instance method of Multipart
Returns: Promise.<this> - - The Multipart instance

| Param | Type | Default | Description | | --- | --- | --- | --- | | [end] | boolean | true | End the writer when the reader ends. Default: true. Available {@since v0.8.0} |

multipart.pipe(destination, [options]) ⇒ stream.Writable

Attaches a Writable stream to the Multipart instance

License

MIT