diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-12 14:58:35 +0100 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-12 17:09:19 -0800 |
commit | 3f7e88a852afe54253eb93ddcb0fdf3a88b9f4ec (patch) | |
tree | fc6516865ab9b0199b35920e68d0ce2c36fea64e /doc | |
parent | 2789323902a745eea16c645e38d9d67b6fcb69a0 (diff) | |
download | node-new-3f7e88a852afe54253eb93ddcb0fdf3a88b9f4ec.tar.gz |
buffer: accept negative indices in Buffer#slice()
A negative start or end parameter now indexes from the end of the
buffer. More in line with String#slice() and ArrayBuffer#slice().
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/buffer.markdown | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index d187225a4f..fb118a954b 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -48,8 +48,8 @@ NOTE: Node.js v0.8 simply retained a reference to the buffer in `array.buffer` instead of cloning it. While more efficient, it introduces subtle incompatibilities with the typed -arrays specification. `ArrayBuffer#slice()` and `Buffer#slice()` behave -differently when passed negative indices, for example. +arrays specification. `ArrayBuffer#slice()` makes a copy of the slice while +`Buffer#slice()` creates a view. ## Class: Buffer @@ -260,7 +260,7 @@ into `buf2`, starting at the 8th byte in `buf2`. Returns a new buffer which references the same memory as the old, but offset and cropped by the `start` (defaults to `0`) and `end` (defaults to -`buffer.length`) indexes. +`buffer.length`) indexes. Negative indexes start from the end of the buffer. **Modifying the new buffer slice will modify memory in the original buffer!** |