it-multipart is a JavaScript library designed to parse HTTP multipart messages using async iterables. It provides a robust and modern approach to handling streaming data from HTTP requests, particularly useful for file uploads or complex form data. Currently at version 3.0.14, it is part of the broader `it` (InterPlanetary Stream) ecosystem, which emphasizes composable, stream-based utilities. The project demonstrates active maintenance, with frequent updates to various `it-*` packages within its monorepo, suggesting a stable and evolving codebase. Its key differentiator lies in its deep integration with JavaScript's async iterable protocol, making it highly efficient for non-blocking I/O operations and suitable for both Node.js server environments and potentially browser-side stream processing where async iterables are supported. It ships with TypeScript types, ensuring a better developer experience for TypeScript users.
npm install it-multipartVerified import paths — ran on the pinned version, not inferred.
This code demonstrates how to create an HTTP server that listens for POST requests with a 'multipart/form-data' content type, parses the incoming multipart message using `it-multipart`, and logs the headers and content of each part.
Ensure a `for await...of` loop or a similar consumption mechanism processes `part.body` completely for each `part` before the outer loop proceeds to the next `part`.
When using `multipart(req)`, ensure `req.headers['content-type']` is available and contains the boundary, or extract it manually and pass it as `multipart(req, boundary)`.
Embrace the async iterable pattern. Use `for await...of` loops to consume streams or leverage utilities from the `it-pipe` package for more complex stream compositions between async iterables.
Ensure you are using `import multipart from 'it-multipart'` in ESM modules. If using CommonJS, verify the environment's support for importing ESM default exports, or use `const multipart = require('it-multipart')` and test its functionality.Confirm that `part.body` is fully consumed for each part within its loop, and that the upstream HTTP request stream is correctly handled and not closed before all parts are processed.
No dependency data recorded yet.