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 — util: improve empty typed array inspection · nodejs/node@3dc3a31

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • util.js
  • test/parallel
    • test-util-inspect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/util.js‎

Copy file name to clipboardExpand all lines: lib/util.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ function formatValue(ctx, value, recurseTimes) {
625625
formatter = formatMap;
626626
} else if (isTypedArray(value)) {
627627
braces = [`${getPrefix(constructor, tag)}[`, ']'];
628+
if (value.length === 0 && keyLength === 0 && !ctx.showHidden)
629+
return `${braces[0]}]`;
628630
formatter = formatTypedArray;
629631
} else if (isMapIterator(value)) {
630632
braces = [`[${tag}] {`, '}'];
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': 2 } } }, false, 1),
7979
'{ a: { b: [Object] } }');
8080
assert.strictEqual(util.inspect({ 'a': { 'b': ['c'] } }, false, 1),
8181
'{ a: { b: [Array] } }');
82-
assert.strictEqual(util.inspect(new Uint8Array(0)), 'Uint8Array [ ]');
82+
assert.strictEqual(util.inspect(new Uint8Array(0)), 'Uint8Array []');
83+
assert(inspect(new Uint8Array(0), { showHidden: true }).includes('[buffer]'));
8384
assert.strictEqual(
8485
util.inspect(
8586
Object.create(

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.