/ src / lib / rollup-parser.ts
rollup-parser.ts
 1  export interface RollupInfo {
 2    namespace: number
 3    name: string
 4    website: string
 5    scan: string
 6  }
 7  
 8  export function parseRollupData(content: string): RollupInfo[] {
 9    const rollupData: RollupInfo[] = []
10    const regex = /new k\(([^,]+),"([^"]+)",new URL\("([^"]+)"\),new URL\("([^"]+)"\)\)/g
11    let match
12    
13    while ((match = regex.exec(content)) !== null) {
14      const [, namespaceStr, name, website, scan] = match
15      const namespace = parseInt(namespaceStr)
16      
17      if (!isNaN(namespace)) {
18        rollupData.push({ namespace, name, website, scan })
19      }
20    }
21    
22    return rollupData
23  }