22
33const {
44 Boolean,
5+ ObjectSetPrototypeOf,
56 Symbol
67} = primordials ;
78
@@ -14,6 +15,13 @@ const {
1415const {
1516 customInspectSymbol : kInspect ,
1617} = require ( 'internal/util' ) ;
18+
19+ const {
20+ JSTransferable,
21+ kClone,
22+ kDeserialize,
23+ } = require ( 'internal/worker/js_transferable' ) ;
24+
1725const { inspect } = require ( 'internal/util/inspect' ) ;
1826
1927const kHandle = Symbol ( 'kHandle' ) ;
@@ -26,14 +34,10 @@ const {
2634
2735const { validateInt32 } = require ( 'internal/validators' ) ;
2836
29- class BlockList {
30- constructor ( handle = new BlockListHandle ( ) ) {
31- // The handle argument is an intentionally undocumented
32- // internal API. User code will not be able to create
33- // a BlockListHandle object directly.
34- if ( ! ( handle instanceof BlockListHandle ) )
35- throw new ERR_INVALID_ARG_TYPE ( 'handle' , 'BlockListHandle' , handle ) ;
36- this [ kHandle ] = handle ;
37+ class BlockList extends JSTransferable {
38+ constructor ( ) {
39+ super ( ) ;
40+ this [ kHandle ] = new BlockListHandle ( ) ;
3741 this [ kHandle ] [ owner_symbol ] = this ;
3842 }
3943
@@ -116,6 +120,34 @@ class BlockList {
116120 get rules ( ) {
117121 return this [ kHandle ] . getRules ( ) ;
118122 }
123+
124+ [ kClone ] ( ) {
125+ const handle = this [ kHandle ] ;
126+ return {
127+ data : { handle } ,
128+ deserializeInfo : 'internal/blocklist:InternalBlockList' ,
129+ } ;
130+ }
131+
132+ [ kDeserialize ] ( { handle } ) {
133+ this [ kHandle ] = handle ;
134+ this [ kHandle ] [ owner_symbol ] = this ;
135+ }
136+ }
137+
138+ class InternalBlockList extends JSTransferable {
139+ constructor ( handle ) {
140+ super ( ) ;
141+ this [ kHandle ] = handle ;
142+ if ( handle !== undefined )
143+ handle [ owner_symbol ] = this ;
144+ }
119145}
120146
121- module . exports = BlockList ;
147+ InternalBlockList . prototype . constructor = BlockList . prototype . constructor ;
148+ ObjectSetPrototypeOf ( InternalBlockList . prototype , BlockList . prototype ) ;
149+
150+ module . exports = {
151+ BlockList,
152+ InternalBlockList,
153+ } ;
0 commit comments