Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,9 @@ console.log(buf.readIntLE(0, 6).toString(16));
<!-- YAML
added: v0.5.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUint8()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -1736,6 +1739,9 @@ console.log(buf.readUInt8(2));
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUint16BE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand All @@ -1762,6 +1768,9 @@ console.log(buf.readUInt16BE(1).toString(16));
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUint16LE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -1790,6 +1799,9 @@ console.log(buf.readUInt16LE(2).toString(16));
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUint32BE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand All @@ -1814,6 +1826,9 @@ console.log(buf.readUInt32BE(0).toString(16));
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUint32LE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand All @@ -1840,6 +1855,9 @@ console.log(buf.readUInt32LE(1).toString(16));
<!-- YAML
added: v0.11.15
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUintBE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -1869,6 +1887,9 @@ console.log(buf.readUIntBE(1, 6).toString(16));
<!-- YAML
added: v0.11.15
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.readUintLE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2651,6 +2672,9 @@ console.log(buf);
<!-- YAML
added: v0.5.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUint8()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2682,6 +2706,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUint16BE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2711,6 +2738,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUint16LE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2740,6 +2770,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUint32BE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2768,6 +2801,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUint32LE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2796,6 +2832,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUintBE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down Expand Up @@ -2826,6 +2865,9 @@ console.log(buf);
<!-- YAML
added: v0.5.5
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34729
description: This function is also available as `buf.writeUintLE()`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18395
description: Removed `noAssert` and no implicit coercion of the offset
Expand Down
14 changes: 14 additions & 0 deletions lib/internal/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,13 @@ function addBufferPrototypeMethods(proto) {
proto.readUIntBE = readUIntBE;
proto.readUInt32BE = readUInt32BE;
proto.readUInt16BE = readUInt16BE;
proto.readUintLE = readUIntLE;
proto.readUint32LE = readUInt32LE;
proto.readUint16LE = readUInt16LE;
proto.readUint8 = readUInt8;
proto.readUintBE = readUIntBE;
proto.readUint32BE = readUInt32BE;
proto.readUint16BE = readUInt16BE;
proto.readIntLE = readIntLE;
proto.readInt32LE = readInt32LE;
proto.readInt16LE = readInt16LE;
Expand All @@ -981,6 +988,13 @@ function addBufferPrototypeMethods(proto) {
proto.writeUIntBE = writeUIntBE;
proto.writeUInt32BE = writeUInt32BE;
proto.writeUInt16BE = writeUInt16BE;
proto.writeUintLE = writeUIntLE;
proto.writeUint32LE = writeUInt32LE;
proto.writeUint16LE = writeUInt16LE;
proto.writeUint8 = writeUInt8;
proto.writeUintBE = writeUIntBE;
proto.writeUint32BE = writeUInt32BE;
proto.writeUint16BE = writeUInt16BE;
proto.writeIntLE = writeIntLE;
proto.writeInt32LE = writeInt32LE;
proto.writeInt16LE = writeInt16LE;
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-buffer-writeuint.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,12 @@ const assert = require('assert');
val *= 0x100;
}
}

for (const fn of [
'UInt8', 'UInt16LE', 'UInt16BE', 'UInt32LE', 'UInt32BE', 'UIntLE', 'UIntBE'
]) {
const p = Buffer.prototype;
const lowerFn = fn.replace(/UInt/, 'Uint');
assert.strictEqual(p[`write${fn}`], p[`write${lowerFn}`]);
assert.strictEqual(p[`read${fn}`], p[`read${lowerFn}`]);
}