25 lines
559 B
JavaScript
25 lines
559 B
JavaScript
|
|
import * as http from './scheme/http.js'
|
||
|
|
import * as xrf from './scheme/http.js'
|
||
|
|
|
||
|
|
function defaultSchemes(){
|
||
|
|
return {http,xrf}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function pollSideCarFiles(urlString, opts){
|
||
|
|
|
||
|
|
opts = {}
|
||
|
|
opts.scheme = opts.scheme || defaultSchemes()
|
||
|
|
let p = []
|
||
|
|
const sext = [".png",".ogg",".vtt",".json"]
|
||
|
|
ext = urlString.lastIndexOf('.')
|
||
|
|
|
||
|
|
for( let i in ext) p.push(
|
||
|
|
new Promise( (resolve,reject) => {
|
||
|
|
fetch( urlString.replace(ext, sext[i] ), { method:'HEAD'} )
|
||
|
|
})
|
||
|
|
)
|
||
|
|
await Promise.all(p)
|
||
|
|
}
|
||
|
|
|
||
|
|
export {pollSideCarFiles}
|