Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

toSpliced matches splice TypeError logic #70

Merged
merged 1 commit into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@
const o = toObject(this);
const len = lengthOfArrayLike(o);
const { actualStart, actualDeleteCount, newLen } = calculateSplice({ start, deleteCount, len, values, argsCount: arguments.length });
if (newLen > Number.MAX_SAFE_INTEGER) {
throw new TypeError();
}
const a = new Array(newLen);
doSplice({ src: o, target: a, actualStart, actualDeleteCount, values, newLen });
return a;
Expand Down
1 change: 1 addition & 0 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h1>Array.prototype.toSpliced ( _start_, _deleteCount_, ..._items_ )</h1>
1. Let _dc_ be ? ToIntegerOrInfinity(_deleteCount_).
1. Let _actualDeleteCount_ be the result of clamping _dc_ between 0 and _len_ - _actualStart_.
1. Let _newLen_ be _len_ + _insertCount_ - _actualDeleteCount_.
1. If _newLen_ &gt; 2<sup>53</sup> - 1, throw a *TypeError* exception.
1. Let _A_ be ? ArrayCreate(𝔽(_newLen_)).
1. Let _k_ be 0.
1. Repeat, while _k_ &lt; _actualStart_,
Expand Down