Skip to content

Conversation

Phillip9587
Copy link

This PR eliminates the concat-stream dependency by implementing a custom ConcatStream class within the memory storage module.

Changes
Moved concat-stream from dependencies to dev dependencies, implemented an internal ConcatStream class with enhanced buffer handling and modernized the code to ES6 class syntax.

Benefits
Removes unnecessary transitive dependencies from the production bundle:

  • readable-stream v3 - mirrors Node.js v10+ native stream implementation
  • buffer-from - polyfill for Buffer.from() (available since Node.js v5.10)
  • typedarray - TypedArray polyfill (native support since Node.js v0.10)

The custom implementation maintains full compatibility with the existing API while reducing the overall dependency footprint.

image

Replace external concat-stream with a simplified custom implementation without additional deps and convert
to ES6 classes
@coveralls
Copy link

Coverage Status

coverage: 96.786% (-1.7%) from 98.485%
when pulling 5d7510a on Phillip9587:memory-stream
into b6e4b1f on expressjs:main.

@Phillip9587 Phillip9587 requested a review from Copilot August 15, 2025 14:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the concat-stream dependency from production by implementing a custom ConcatStream class and modernizes the memory storage module with ES6 class syntax.

  • Eliminates transitive dependencies (readable-stream, buffer-from, typedarray) from the production bundle
  • Implements a custom ConcatStream class with enhanced buffer handling within the memory storage module
  • Modernizes code structure using ES6 classes instead of prototype-based patterns

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
storage/memory.js Replaces concat-stream with custom implementation and converts to ES6 classes
package.json Moves concat-stream from dependencies to devDependencies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

constructor (cb) {
super()
this.body = []
this.on('finish', function () {
Copy link
Preview

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback is invoked with this.getBody() but this context may not refer to the ConcatStream instance inside the 'finish' event handler. Use an arrow function or bind the context to ensure this refers to the ConcatStream instance.

Suggested change
this.on('finish', function () {
this.on('finish', () => {

Copilot uses AI. Check for mistakes.

@Phillip9587 Phillip9587 requested a review from LinusU August 18, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants