MCPcopy Index your code
hub / github.com/watsonbox/exportify / search

Method search

src/components/data/PlaylistsData.ts:53–73  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

51 }
52
53 async search(query: string) {
54 await this.loadAll()
55
56 // Remove any uninitialized playlists when exporting
57 let results = this.data.filter(p => p && Object.keys(p).length > 0)
58
59 if (query.startsWith("public:")) {
60 return results.filter(p => p.public === query.endsWith(":true"))
61 } else if (query.startsWith("collaborative:")) {
62 return results.filter(p => p.collaborative === query.endsWith(":true"))
63 } else if (query.startsWith("owner:")) {
64 let owner = query.match(/owner:(.*)/)?.at(-1)?.toLowerCase()
65 if (owner === "me") owner = this.userId
66
67 return results.filter(p => p.owner).filter(p => p.owner.id === owner)
68 } else {
69 // Case-insensitive search in playlist name
70 // TODO: Add lazy evaluation for performance?
71 return results.filter(p => p.name.toLowerCase().includes(query.toLowerCase()))
72 }
73 }
74
75 async loadAll() {
76 if (this.onPlaylistsLoadingStarted) {

Callers 2

exportMethod · 0.80
PlaylistTableClass · 0.80

Calls 1

loadAllMethod · 0.95

Tested by

no test coverage detected