Fix buffer.slice(0, 0)
This commit is contained in:
parent
f123a1ab40
commit
4f32a59307
@ -322,7 +322,7 @@ Buffer.prototype.copy = function copy (target, target_start, start, end) {
|
||||
|
||||
// slice(start, end)
|
||||
Buffer.prototype.slice = function (start, end) {
|
||||
if (!end) end = this.length;
|
||||
if (end === undefined) end = this.length;
|
||||
if (end > this.length) throw new Error("oob");
|
||||
if (start > end) throw new Error("oob");
|
||||
|
||||
|
@ -353,3 +353,7 @@ assert.equal(14, Buffer.byteLength("Il était tué"));
|
||||
assert.equal(14, Buffer.byteLength("Il était tué", "utf8"));
|
||||
assert.equal(12, Buffer.byteLength("Il était tué", "ascii"));
|
||||
assert.equal(12, Buffer.byteLength("Il était tué", "binary"));
|
||||
|
||||
|
||||
// slice(0,0).length === 0
|
||||
assert.equal(0, Buffer('hello').slice(0, 0).length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user