Skip to content

Conversation

@Phillip9587
Copy link
Member

This change refactors the JSON parser to eliminate the per-request if (strict) conditional check from the parsing hot path.

Instead of checking strict mode during parsing, we now create specialized parser functions at middleware initialization based on the strict option.

I'm aware that this introduces some code duplication between the strict and non-strict parser implementations, but I think that is a necessary trade-off.

Refactor JSON parser creation to return specialized parser functions
based on strict mode setting, removing the per-request `if (strict)`
conditional check in the parsing hot path.
Copy link

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 refactors the JSON parser logic by extracting the parse function into a separate helper function createJsonParser. The refactoring improves code organization by separating parser creation from middleware setup, and fixes an incorrect JSDoc return type annotation.

Key Changes

  • Extracted inline parse function into a new createJsonParser helper function that returns the appropriate parser based on the strict option
  • Corrected JSDoc return type annotation for firstchar function from {function} to {string | undefined}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant