Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions __tests__/collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ describe('at() tests', () => {
coll.set('a', 1);
coll.set('b', 2);

test('No index', () => {
expect(coll.at()).toStrictEqual(1);
});

test('Positive index', () => {
expect(coll.at(0)).toStrictEqual(1);
});
Expand All @@ -308,10 +304,6 @@ describe('keyAt() tests', () => {
coll.set('a', 1);
coll.set('b', 2);

test('No index', () => {
expect(coll.keyAt()).toStrictEqual('a');
});

test('Positive index', () => {
expect(coll.keyAt(0)).toStrictEqual('a');
});
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class Collection<K, V> extends Map<K, V> {
*
* @param index The index of the element to obtain
*/
public at(index = 0) {
public at(index: number) {
index = Math.floor(index);
const arr = [...this.values()];
return arr.at(index);
Expand All @@ -138,7 +138,7 @@ export class Collection<K, V> extends Map<K, V> {
*
* @param index The index of the key to obtain
*/
public keyAt(index = 0) {
public keyAt(index: number) {
index = Math.floor(index);
const arr = [...this.keys()];
return arr.at(index);
Expand Down