Skip to content

feat(bindings): Enhance existing parse function to accept both string and buffer types #9876 #10371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025

Conversation

blueavee
Copy link
Contributor

@blueavee blueavee commented Apr 13, 2025

  • Enhanced existing parse and parseSync functions to accept both string and Buffer inputs.
  • Updated TypeScript definitions and JavaScript bindings to reflect the new input types.
  • Improved tests to cover the new capabilities for parsing from both string and Buffer inputs.

Fixes: #9876

@blueavee blueavee requested review from a team as code owners April 13, 2025 11:34
Copy link

changeset-bot bot commented Apr 13, 2025

⚠️ No Changeset found

Latest commit: fc262c3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@blueavee blueavee marked this pull request as draft April 13, 2025 11:34
Copy link

socket-security bot commented Apr 13, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@blueavee blueavee force-pushed the parse-buffer-support branch from 7fea2c2 to 4dae700 Compare April 13, 2025 11:41
@blueavee blueavee changed the title feat(parser): Add buffer parsing functions for async and sync operations #9876 feat(bindings): Add buffer parsing functions for async and sync operations #9876 Apr 13, 2025
@blueavee blueavee marked this pull request as ready for review April 13, 2025 12:37
@blueavee blueavee marked this pull request as draft April 14, 2025 03:19
… to accept `Buffer` or `string` as input types

- Introduced a new `stringify` function to handle conversion between `Buffer` and `string`.
- Updated type definitions in `binding.d.ts` to reflect the changes in function signatures.
- Added tests for asynchronous and synchronous parsing with `Buffer` input.
@blueavee blueavee force-pushed the parse-buffer-support branch from 56272c1 to 258d648 Compare April 14, 2025 04:54
@blueavee blueavee changed the title feat(bindings): Add buffer parsing functions for async and sync operations #9876 feat(bindings): Enhance existing parse function to accept both string and buffer types #9876 Apr 14, 2025
@blueavee blueavee marked this pull request as ready for review April 14, 2025 05:25
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

to_string() always allocates, while into_owned allocates only if necessary.

In this case it would be mostly the same but just for consistency

@kdy1 kdy1 self-assigned this Apr 14, 2025
@kdy1 kdy1 added this to the Planned milestone Apr 14, 2025
Copy link

codspeed-hq bot commented Apr 14, 2025

CodSpeed Performance Report

Merging #10371 will degrade performances by 2.73%

Comparing blueavee:parse-buffer-support (fc262c3) with main (e12ae1c)

Summary

❌ 1 regressions
✅ 151 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
es/lints/libs/d3 27.9 ms 28.7 ms -2.73%

@kdy1 kdy1 merged commit c9a2afc into swc-project:main Apr 14, 2025
166 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.11.22 Apr 23, 2025
@swc-project swc-project locked as resolved and limited conversation to collaborators May 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

@swc/core additional binding contracts that accept and receive utf8 data as JsBuffer instead of String
2 participants