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 — errors: improve classRegExp in errors.js · nodejs/node@142e256

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/error
    • error-class-reg-exp.js
  • lib/internal
    • errors.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/error/error-class-reg-exp.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
5+
const bench = common.createBenchmark(main, {
6+
n: [1e5],
7+
}, {
8+
flags: ['--expose-internals'],
9+
});
10+
11+
const instances = Array.from({ length: 1000 }).map(() => 'Uint8Array');
12+
13+
function main({ n }) {
14+
const {
15+
codes: {
16+
ERR_INVALID_ARG_TYPE,
17+
},
18+
} = require('internal/errors');
19+
bench.start();
20+
for (let i = 0; i < n; ++i)
21+
new ERR_INVALID_ARG_TYPE('target', instances, 'test');
22+
bench.end(n);
23+
}
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const isWindows = process.platform === 'win32';
6666
const messages = new SafeMap();
6767
const codes = {};
6868

69-
const classRegExp = /^([A-Z][a-z0-9]*)+$/;
69+
const classRegExp = /^[A-Z][a-zA-Z0-9]*$/;
70+
7071
// Sorted by a rough estimate on most frequently used entries.
7172
const kTypes = [
7273
'string',

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.