Skip to content

feat(builtins): implement JsWeakMap safe wrapper#4738

Merged
jedel1043 merged 3 commits intoboa-dev:mainfrom
KaustubhOG:feat/js-weak-map-wrapper
Feb 27, 2026
Merged

feat(builtins): implement JsWeakMap safe wrapper#4738
jedel1043 merged 3 commits intoboa-dev:mainfrom
KaustubhOG:feat/js-weak-map-wrapper

Conversation

@KaustubhOG
Copy link
Copy Markdown
Contributor

Implements JsWeakMap as a safe Rust wrapper around the ECMAScript WeakMap builtin, as part of #2098.

Changes

  • core/engine/src/object/builtins/jsweakmap.rs — new JsWeakMap wrapper with all methods
  • core/engine/src/object/builtins/mod.rs — registered and re-exported JsWeakMap
  • examples/src/bin/jsweakmap.rs — usage example

Methods implemented

  • new — creates an empty WeakMap
  • get — retrieves value by key
  • set — inserts a key-value pair
  • has — checks key existence
  • delete — removes a key
  • get_or_insert — upsert with default value
  • get_or_insert_computed — upsert with callback
  • from_object — converts JsObject to JsWeakMap

Follows the same pattern as JsMap and JsSet.

Closes part of #2098

@KaustubhOG KaustubhOG requested a review from a team as a code owner February 26, 2026 10:26
@github-actions
Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,862 52,862 0
Passed 49,504 49,504 0
Ignored 2,262 2,262 0
Failed 1,096 1,096 0
Panics 0 0 0
Conformance 93.65% 93.65% 0.00%

Comment thread core/engine/src/object/builtins/jsweakmap.rs Outdated
Comment thread core/engine/src/object/builtins/jsweakmap.rs Outdated
@jedel1043 jedel1043 added C-Builtins PRs and Issues related to builtins/intrinsics A-API Changes related to public APIs Waiting On Author Waiting on PR changes from the author A-Enhancement New feature or request labels Feb 27, 2026
Copy link
Copy Markdown
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@jedel1043 jedel1043 enabled auto-merge February 27, 2026 22:44
@jedel1043 jedel1043 removed the Waiting On Author Waiting on PR changes from the author label Feb 27, 2026
@jedel1043 jedel1043 added this pull request to the merge queue Feb 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.23%. Comparing base (6ddc2b4) to head (57289e9).
⚠️ Report is 699 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/object/builtins/jsweakmap.rs 0.00% 39 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4738      +/-   ##
==========================================
+ Coverage   47.24%   57.23%   +9.99%     
==========================================
  Files         476      551      +75     
  Lines       46892    60466   +13574     
==========================================
+ Hits        22154    34610   +12456     
- Misses      24738    25856    +1118     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into boa-dev:main with commit 0d58601 Feb 27, 2026
19 checks passed
@KaustubhOG
Copy link
Copy Markdown
Contributor Author

KaustubhOG commented Feb 27, 2026

Hi @jedel1043! Thank you for the quick reviews and guidance on #4738 really appreciated the clear feedback.

github-merge-queue Bot pushed a commit that referenced this pull request Feb 28, 2026
Implements `JsWeakSet` as a safe Rust wrapper around the ECMAScript
`WeakSet` builtin, as part of #2098.

## Changes
- `core/engine/src/object/builtins/jsweakset.rs` — new `JsWeakSet`
wrapper with all methods
- `core/engine/src/object/builtins/mod.rs` — registered and re-exported
`JsWeakSet`
- `examples/src/bin/jsweakset.rs` — usage example

## Methods implemented
- `new` — creates an empty WeakSet
- `add` — adds an object to the set
- `has` — checks if an object exists
- `delete` — removes an object
- `from_object` — converts `JsObject` to `JsWeakSet`

Follows the same pattern as `JsWeakMap` (#4738) and `JsSet`.

Closes part of #2098
akash-R-A-J pushed a commit to akash-R-A-J/boa that referenced this pull request Mar 1, 2026
Implements `JsWeakMap` as a safe Rust wrapper around the ECMAScript
`WeakMap` builtin, as part of boa-dev#2098.

## Changes
- `core/engine/src/object/builtins/jsweakmap.rs` — new `JsWeakMap`
wrapper with all methods
- `core/engine/src/object/builtins/mod.rs` — registered and re-exported
`JsWeakMap`
- `examples/src/bin/jsweakmap.rs` — usage example

## Methods implemented
- `new` — creates an empty WeakMap
- `get` — retrieves value by key
- `set` — inserts a key-value pair
- `has` — checks key existence
- `delete` — removes a key
- `get_or_insert` — upsert with default value
- `get_or_insert_computed` — upsert with callback
- `from_object` — converts `JsObject` to `JsWeakMap`

Follows the same pattern as `JsMap` and `JsSet`.

Closes part of boa-dev#2098
akash-R-A-J pushed a commit to akash-R-A-J/boa that referenced this pull request Mar 1, 2026
Implements `JsWeakSet` as a safe Rust wrapper around the ECMAScript
`WeakSet` builtin, as part of boa-dev#2098.

## Changes
- `core/engine/src/object/builtins/jsweakset.rs` — new `JsWeakSet`
wrapper with all methods
- `core/engine/src/object/builtins/mod.rs` — registered and re-exported
`JsWeakSet`
- `examples/src/bin/jsweakset.rs` — usage example

## Methods implemented
- `new` — creates an empty WeakSet
- `add` — adds an object to the set
- `has` — checks if an object exists
- `delete` — removes an object
- `from_object` — converts `JsObject` to `JsWeakSet`

Follows the same pattern as `JsWeakMap` (boa-dev#4738) and `JsSet`.

Closes part of boa-dev#2098
ashddev pushed a commit to ashddev/boa that referenced this pull request Mar 2, 2026
Implements `JsWeakMap` as a safe Rust wrapper around the ECMAScript
`WeakMap` builtin, as part of boa-dev#2098.

## Changes
- `core/engine/src/object/builtins/jsweakmap.rs` — new `JsWeakMap`
wrapper with all methods
- `core/engine/src/object/builtins/mod.rs` — registered and re-exported
`JsWeakMap`
- `examples/src/bin/jsweakmap.rs` — usage example

## Methods implemented
- `new` — creates an empty WeakMap
- `get` — retrieves value by key
- `set` — inserts a key-value pair
- `has` — checks key existence
- `delete` — removes a key
- `get_or_insert` — upsert with default value
- `get_or_insert_computed` — upsert with callback
- `from_object` — converts `JsObject` to `JsWeakMap`

Follows the same pattern as `JsMap` and `JsSet`.

Closes part of boa-dev#2098
ashddev pushed a commit to ashddev/boa that referenced this pull request Mar 2, 2026
Implements `JsWeakSet` as a safe Rust wrapper around the ECMAScript
`WeakSet` builtin, as part of boa-dev#2098.

## Changes
- `core/engine/src/object/builtins/jsweakset.rs` — new `JsWeakSet`
wrapper with all methods
- `core/engine/src/object/builtins/mod.rs` — registered and re-exported
`JsWeakSet`
- `examples/src/bin/jsweakset.rs` — usage example

## Methods implemented
- `new` — creates an empty WeakSet
- `add` — adds an object to the set
- `has` — checks if an object exists
- `delete` — removes an object
- `from_object` — converts `JsObject` to `JsWeakSet`

Follows the same pattern as `JsWeakMap` (boa-dev#4738) and `JsSet`.

Closes part of boa-dev#2098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-API Changes related to public APIs A-Enhancement New feature or request C-Builtins PRs and Issues related to builtins/intrinsics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants