}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
-Buffer.prototype.copy = function copy (target, target_start, start, end) {
+Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
- if (target_start >= target.length) target_start = target.length
- if (!target_start) target_start = 0
+ if (targetStart >= target.length) targetStart = target.length
+ if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
- if (target_start < 0) {
+ if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
// Are we oob?
if (end > this.length) end = this.length
- if (target.length - target_start < end - start) {
- end = target.length - target_start + start
+ if (target.length - targetStart < end - start) {
+ end = target.length - targetStart + start
}
var len = end - start
if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < len; i++) {
- target[i + target_start] = this[i + start]
+ target[i + targetStart] = this[i + start]
}
} else {
- target._set(this.subarray(start, start + len), target_start)
+ target._set(this.subarray(start, start + len), targetStart)
}
return len