Skip to content

Commit efb99db

Browse files
committed
fix: commit last.js
1 parent 24b4933 commit efb99db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/last.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function last(arrayLike) {
2+
if (Array.isArray(arrayLike)) return arrayLike.at(-1);
3+
if (arrayLike?.length !== undefined) return arrayLike[arrayLike.length - 1];
4+
throw new Error('Not an array like object', typeof arrayLike);
5+
}

0 commit comments

Comments
 (0)