MCPcopy Create free account
hub / github.com/ThatGuySam/doesitarm / setup

Method setup

helpers/stork/browser.js:236–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234
235 // https://github.com/jameslittle230/stork/blob/ff49f163db06734e18ab690c188b45a3c68442ae/js/main.ts#L40
236 async setup () {
237 // Prevent multiple setups
238 if ( this.setupState !== 'not-setup' ) {
239 await this.waitForSetup()
240 return
241 }
242
243 // We're the first to setup
244 // so let's set the state to prevent duplicates
245 this.setupState = 'pending'
246
247 // Load Stork Script
248 if ( !this.stork ) {
249 // console.log('Loading stork script...')
250 await this.loadStorkScript()
251 }
252
253 const {
254 initialize,
255 downloadIndex,
256 } = this.stork
257
258 // Stork JavaScript Reference - https://stork-search.net/docs/js-ref
259
260 // initialize() - https://github.com/jameslittle230/stork/blob/ff49f163db06734e18ab690c188b45a3c68442ae/js/main.ts#L14
261 const initPromise = initialize()
262
263 // downloadIndex() - https://github.com/jameslittle230/stork/blob/ff49f163db06734e18ab690c188b45a3c68442ae/js/main.ts#L20
264 const downloadPromise = downloadIndex( this.name, this.url, this.config )
265
266 // This silly `then` call turns a [(void), (void)] into a (void), which is
267 // only necessary to make Typescript happy.
268 // You begin to wonder if you write Typescript code, or if Typescript code writes you.
269 await Promise.all([ initPromise, downloadPromise ])
270
271 // Mark setup as complete
272 this.setupState = 'complete'
273
274 return
275 }
276}
277
278export class StorkFilters extends SearchFilters {}

Callers 1

lazyQueryMethod · 0.95

Calls 2

waitForSetupMethod · 0.95
loadStorkScriptMethod · 0.95

Tested by

no test coverage detected