diff --git a/core/frontend/src/cosmos.ts b/core/frontend/src/cosmos.ts index 09b62e24b..df614f78b 100644 --- a/core/frontend/src/cosmos.ts +++ b/core/frontend/src/cosmos.ts @@ -3,6 +3,7 @@ export {} declare global { interface Array { first(): T | undefined; + last(): T | undefined; isEmpty(): boolean; } @@ -18,6 +19,11 @@ Array.prototype.first = function (this: T[]): T | undefined { return this.isEmpty() ? undefined : this[0] } +// eslint-disable-next-line +Array.prototype.last = function (this: T[]): T | undefined { + return this.at(-1) +} + // eslint-disable-next-line Array.prototype.isEmpty = function (this: T[]): boolean { return this.length === 0