Buffer.prototype.copy = function(target, target_start, start, end) {
var source = this;
start || (start = 0);
- end || (end = this.length);
+ if (end === undefined || isNaN(end)) {
+ end = this.length;
+ }
target_start || (target_start = 0);
if (end < start) throw new Error('sourceEnd < sourceStart');
t.equal(b.toString('hex'), '02020202020202020202');
t.end();
});
+
+test('copy() empty buffer with sourceEnd=0', function (t) {
+ t.plan(1);
+ var source = new B([42]);
+ var destination = new B([43]);
+ source.copy(destination, 0, 0, 0);
+ t.equal(destination.readUInt8(0), 43);
+ t.end();
+});