File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
packages/lobe-cli-ui/src/lib Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ package-lock.json
2626# production
2727dist
2828es
29- lib
3029logs
3130test-output
3231
@@ -41,4 +40,4 @@ test-output
4140
4241# misc
4342# add other ignore file below
44- bun.lockb
43+ bun.lockb
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments