2
2
3
3
const {
4
4
Boolean,
5
+ ObjectSetPrototypeOf,
5
6
Symbol
6
7
} = primordials ;
7
8
@@ -14,6 +15,13 @@ const {
14
15
const {
15
16
customInspectSymbol : kInspect ,
16
17
} = require ( 'internal/util' ) ;
18
+
19
+ const {
20
+ JSTransferable,
21
+ kClone,
22
+ kDeserialize,
23
+ } = require ( 'internal/worker/js_transferable' ) ;
24
+
17
25
const { inspect } = require ( 'internal/util/inspect' ) ;
18
26
19
27
const kHandle = Symbol ( 'kHandle' ) ;
@@ -26,14 +34,10 @@ const {
26
34
27
35
const { validateInt32 } = require ( 'internal/validators' ) ;
28
36
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 ( ) ;
37
41
this [ kHandle ] [ owner_symbol ] = this ;
38
42
}
39
43
@@ -116,6 +120,34 @@ class BlockList {
116
120
get rules ( ) {
117
121
return this [ kHandle ] . getRules ( ) ;
118
122
}
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
+ }
119
145
}
120
146
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