diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-04-02 23:27:55 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-04-02 23:27:55 -0300 |
| commit | 818e89c7ee0a426ac5f66a4079c70e047627a7f2 (patch) | |
| tree | 489d6651767e7b7214324e8dfbc47fed1d2deda6 /src/static/js | |
| parent | b250e91a74b244cc5decd79f5604cfb8a811421a (diff) | |
content: generateDividedTrackList: context groups
Diffstat (limited to 'src/static/js')
| -rw-r--r-- | src/static/js/search-worker.js | 24 |
1 files changed, 2 insertions, 22 deletions
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 = {}; |