Vitepress
This commit is contained in:
17
node_modules/@docsearch/react/dist/esm/utils/groupBy.js
generated
vendored
Normal file
17
node_modules/@docsearch/react/dist/esm/utils/groupBy.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export function groupBy(values, predicate, maxResultsPerGroup) {
|
||||
return values.reduce(function (acc, item) {
|
||||
var key = predicate(item);
|
||||
|
||||
if (!acc.hasOwnProperty(key)) {
|
||||
acc[key] = [];
|
||||
} // We limit each section to show 5 hits maximum.
|
||||
// This acts as a frontend alternative to `distinct`.
|
||||
|
||||
|
||||
if (acc[key].length < (maxResultsPerGroup || 5)) {
|
||||
acc[key].push(item);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
Reference in New Issue
Block a user