xrf.js/level0.js

39 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2025-10-02 16:56:10 +02:00
/**
2025-10-02 17:01:09 +02:00
* import {...} from 'xrf/level0'
2025-10-02 16:56:10 +02:00
*
* | function | example |
* |------------------------|-------------------------------------------------------------------------|
2025-10-23 09:28:05 +02:00
* | sideCarFiles(...) | sideCarFiles("https://f.org/a.glb") `// ["https://f.org/a.png",...]` |
* | fetchSideCarFiles(...) | await fetchSideCarFiles("https://f.org/a.glb") `// [{code:200},...]` |
2025-10-02 16:56:10 +02:00
*
*/
2025-09-30 13:20:59 +02:00
import * as http from './scheme/http.js'
import * as xrf from './scheme/http.js'
function defaultSchemes(){
return {http,xrf}
}
2025-10-02 16:56:10 +02:00
async function sideCarFiles(urlString, opts){
const sext = [".png",".ogg",".vtt",".json"]
}
async function fetchSideCarFiles(urlString, opts){
2025-09-30 13:20:59 +02:00
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'} )
})
)
2025-10-23 09:28:05 +02:00
await Promise.allSettled(p)
2025-09-30 13:20:59 +02:00
}
export {pollSideCarFiles}