File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ export const create = () => {
5
5
const values = new Map ;
6
6
let uid = 0 ;
7
7
return {
8
+ /**
9
+ * Clear all references retained in the current heap.
10
+ */
11
+ clear : ( ) => {
12
+ ids . clear ( ) ;
13
+ values . clear ( ) ;
14
+ } ,
15
+
8
16
/**
9
17
* Remove by id or value any previously stored reference.
10
18
* @param {number | unknown } id the held value by id or the value itself.
@@ -48,5 +56,5 @@ export const create = () => {
48
56
} ;
49
57
50
58
// globally shared heap
51
- const { drop, get, hold } = create ( ) ;
52
- export { drop , get , hold } ;
59
+ const { clear , drop, get, hold } = create ( ) ;
60
+ export { clear , drop , get , hold } ;
Original file line number Diff line number Diff line change 1
- import { drop , get , hold } from '../esm/heap.js' ;
1
+ import { clear , drop , get , hold } from '../esm/heap.js' ;
2
2
import { assert , collect } from './utils.js' ;
3
3
4
4
let o = { } ;
@@ -25,3 +25,7 @@ assert(id !== hold(o), true);
25
25
assert ( drop ( o ) , true ) ;
26
26
assert ( drop ( o ) , false ) ;
27
27
assert ( drop ( id ) , false ) ;
28
+
29
+ hold ( o ) ;
30
+ clear ( ) ;
31
+ assert ( drop ( o ) , false ) ;
You can’t perform that action at this time.
0 commit comments