Gathering detailed insights and metrics for @thenorthmemory/multipart
Gathering detailed insights and metrics for @thenorthmemory/multipart
Simple and lite of the multipart/form-data implementation.
npm install @thenorthmemory/multipart
Typescript
Module System
Min. Node Version
Node Version
NPM Version
72.2
Supply Chain
98.9
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
211
Last Day
2
Last Week
3
Last Month
7
Last Year
43
5 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
@thenorthmemory/multipart@1.0.0
Unpacked Size
30.27 kB
Size
6.17 kB
File Count
5
NPM Version
9.1.2
Node Version
16.18.1
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
0%
3
Compared to previous week
Last month
250%
7
Compared to previous month
Last year
-41.9%
43
Compared to previous year
Simple and lite of the multipart/form-data
implementation. Split from wechatpay-axios-plugin
project for general usages.
npm i @thenorthmemory/multipart
1import Multipart from '@thenorthmemory/multipart'; 2 3// buffer style(Synchronous) 4(new Multipart()) 5 .append('a', 1) 6 .append('b', '2') 7 .append('c', Buffer.from('31')) 8 .append('d', JSON.stringify({}), 'any.json') 9 .append('e', require('fs').readFileSync('/path/your/file.jpg'), 'file.jpg') 10 .getBuffer(); 11 12// stream style(Asynchronous) 13(new Multipart()) 14 .append('f', require('fs').createReadStream('/path/your/file2.jpg'), 'file2.jpg') 15 .pipe(require('fs').createWriteStream('./file3.jpg'));
Buffer
object.<string, string>
this
this
Array.<(Buffer|ReadStream)>
this
this
Buffer
| ReadStream
| undefined
Array.<(Buffer|ReadStream)>
boolean
Iterator.<Array.<EntryTuple.<(string|undefined), (Buffer|ReadStream)>>>
Iterator.<(string|undefined)>
Iterator.<(Buffer|ReadStream)>
string
Promise.<this>
stream.Writable
Create a multipart/form-data
buffer container for the media(image/video) file uploading.
Kind: instance property of Multipart
Access: protected
Properties
Name | Type | Description |
---|---|---|
mimeTypes | object.<string, string> | Built-in mime-type mapping |
Kind: instance property of Multipart
Read only: true
Properties
Name | Type | Description |
---|---|---|
boundary | Buffer | The boundary buffer. |
Kind: instance property of Multipart
Access: protected
Properties
Name | Type | Description |
---|---|---|
data | Array.<(Buffer|ReadStream)> | The Multipart's instance data storage |
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 |
Buffer
To retrieve the Miltipart#data buffer
Kind: instance method of Multipart
Returns: Buffer
- - The payload buffer
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
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
1.appendMimeTypes({p12: 'application/x-pkcs12'})
2.appendMimeTypes({txt: 'text/plain'})
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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.
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.
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.
string
Kind: instance method of Multipart
Returns: string
- - FormData string
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} |
stream.Writable
Attaches a Writable stream to the Multipart instance
No vulnerabilities found.
No security vulnerabilities found.