Skip to content

Commit

Permalink
core: frontend: cosmos: Add Array.last
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Mar 27, 2024
1 parent b925a53 commit 01718a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/frontend/src/cosmos.ts
Expand Up @@ -3,6 +3,7 @@ export {}
declare global {
interface Array<T> {
first(): T | undefined;
last(): T | undefined;
isEmpty(): boolean;
}

Expand All @@ -18,6 +19,11 @@ Array.prototype.first = function<T> (this: T[]): T | undefined {
return this.isEmpty() ? undefined : this[0]
}

// eslint-disable-next-line
Array.prototype.last = function<T> (this: T[]): T | undefined {
return this.at(-1)
}

// eslint-disable-next-line
Array.prototype.isEmpty = function<T> (this: T[]): boolean {
return this.length === 0
Expand Down

0 comments on commit 01718a1

Please sign in to comment.