From 818e89c7ee0a426ac5f66a4079c70e047627a7f2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 2 Apr 2026 23:27:55 -0300 Subject: content: generateDividedTrackList: context groups --- src/static/js/search-worker.js | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'src/static/js') diff --git a/src/static/js/search-worker.js b/src/static/js/search-worker.js index b79df3d4..9ccaa95d 100644 --- a/src/static/js/search-worker.js +++ b/src/static/js/search-worker.js @@ -6,6 +6,7 @@ import {default as searchSpec, makeSearchIndex} import { empty, groupArray, + permutations, promiseWithResolvers, stitchArrays, unique, @@ -542,7 +543,7 @@ function queryIndex({termsKey, indexKey}, query, options) { const queriesBy = keys => (groupedParticles.get(keys.length) ?? []) - .flatMap(permutations) + .flatMap(particles => Array.from(permutations(particles))) .map(values => values.map(({terms}) => terms.join(' '))) .map(values => stitchArrays({ @@ -692,27 +693,6 @@ function particulate(terms) { return results; } -// This function doesn't even come close to "performant", -// but it only operates on small data here. -function permutations(array) { - switch (array.length) { - case 0: - return []; - - case 1: - return [array]; - - default: - return array.flatMap((item, index) => { - const behind = array.slice(0, index); - const ahead = array.slice(index + 1); - return ( - permutations([...behind, ...ahead]) - .map(rest => [item, ...rest])); - }); - } -} - function queryBoilerplate(index) { const idToDoc = {}; -- cgit 1.3.0-6-gf8a5