GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — net: add net.BlockList.isBlockList(value) · nodejs/node@ed7eab1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • net.md
  • lib/internal
    • blocklist.js
  • test/parallel
    • test-blocklist.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/net.md‎

Copy file name to clipboardExpand all lines: doc/api/net.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
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
Collapse file

‎lib/internal/blocklist.js‎

Copy file name to clipboardExpand all lines: lib/internal/blocklist.js
+9Lines 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+
static isBlockList(value) {
52+
return value?.[kHandle] !== undefined;
53+
}
54+
4655
[kInspect](depth, options) {
4756
if (depth < 0)
4857
return this;
Collapse file

‎test/parallel/test-blocklist.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-blocklist.js
+5Lines 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(new BlockList()));
288+
assert(!BlockList.isBlockList({}));
289+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.