Skip to content

Commit

Permalink
.toSpliced should throw a TypeError instead of RangeError
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Jun 26, 2022
1 parent 7019893 commit c34d852
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Float16Array.mjs
Expand Up @@ -17,6 +17,7 @@ import {
CANNOT_MIX_BIGINT_AND_OTHER_TYPES,
DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH,
ITERATOR_PROPERTY_IS_NOT_CALLABLE,
MAXIMUM_ALLOWED_LENGTH_EXCEEDED,
OFFSET_IS_OUT_OF_BOUNDS,
REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE,
SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT,
Expand All @@ -29,6 +30,7 @@ import {
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeToLocaleString,
MAX_SAFE_INTEGER,
NativeArrayBuffer,
NativeObject,
NativeProxy,
Expand Down Expand Up @@ -1067,6 +1069,9 @@ export class Float16Array {

// don't use SpeciesConstructor
const newLength = length + insertCount - actualDeleteCount;
if (newLength > MAX_SAFE_INTEGER) {
throw NativeTypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
}
const proxy = new Float16Array(newLength);
const array = getFloat16BitsArray(proxy);

Expand Down
1 change: 1 addition & 0 deletions src/_util/messages.mjs
Expand Up @@ -17,4 +17,5 @@ export const CANNOT_MIX_BIGINT_AND_OTHER_TYPES =
export const ITERATOR_PROPERTY_IS_NOT_CALLABLE = "@@iterator property is not callable";
export const REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE =
"Reduce of empty array with no initial value";
export const MAXIMUM_ALLOWED_LENGTH_EXCEEDED = "Maximum allowed length exceeded";
export const OFFSET_IS_OUT_OF_BOUNDS = "Offset is out of bounds";

0 comments on commit c34d852

Please sign in to comment.