1
0
mirror of https://github.com/Yidadaa/ChatGPT-Next-Web.git synced 2025-08-06 07:37:41 +08:00
Files
.github
.husky
app
api
client
components
config
icons
locales
masks
store
styles
utils
command.ts
constant.ts
global.d.ts
layout.tsx
page.tsx
polyfill.ts
typing.ts
utils.ts
docs
public
scripts
.env.template
.eslintignore
.eslintrc.json
.gitignore
.gitpod.yml
.lintstagedrc.json
.prettierrc.js
CODE_OF_CONDUCT.md
Dockerfile
LICENSE
README.md
README_CN.md
docker-compose.yml
next.config.mjs
package.json
tsconfig.json
vercel.json
yarn.lock
ChatGPT-Next-Web/app/polyfill.ts

28 lines
623 B
TypeScript

declare global {
interface Array<T> {
at(index: number): T | undefined;
}
}
if (!Array.prototype.at) {
Array.prototype.at = function (index: number) {
// Get the length of the array
const length = this.length;
// Convert negative index to a positive index
if (index < 0) {
index = length + index;
}
// Return undefined if the index is out of range
if (index < 0 || index >= length) {
return undefined;
}
// Use Array.prototype.slice method to get value at the specified index
return Array.prototype.slice.call(this, index, index + 1)[0];
};
}
export {};