Skip to content

Commit

Permalink
fix redundant set add
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Jul 17, 2024
1 parent 43a8742 commit e7ed3ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions types/native_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,17 @@ Type.std.Set.setJSInterface({
create_proxy: (value:Set<any>, pointer:Pointer) => {
// override methods
Object.defineProperty(value, "add", {value: el => {
return pointer.handleAdd(el);
if (value.has(el)) return false;
return pointer.handleAdd(el); // TODO: return the Set
}, writable:false, enumerable:false});

Object.defineProperty(value, "clear", {value: () => {
return pointer.handleClear();
}, writable:false, enumerable:false});

Object.defineProperty(value, "delete", {value: el => {
return pointer.handleRemove(el);
if (!value.has(el)) return false;
return pointer.handleRemove(el); // TODO: return the Set
}, writable:false, enumerable:false});

/**** override getters to trigger handleBeforeValueGet(): ****/
Expand Down

0 comments on commit e7ed3ff

Please sign in to comment.