Telegram Web K with changes to work inside I2P https://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import bufferConcats from "../helpers/bytes/bufferConcats";
5 years ago
Uint8Array.prototype.concat = function(...args: Array<Uint8Array | ArrayBuffer | number[]>) {
return bufferConcats(this, ...args);
};
/* Uint8Array.prototype.toString = function() {
return String.fromCharCode.apply(null, [...this]);
}; */
Uint8Array.prototype.toJSON = function() {
return [...this];
//return {type: 'bytes', value: [...this]};
};
Promise.prototype.finally = Promise.prototype.finally || function<T>(this: Promise<T>, fn: () => any) {
const onFinally = (callback: typeof fn) => Promise.resolve(fn()).then(callback);
return this.then(
result => onFinally(() => result),
reason => onFinally(() => Promise.reject(reason))
);
};
5 years ago
declare global {
interface Uint8Array {
concat: (...args: Array<Uint8Array | ArrayBuffer | number[]>) => Uint8Array,
//toString: () => string,
toJSON: () => number[],
//toJSON: () => {type: 'bytes', value: number[]},
5 years ago
}
interface Promise<T> {
finally: (onfinally?: () => void) => Promise<T>;
}
5 years ago
}