From f332669ddd5437d632338fb9dbcdcca606958703 Mon Sep 17 00:00:00 2001 From: Sukka Date: Mon, 30 Dec 2019 21:03:22 +0800 Subject: [PATCH] refactor(hexo/index): use Set (#4013) --- lib/hexo/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/hexo/index.js b/lib/hexo/index.js index a5c45bec4c..97a9566ef9 100644 --- a/lib/hexo/index.js +++ b/lib/hexo/index.js @@ -36,15 +36,13 @@ const stopWatcher = box => { if (box.isWatching()) box.unwatch(); }; const routeCache = new WeakMap(); -const unique = array => array.filter((item, index, self) => self.indexOf(item) === index); - const castArray = obj => { return Array.isArray(obj) ? obj : [obj]; }; const createLoadThemeRoute = function(generatorResult, locals, ctx) { const { log, theme } = ctx; const { path, cache: useCache } = locals; - const layout = unique(castArray(generatorResult.layout)); + const layout = [...new Set(castArray(generatorResult.layout))]; const layoutLength = layout.length; // allways use cache in fragment_cache