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

Commit

Permalink
Merge pull request #70 from acutmore/tospliced-type-error
Browse files Browse the repository at this point in the history
toSpliced matches splice TypeError logic
  • Loading branch information
acutmore committed Jan 9, 2022
2 parents fa6b3b5 + 8e1d927 commit c013c3f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions polyfill.js
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
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
2 changes: 1 addition & 1 deletion test262

0 comments on commit c013c3f

Please sign in to comment.