From 53efe34f966cdde4c4a7f8f22519c99788e809ae Mon Sep 17 00:00:00 2001 From: Folyd Date: Sat, 22 Jun 2024 17:18:29 -0700 Subject: [PATCH] Always return crate search index as Map --- extension/crate-manager.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extension/crate-manager.js b/extension/crate-manager.js index 1f7270cf..6883428b 100644 --- a/extension/crate-manager.js +++ b/extension/crate-manager.js @@ -25,7 +25,7 @@ export default class CrateDocManager { static async getCrateSearchIndex(name) { let searchIndex = await storage.getItem(`@${name}`); if (searchIndex) { - return searchIndex; + return new Map(searchIndex); } else { let crates = await CrateDocManager.getCrates(); let crate = Object.entries(crates).find(([_, { crateName }]) => crateName == name); @@ -43,8 +43,6 @@ export default class CrateDocManager { // 2. https://docs.rs/md-5/0.10.5/md5/ // // Here is the rule: https://docs.rs/{crateName}/{crateVersion}/{libName} - // - // The caller should ensure `searchIndex` is a Map, not a Object. static async addCrate({ libName, crateVersion, crateTitle, searchIndex, crateName, descShards }) { await storage.setItem(`@${libName}`, searchIndex); let doc = crateTitle;