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

Commit c013c3f

Browse files
authored
Merge pull request #70 from acutmore/tospliced-type-error
toSpliced matches splice TypeError logic
2 parents fa6b3b5 + 8e1d927 commit c013c3f

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

polyfill.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
const o = toObject(this);
205205
const len = lengthOfArrayLike(o);
206206
const { actualStart, actualDeleteCount, newLen } = calculateSplice({ start, deleteCount, len, values, argsCount: arguments.length });
207+
if (newLen > Number.MAX_SAFE_INTEGER) {
208+
throw new TypeError();
209+
}
207210
const a = new Array(newLen);
208211
doSplice({ src: o, target: a, actualStart, actualDeleteCount, values, newLen });
209212
return a;

spec.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ <h1>Array.prototype.toSpliced ( _start_, _deleteCount_, ..._items_ )</h1>
8686
1. Let _dc_ be ? ToIntegerOrInfinity(_deleteCount_).
8787
1. Let _actualDeleteCount_ be the result of clamping _dc_ between 0 and _len_ - _actualStart_.
8888
1. Let _newLen_ be _len_ + _insertCount_ - _actualDeleteCount_.
89+
1. If _newLen_ &gt; 2<sup>53</sup> - 1, throw a *TypeError* exception.
8990
1. Let _A_ be ? ArrayCreate(𝔽(_newLen_)).
9091
1. Let _k_ be 0.
9192
1. Repeat, while _k_ &lt; _actualStart_,

0 commit comments

Comments
 (0)