Skip to content

Commit 565b04a

Browse files
jasnelltargos
authored andcommitted
net: add net.BlockList.isBlockList(value)
PR-URL: #56078 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: theanarkh <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent da354f4 commit 565b04a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

‎doc/api/net.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ added:
170170

171171
The list of rules added to the blocklist.
172172

173+
### `BlockList.isBlockList(value)`
174+
175+
<!-- YAML
176+
added: REPLACEME
177+
-->
178+
179+
*`value`{any} Any JS value
180+
* Returns `true` if the `value` is a `net.BlockList`.
181+
173182
## Class: `net.SocketAddress`
174183

175184
<!-- YAML

‎lib/internal/blocklist.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ class BlockList{
4343
this[kHandle][owner_symbol]=this;
4444
}
4545

46+
/**
47+
* Returns true if the value is a BlockList
48+
* @param{any} value
49+
* @returns{boolean}
50+
*/
51+
staticisBlockList(value){
52+
returnvalue?.[kHandle]!==undefined;
53+
}
54+
4655
[kInspect](depth,options){
4756
if(depth<0)
4857
returnthis;

‎test/parallel/test-blocklist.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,8 @@ const util = require('util');
282282
assert(!blocklist.check('1.1.1.2'));
283283
assert(!blocklist.check('2.3.4.5'));
284284
}
285+
286+
{
287+
assert(BlockList.isBlockList(newBlockList()));
288+
assert(!BlockList.isBlockList({}));
289+
}

0 commit comments

Comments
(0)