Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d07217

Browse filesBrowse files
committed
buffer: alias UInt ➡️ Uint in buffer methods
It’s *so* hard to remember that it’s `UintXArray` but not `(write|read)UintX`. Let’s fix that by just providing aliases. 😊 PR-URL: #34729 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 987e0cb commit 9d07217
Copy full SHA for 9d07217

File tree

Expand file treeCollapse file tree

3 files changed

+65
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+65
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+42Lines changed: 42 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,9 @@ console.log(buf.readIntLE(0, 6).toString(16));
17051705
<!-- YAML
17061706
added: v0.5.0
17071707
changes:
1708+
- version: REPLACEME
1709+
pr-url: https://github.com/nodejs/node/pull/34729
1710+
description: This function is also available as `buf.readUint8()`.
17081711
- version: v10.0.0
17091712
pr-url: https://github.com/nodejs/node/pull/18395
17101713
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1732,6 +1735,9 @@ console.log(buf.readUInt8(2));
17321735
<!-- YAML
17331736
added: v0.5.5
17341737
changes:
1738+
- version: REPLACEME
1739+
pr-url: https://github.com/nodejs/node/pull/34729
1740+
description: This function is also available as `buf.readUint16BE()`.
17351741
- version: v10.0.0
17361742
pr-url: https://github.com/nodejs/node/pull/18395
17371743
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1758,6 +1764,9 @@ console.log(buf.readUInt16BE(1).toString(16));
17581764
<!-- YAML
17591765
added: v0.5.5
17601766
changes:
1767+
- version: REPLACEME
1768+
pr-url: https://github.com/nodejs/node/pull/34729
1769+
description: This function is also available as `buf.readUint16LE()`.
17611770
- version: v10.0.0
17621771
pr-url: https://github.com/nodejs/node/pull/18395
17631772
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1786,6 +1795,9 @@ console.log(buf.readUInt16LE(2).toString(16));
17861795
<!-- YAML
17871796
added: v0.5.5
17881797
changes:
1798+
- version: REPLACEME
1799+
pr-url: https://github.com/nodejs/node/pull/34729
1800+
description: This function is also available as `buf.readUint32BE()`.
17891801
- version: v10.0.0
17901802
pr-url: https://github.com/nodejs/node/pull/18395
17911803
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1810,6 +1822,9 @@ console.log(buf.readUInt32BE(0).toString(16));
18101822
<!-- YAML
18111823
added: v0.5.5
18121824
changes:
1825+
- version: REPLACEME
1826+
pr-url: https://github.com/nodejs/node/pull/34729
1827+
description: This function is also available as `buf.readUint32LE()`.
18131828
- version: v10.0.0
18141829
pr-url: https://github.com/nodejs/node/pull/18395
18151830
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1836,6 +1851,9 @@ console.log(buf.readUInt32LE(1).toString(16));
18361851
<!-- YAML
18371852
added: v0.11.15
18381853
changes:
1854+
- version: REPLACEME
1855+
pr-url: https://github.com/nodejs/node/pull/34729
1856+
description: This function is also available as `buf.readUintBE()`.
18391857
- version: v10.0.0
18401858
pr-url: https://github.com/nodejs/node/pull/18395
18411859
description: Removed `noAssert` and no implicit coercion of the offset
@@ -1865,6 +1883,9 @@ console.log(buf.readUIntBE(1, 6).toString(16));
18651883
<!-- YAML
18661884
added: v0.11.15
18671885
changes:
1886+
- version: REPLACEME
1887+
pr-url: https://github.com/nodejs/node/pull/34729
1888+
description: This function is also available as `buf.readUintLE()`.
18681889
- version: v10.0.0
18691890
pr-url: https://github.com/nodejs/node/pull/18395
18701891
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2643,6 +2664,9 @@ console.log(buf);
26432664
<!-- YAML
26442665
added: v0.5.0
26452666
changes:
2667+
- version: REPLACEME
2668+
pr-url: https://github.com/nodejs/node/pull/34729
2669+
description: This function is also available as `buf.writeUint8()`.
26462670
- version: v10.0.0
26472671
pr-url: https://github.com/nodejs/node/pull/18395
26482672
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2674,6 +2698,9 @@ console.log(buf);
26742698
<!-- YAML
26752699
added: v0.5.5
26762700
changes:
2701+
- version: REPLACEME
2702+
pr-url: https://github.com/nodejs/node/pull/34729
2703+
description: This function is also available as `buf.writeUint16BE()`.
26772704
- version: v10.0.0
26782705
pr-url: https://github.com/nodejs/node/pull/18395
26792706
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2703,6 +2730,9 @@ console.log(buf);
27032730
<!-- YAML
27042731
added: v0.5.5
27052732
changes:
2733+
- version: REPLACEME
2734+
pr-url: https://github.com/nodejs/node/pull/34729
2735+
description: This function is also available as `buf.writeUint16LE()`.
27062736
- version: v10.0.0
27072737
pr-url: https://github.com/nodejs/node/pull/18395
27082738
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2732,6 +2762,9 @@ console.log(buf);
27322762
<!-- YAML
27332763
added: v0.5.5
27342764
changes:
2765+
- version: REPLACEME
2766+
pr-url: https://github.com/nodejs/node/pull/34729
2767+
description: This function is also available as `buf.writeUint32BE()`.
27352768
- version: v10.0.0
27362769
pr-url: https://github.com/nodejs/node/pull/18395
27372770
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2760,6 +2793,9 @@ console.log(buf);
27602793
<!-- YAML
27612794
added: v0.5.5
27622795
changes:
2796+
- version: REPLACEME
2797+
pr-url: https://github.com/nodejs/node/pull/34729
2798+
description: This function is also available as `buf.writeUint32LE()`.
27632799
- version: v10.0.0
27642800
pr-url: https://github.com/nodejs/node/pull/18395
27652801
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2788,6 +2824,9 @@ console.log(buf);
27882824
<!-- YAML
27892825
added: v0.5.5
27902826
changes:
2827+
- version: REPLACEME
2828+
pr-url: https://github.com/nodejs/node/pull/34729
2829+
description: This function is also available as `buf.writeUintBE()`.
27912830
- version: v10.0.0
27922831
pr-url: https://github.com/nodejs/node/pull/18395
27932832
description: Removed `noAssert` and no implicit coercion of the offset
@@ -2818,6 +2857,9 @@ console.log(buf);
28182857
<!-- YAML
28192858
added: v0.5.5
28202859
changes:
2860+
- version: REPLACEME
2861+
pr-url: https://github.com/nodejs/node/pull/34729
2862+
description: This function is also available as `buf.writeUintLE()`.
28212863
- version: v10.0.0
28222864
pr-url: https://github.com/nodejs/node/pull/18395
28232865
description: Removed `noAssert` and no implicit coercion of the offset
Collapse file

‎lib/internal/buffer.js‎

Copy file name to clipboardExpand all lines: lib/internal/buffer.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,13 @@ function addBufferPrototypeMethods(proto) {
961961
proto.readUIntBE = readUIntBE;
962962
proto.readUInt32BE = readUInt32BE;
963963
proto.readUInt16BE = readUInt16BE;
964+
proto.readUintLE = readUIntLE;
965+
proto.readUint32LE = readUInt32LE;
966+
proto.readUint16LE = readUInt16LE;
967+
proto.readUint8 = readUInt8;
968+
proto.readUintBE = readUIntBE;
969+
proto.readUint32BE = readUInt32BE;
970+
proto.readUint16BE = readUInt16BE;
964971
proto.readIntLE = readIntLE;
965972
proto.readInt32LE = readInt32LE;
966973
proto.readInt16LE = readInt16LE;
@@ -976,6 +983,13 @@ function addBufferPrototypeMethods(proto) {
976983
proto.writeUIntBE = writeUIntBE;
977984
proto.writeUInt32BE = writeUInt32BE;
978985
proto.writeUInt16BE = writeUInt16BE;
986+
proto.writeUintLE = writeUIntLE;
987+
proto.writeUint32LE = writeUInt32LE;
988+
proto.writeUint16LE = writeUInt16LE;
989+
proto.writeUint8 = writeUInt8;
990+
proto.writeUintBE = writeUIntBE;
991+
proto.writeUint32BE = writeUInt32BE;
992+
proto.writeUint16BE = writeUInt16BE;
979993
proto.writeIntLE = writeIntLE;
980994
proto.writeInt32LE = writeInt32LE;
981995
proto.writeInt16LE = writeInt16LE;
Collapse file

‎test/parallel/test-buffer-writeuint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeuint.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,12 @@ const assert = require('assert');
220220
val *= 0x100;
221221
}
222222
}
223+
224+
for (const fn of [
225+
'UInt8', 'UInt16LE', 'UInt16BE', 'UInt32LE', 'UInt32BE', 'UIntLE', 'UIntBE'
226+
]) {
227+
const p = Buffer.prototype;
228+
const lowerFn = fn.replace(/UInt/, 'Uint');
229+
assert.strictEqual(p[`write${fn}`], p[`write${lowerFn}`]);
230+
assert.strictEqual(p[`read${fn}`], p[`read${lowerFn}`]);
231+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.