feat: Add polyfill for Array.prototype.toSpliced method

This commit is contained in:
CodingOnStar 2025-12-23 15:16:28 +08:00
parent 00af19c7f2
commit 91e23027f1
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,15 @@
'use client'
// Polyfill for Array.prototype.toSpliced (ES2023, Chrome 110+)
if (!Array.prototype.toSpliced) {
// eslint-disable-next-line no-extend-native
Array.prototype.toSpliced = function <T>(this: T[], start: number, deleteCount?: number, ...items: T[]): T[] {
const copy = this.slice()
copy.splice(start, deleteCount ?? copy.length - start, ...items)
return copy
}
}
class StorageMock {
data: Record<string, string>