Skip to content
Prev Previous commit
Next Next commit
doc: fix wrong function arguments in the buffer.md
  • Loading branch information
vsemozhetbyt committed Nov 26, 2016
commit da92b8e7a2291e1b1e179faa513c4f546861dda7
4 changes: 2 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ console.log(buf.lastIndexOf('buffer', 4));
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');

// Prints: 6
console.log(utf16Buffer.lastIndexOf('\u03a3', null, 'ucs2'));
console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'ucs2'));

@silverwind silverwind Dec 3, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both null and undefined are technically not valid arguments. Maybe make a better example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@silverwind It is a bit complicated here and I hoped it would be fixed fully when #9801 is addressed. Maybe this could be postponed till that big issue fixed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fine with me.


// Prints: 4
console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'ucs2'));
Expand Down Expand Up @@ -1446,7 +1446,7 @@ const buf = Buffer.from([0, 5]);
console.log(buf.readInt16BE());

// Prints: 1280
console.log(buf.readInt16LE(1));
console.log(buf.readInt16LE());

// Throws an exception: RangeError: Index out of range
console.log(buf.readInt16LE(1));
Expand Down