This commit is contained in:
IDONTSUDO 2023-11-20 00:48:40 +03:00
parent d70253d6a6
commit fa645dde92
51 changed files with 657 additions and 281 deletions

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-this-alias */
export const ArrayExtensions = () => {
if ([].equals === undefined) {
// eslint-disable-next-line no-extend-native
@ -23,11 +24,11 @@ export const ArrayExtensions = () => {
if ([].lastElement === undefined) {
// eslint-disable-next-line no-extend-native
Array.prototype.lastElement = function () {
let instanceCheck = this;
const instanceCheck = this;
if (instanceCheck === undefined) {
return undefined;
} else {
let instance = instanceCheck as [];
const instance = instanceCheck as [];
return instance[instance.length - 1];
}
};
@ -38,4 +39,10 @@ export const ArrayExtensions = () => {
return this.length === 0;
};
}
if ([].isNotEmpty === undefined) {
// eslint-disable-next-line no-extend-native
Array.prototype.isNotEmpty = function () {
return this.length !== 0;
};
}
};

View file

@ -7,6 +7,7 @@ declare global {
equals(array: Array<T>, strict: boolean): boolean;
lastElement(): T | undefined;
isEmpty(): boolean;
isNotEmpty():boolean;
}
interface String {
isEmpty(): boolean;