Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
lib/src: refactoring out of range index
  • Loading branch information
larissayvette authored and Trott committed May 27, 2017
commit 41ba54faaa154aa1f644e8b82be5eb1d8d0f2d48
8 changes: 4 additions & 4 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,28 +629,28 @@ Buffer.prototype.compare = function compare(target,
if (start === undefined)
start = 0;
else if (start < 0)
throw new RangeError('out of range index');
throw new RangeError('Index out of range');
else
start >>>= 0;

if (end === undefined)
end = target.length;
else if (end > target.length)
throw new RangeError('out of range index');
throw new RangeError('Index out of range');
else
end >>>= 0;

if (thisStart === undefined)
thisStart = 0;
else if (thisStart < 0)
throw new RangeError('out of range index');
throw new RangeError('Index out of range');
else
thisStart >>>= 0;

if (thisEnd === undefined)
thisEnd = this.length;
else if (thisEnd > this.length)
throw new RangeError('out of range index');
throw new RangeError('Index out of range');
else
thisEnd >>>= 0;

Expand Down
8 changes: 4 additions & 4 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#define THROW_AND_RETURN_IF_OOB(r) \
do { \
if (!(r)) return env->ThrowRangeError("out of range index"); \
if (!(r)) return env->ThrowRangeError("Index out of range"); \
} while (0)

#define SLICE_START_END(start_arg, end_arg, end_max) \
Expand Down Expand Up @@ -564,7 +564,7 @@ void Copy(const FunctionCallbackInfo<Value> &args) {
return args.GetReturnValue().Set(0);

if (source_start > ts_obj_length)
return env->ThrowRangeError("out of range index");
return env->ThrowRangeError("Index out of range");

if (source_end - source_start > target_length - target_start)
source_end = source_start + target_length - target_start;
Expand Down Expand Up @@ -878,9 +878,9 @@ void CompareOffset(const FunctionCallbackInfo<Value> &args) {
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(args[5], ts_obj_length, &source_end));

if (source_start > ts_obj_length)
return env->ThrowRangeError("out of range index");
return env->ThrowRangeError("Index out of range");
if (target_start > target_length)
return env->ThrowRangeError("out of range index");
return env->ThrowRangeError("Index out of range");

CHECK_LE(source_start, source_end);
CHECK_LE(target_start, target_end);
Expand Down