| 12345678910111213141516171819202122 |
- if (typeof Promise.withResolvers !== 'function') {
- Promise.withResolvers = function <T>() {
- let resolve!: (value: T | PromiseLike<T>) => void;
- let reject!: (reason?: any) => void;
- const promise = new Promise<T>((res, rej) => {
- resolve = res;
- reject = rej;
- });
- return { promise, resolve, reject } as PromiseWithResolvers<T>;
- };
- Object.defineProperty(Promise, 'withResolvers', {});
- }
- if (typeof Array.prototype.at !== 'function') {
- Array.prototype.at = function (index: number) {
- return index < 0 ? this[this.length + index] : this[index];
- };
- }
- export {};
|