Socket
Socket
Sign inDemoInstall

formidable

Package Overview
Dependencies
0
Maintainers
10
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-canary.20200129.32 to 2.0.0-canary.20200131.1

3

CHANGELOG.md

@@ -0,4 +1,3 @@

### Unreleased (`canary` & `dev` dist-tags)
### Unreleased (`formidable@canary` dist-tag)
* Test only on Node.js >= v10. Support only Node LTS and latest ([#515](https://github.com/node-formidable/node-formidable/pull/515))

@@ -5,0 +4,0 @@ * stop using deprecated features ([#516](https://github.com/node-formidable/node-formidable/pull/516), [#472](https://github.com/node-formidable/node-formidable/issues/472), [#406](https://github.com/node-formidable/node-formidable/issues/406))

{
"name": "formidable",
"version": "2.0.0-canary.20200129.32",
"version": "2.0.0-canary.20200131.1",
"license": "MIT",

@@ -18,6 +18,9 @@ "description": "A node.js module for parsing form data, especially file uploads.",

"scripts": {
"cleanup": "rm -rf test/tmp",
"fmt": "prettier '**/*.{md,js,json}' --write",
"lint": "eslint . --cache --fix --quiet --format codeframe",
"pretest": "yarn run cleanup && mkdir test/tmp",
"bench": "node benchmark",
"fmt": "yarn run fmt:prepare '**/*'",
"fmt:prepare": "prettier --write",
"lint": "yarn run lint:prepare .",
"lint:prepare": "eslint --cache --fix --quiet --format codeframe",
"reinstall": "rm -rf node_modules yarn.lock && yarn",
"pretest": "rm -rf test/tmp && mkdir test/tmp",
"test": "node test/run.js",

@@ -28,2 +31,4 @@ "pretest:ci": "yarn pretest",

"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@tunnckocore/prettier-config": "^1.2.0",

@@ -35,2 +40,5 @@ "eslint": "^6.8.0",

"eslint-plugin-prettier": "^3.1.2",
"husky": "^4.2.1",
"jest": "^25.1.0",
"lint-staged": "^10.0.6",
"nyc": "^15.0.0",

@@ -42,3 +50,22 @@ "prettier": "^1.19.1",

"utest": "^0.0.8"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"!*.{js,jsx,ts,tsx}": [
"yarn run fmt:prepare"
],
"*.{js,jsx,ts,tsx}": [
"yarn run lint"
]
}
}

@@ -16,16 +16,27 @@ <p align="center">

## Status: Maintained
## Status: Maintained [![npm version][npmv-canary-img]][npmv-url] [![npm version][npmv-dev-img]][npmv-url]
This module was initially developed by [**@felixge**](https://github.com/felixge) for [Transloadit](http://transloadit.com/), a service focused on uploading and encoding images and videos. It has been battle-tested against hundreds of GBs of file uploads from a large variety of clients and is considered production-ready and is used in production for years.
This module was initially developed by
[**@felixge**](https://github.com/felixge) for
[Transloadit](http://transloadit.com/), a service focused on uploading and
encoding images and videos. It has been battle-tested against hundreds of GBs of
file uploads from a large variety of clients and is considered production-ready
and is used in production for years.
Currently, we are few maintainers trying to deal with it. :) More contributors are always welcome! :heart:
Jump on [issue #412](https://github.com/felixge/node-formidable/issues/412) if you are interested.
Currently, we are few maintainers trying to deal with it. :) More contributors
are always welcome! :heart: Jump on
[issue #412](https://github.com/felixge/node-formidable/issues/412) if you are
interested.
_**Note:** Master is a "development" branch - try it with `npm i formidable@canary`.
Do not expect (for now) things from it to be inside the`latest`"dist-tag" in the Npm.
The`formidable@latest`is the`v1.2.1` version and probably it will be the last`v1` release!_
_**Note:** Master is a "canary" branch - try it with `npm i formidable@canary`.
Do not expect (for now) things from it to be inside the`latest`"dist-tag" in the
Npm. The`formidable@latest`is the`v1.2.1` version and probably it will be the
last`v1` release!_
_**Note: v2 is coming soon!**_
[![npm version][npmv-canary-img]][npmv-url]
You can try the
[Plugins API](https://github.com/felixge/node-formidable/tree/plugins-api)
([#545](https://github.com/felixge/node-formidable/pull/545)), which is
available through `formidable@dev`.

@@ -44,3 +55,3 @@ ## Highlights

npm install formidable
# or the development version
# or the canary version
npm install formidable@canary

@@ -53,12 +64,14 @@ ```

yarn add formidable
# or the development version
# or the canary version
yarn add formidable@canary
```
This is a low-level package, and if you're using a high-level framework it may already be included.
This is a low-level package, and if you're using a high-level framework it may
already be included.
However, [Express v4](http://expressjs.com) does not include any multipart handling, nor does [body-parser](https://github.com/expressjs/body-parser).
However, [Express v4](http://expressjs.com) does not include any multipart
handling, nor does [body-parser](https://github.com/expressjs/body-parser).
For `koa` there is [koa-better-body](https://ghub.now.sh/koa-better-body)
which can handle ANY type of body / form-data - JSON, urlencoded, multpart and so on.
For `koa` there is [koa-better-body](https://ghub.now.sh/koa-better-body) which
can handle ANY type of body / form-data - JSON, urlencoded, multpart and so on.
A new major release is coming there too.

@@ -108,5 +121,5 @@

The benchmark is quite old, from the old codebase. But maybe quite true though.
Previously the numbers was around ~500 mb/sec. Currently with moving to
the new Node.js Streams API it's faster. You can clearly see the differences
between the Node versions.
Previously the numbers was around ~500 mb/sec. Currently with moving to the new
Node.js Streams API it's faster. You can clearly see the differences between the
Node versions.

@@ -146,4 +159,4 @@ _Note: a lot better benchmarking could and should be done in future._

_Please pass [`options`](#options) to the function/constructor,
not by passing assigning them to the instance `form`_
_Please pass [`options`](#options) to the function/constructor, not by passing
assigning them to the instance `form`_

@@ -169,12 +182,27 @@ ```js

See it's defaults in [src/Formidable.js](./src/Formidable.js#L14-L22) (the `DEFAULT_OPTIONS` constant).
See it's defaults in [src/Formidable.js](./src/Formidable.js#L14-L22) (the
`DEFAULT_OPTIONS` constant).
- `options.encoding` **{string}** - default `'utf-8'`; sets encoding for incoming form fields,
- `options.uploadDir` **{string}** - default `os.tmpdir()`; the directory for placing file uploads in. You can move them later by using `fs.rename()`
- `options.keepExtensions` **{boolean}** - default `false`; to include the extensions of the original files or not
- `options.maxFieldsSize` **{number}** - default `20 * 1024 * 1024` (20mb); limit the amount of memory all fields together (except files) can allocate in bytes.
- `options.maxFieldsSize` **{number}** - default `200 * 1024 * 1024` (200mb); limit the size of uploaded file.
- `options.maxFields` **{number}** - default `1000`; limit the number of fields that the Querystring parser will decode, set 0 for unlimited
- `options.hash` **{boolean}** - default `false`; include checksums calculated for incoming files, set this to some hash algorithm, see [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options) for available algorithms
- `options.multiples` **{boolean}** - default `false`; when you call the `.parse` method, the `files` argument (of the callback) will contain arrays of files for inputs which submit multiple files using the HTML5 `multiple` attribute. Also, the `fields` argument will contain arrays of values for fields that have names ending with '[]'.
- `options.encoding` **{string}** - default `'utf-8'`; sets encoding for
incoming form fields,
- `options.uploadDir` **{string}** - default `os.tmpdir()`; the directory for
placing file uploads in. You can move them later by using `fs.rename()`
- `options.keepExtensions` **{boolean}** - default `false`; to include the
extensions of the original files or not
- `options.maxFileSize` **{number}** - default `200 * 1024 * 1024` (200mb);
limit the size of uploaded file.
- `options.maxFields` **{number}** - default `1000`; limit the number of fields
that the Querystring parser will decode, set 0 for unlimited
- `options.maxFieldsSize` **{number}** - default `20 * 1024 * 1024` (20mb);
limit the amount of memory all fields together (except files) can allocate in
bytes.
- `options.hash` **{boolean}** - default `false`; include checksums calculated
for incoming files, set this to some hash algorithm, see
[crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options)
for available algorithms
- `options.multiples` **{boolean}** - default `false`; when you call the
`.parse` method, the `files` argument (of the callback) will contain arrays of
files for inputs which submit multiple files using the HTML5 `multiple`
attribute. Also, the `fields` argument will contain arrays of values for
fields that have names ending with '[]'.

@@ -195,4 +223,4 @@ _**Note:** If this value is exceeded, an `'error'` event is emitted._

Parses an incoming Node.js `request` containing form data.
If `callback` is provided, all fields and files are collected and passed to the callback.
Parses an incoming Node.js `request` containing form data. If `callback` is
provided, all fields and files are collected and passed to the callback.

@@ -210,9 +238,14 @@ ```js

You may overwrite this method if you are interested in directly accessing the multipart stream. Doing so will disable any `'field'` / `'file'` events processing which would occur otherwise, making you fully responsible for handling the processing.
You may overwrite this method if you are interested in directly accessing the
multipart stream. Doing so will disable any `'field'` / `'file'` events
processing which would occur otherwise, making you fully responsible for
handling the processing.
In the example below, we listen on couple of events and direct them to the `data` listener,
so you can do whatever you choose there, based on whether its before the file been emitted,
the header value, the header name, on field, on file and etc.
In the example below, we listen on couple of events and direct them to the
`data` listener, so you can do whatever you choose there, based on whether its
before the file been emitted, the header value, the header name, on field, on
file and etc.
Or the other way could be to just override the `form.onPart` as it's shown a bit later.
Or the other way could be to just override the `form.onPart` as it's shown a bit
later.

@@ -267,5 +300,6 @@ ```js

If you want to use Formidable to only handle certain parts for you, you can do something similar.
Or see [#387](https://github.com/node-formidable/node-formidable/issues/387) for inspiration,
you can for example validate the mime-type.
If you want to use Formidable to only handle certain parts for you, you can do
something similar. Or see
[#387](https://github.com/node-formidable/node-formidable/issues/387) for
inspiration, you can for example validate the mime-type.

@@ -282,3 +316,4 @@ ```js

For example, force Formidable to be used only on non-file "parts" (i.e., html fields)
For example, force Formidable to be used only on non-file "parts" (i.e., html
fields)

@@ -328,4 +363,4 @@ ```js

This method returns a JSON-representation of the file, allowing you to
`JSON.stringify()` the file which is useful for logging and responding
to requests.
`JSON.stringify()` the file which is useful for logging and responding to
requests.

@@ -336,3 +371,4 @@ ### Events

Emitted after each incoming chunk of data that has been parsed. Can be used to roll your own progress bar.
Emitted after each incoming chunk of data that has been parsed. Can be used to
roll your own progress bar.

@@ -354,4 +390,4 @@ ```js

Emitted whenever a new file is detected in the upload stream. Use this event if
you want to stream the file to somewhere else while buffering the upload on
the file system.
you want to stream the file to somewhere else while buffering the upload on the
file system.

@@ -364,3 +400,4 @@ ```js

Emitted whenever a field / file pair has been received. `file` is an instance of `File`.
Emitted whenever a field / file pair has been received. `file` is an instance of
`File`.

@@ -373,3 +410,5 @@ ```js

Emitted when there is an error processing the incoming form. A request that experiences an error is automatically paused, you will have to manually call `request.resume()` if you want the request to continue firing `'data'` events.
Emitted when there is an error processing the incoming form. A request that
experiences an error is automatically paused, you will have to manually call
`request.resume()` if you want the request to continue firing `'data'` events.

@@ -382,3 +421,6 @@ ```js

Emitted when the request was aborted by the user. Right now this can be due to a 'timeout' or 'close' event on the socket. After this event is emitted, an `error` event will follow. In the future there will be a separate 'timeout' event (needs a change in the node core).
Emitted when the request was aborted by the user. Right now this can be due to a
'timeout' or 'close' event on the socket. After this event is emitted, an
`error` event will follow. In the future there will be a separate 'timeout'
event (needs a change in the node core).

@@ -391,3 +433,4 @@ ```js

Emitted when the entire request has been received, and all contained files have finished flushing to disk. This is a great place for you to send your response.
Emitted when the entire request has been received, and all contained files have
finished flushing to disk. This is a great place for you to send your response.

@@ -400,4 +443,7 @@ ```js

- [multipart-parser](http://github.com/FooBarWidget/multipart-parser): a C++ parser based on formidable
- [Ryan Dahl](http://twitter.com/ryah) for his work on [http-parser](http://github.com/ry/http-parser) which heavily inspired the initial `multipart_parser.js`.
- [multipart-parser](http://github.com/FooBarWidget/multipart-parser): a C++
parser based on formidable
- [Ryan Dahl](http://twitter.com/ryah) for his work on
[http-parser](http://github.com/ry/http-parser) which heavily inspired the
initial `multipart_parser.js`.

@@ -407,6 +453,8 @@ ## Contributing

If the documentation is unclear or has a typo, please click on the page's `Edit`
button (pencil icon) and suggest a correction. If you would like to help us fix a bug or add a new feature, please check our
button (pencil icon) and suggest a correction. If you would like to help us fix
a bug or add a new feature, please check our
[Contributing Guide](./CONTRIBUTING.md). Pull requests are welcome!
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Thanks goes to these wonderful people
([emoji key](https://allcontributors.org/docs/en/emoji-key)):

@@ -436,2 +484,4 @@ <!-- ALL-CONTRIBUTORS-LIST:START -->

<td align="center"><a href="https://github.com/gabipetrovay"><img src="https://avatars0.githubusercontent.com/u/1170398?v=4" width="100px;" alt=""/><br /><sub><b>Gabriel Petrovay</b></sub></a><br /><a href="https://github.com/node-formidable/node-formidable/issues?q=author%3Agabipetrovay" title="Bug reports">๐Ÿ›</a> <a href="https://github.com/node-formidable/node-formidable/commits?author=gabipetrovay" title="Code">๐Ÿ’ป</a></td>
<td align="center"><a href="https://github.com/Elzair"><img src="https://avatars0.githubusercontent.com/u/2352818?v=4" width="100px;" alt=""/><br /><sub><b>Philip Woods</b></sub></a><br /><a href="https://github.com/node-formidable/node-formidable/commits?author=Elzair" title="Code">๐Ÿ’ป</a> <a href="#ideas-Elzair" title="Ideas, Planning, & Feedback">๐Ÿค”</a></td>
<td align="center"><a href="https://github.com/dmolim"><img src="https://avatars2.githubusercontent.com/u/7090374?v=4" width="100px;" alt=""/><br /><sub><b>Dmitry Ivonin</b></sub></a><br /><a href="https://github.com/node-formidable/node-formidable/commits?author=dmolim" title="Documentation">๐Ÿ“–</a></td>
</tr>

@@ -442,2 +492,3 @@ </table>

<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -450,2 +501,3 @@

<!-- badges -->
<!-- prettier-ignore-start -->

@@ -459,2 +511,3 @@ [codestyle-url]: https://github.com/airbnb/javascript

[npmv-canary-img]: https://badgen.net/npm/v/formidable/canary?icon=npm
[npmv-dev-img]: https://badgen.net/npm/v/formidable/dev?icon=npm
[npmv-img]: https://badgen.net/npm/v/formidable?icon=npm

@@ -474,1 +527,3 @@ [npmv-url]: https://npmjs.com/package/formidable

[twitter-img]: https://badgen.net/twitter/follow/tunnckoCore?icon=twitter&color=1da1f2&cache=300
<!-- prettier-ignore-end -->

@@ -5,2 +5,5 @@ /* eslint-disable no-fallthrough */

/* eslint-disable no-underscore-dangle */
'use strict';
const { Transform } = require('stream');

@@ -7,0 +10,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc