Skip to content

Commit 2da506b

Browse files
🐛 fix: fix gitignore
1 parent 9776ea0 commit 2da506b

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package-lock.json
2626
# production
2727
dist
2828
es
29-
lib
3029
logs
3130
test-output
3231

@@ -41,4 +40,4 @@ test-output
4140

4241
# misc
4342
# add other ignore file below
44-
bun.lockb
43+
bun.lockb
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {type Option} from '../types';
2+
3+
type OptionMapItem = Option & {
4+
previous: OptionMapItem | undefined;
5+
next: OptionMapItem | undefined;
6+
index: number;
7+
};
8+
9+
export default class OptionMap extends Map<string, OptionMapItem> {
10+
readonly first: OptionMapItem | undefined;
11+
12+
constructor(options: Option[]) {
13+
const items: Array<[string, OptionMapItem]> = [];
14+
let firstItem: OptionMapItem | undefined;
15+
let previous: OptionMapItem | undefined;
16+
let index = 0;
17+
18+
for (const option of options) {
19+
const item = {
20+
...option,
21+
previous,
22+
next: undefined,
23+
index,
24+
};
25+
26+
if (previous) {
27+
previous.next = item;
28+
}
29+
30+
firstItem ||= item;
31+
32+
items.push([option.value, item]);
33+
index++;
34+
previous = item;
35+
}
36+
37+
super(items);
38+
this.first = firstItem;
39+
}
40+
}

0 commit comments

Comments
 (0)