musescore-downloader

[Fork] again, nothing to see here.
git clone https://git.jojolepro.com/musescore-downloader.git
Log | Files | Refs | README | LICENSE

utils.ts (810B)


      1 
      2 export const getIndexPath = (id: number) => {
      3     const idStr = String(id)
      4     // 获取最后三位,倒序排列
      5     // x, y, z are the reversed last digits of the score id. Example: id 123456789, x = 9, y = 8, z = 7
      6     // https://developers.musescore.com/#/file-urls
      7     // "5449062" -> ["2", "6", "0"]
      8     const indexN = idStr.split("").reverse().slice(0, 3)
      9     return indexN.join("/")
     10 }
     11 
     12 export const waitForDocumentLoaded = (): Promise<void> => {
     13     if (document.readyState !== "complete") {
     14         return new Promise(resolve => {
     15             document.addEventListener("readystatechange", () => {
     16                 if (document.readyState == "complete") {
     17                     resolve()
     18                 }
     19             }, { once: true })
     20         })
     21     } else {
     22         return Promise.resolve()
     23     }
     24 }