Improve code formatting and readability, handle edge cases in tests, and enhance lazy path extraction logic

This commit is contained in:
2026-01-29 03:47:37 +00:00
parent 9507059ad9
commit e98cb05b14
2 changed files with 75 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
/**
* useJsonFilter Composable
*
*
* Manages JSON path filtering and property-based data filtering.
* Handles path extraction from JSON objects and filtering by property values.
*/
@@ -108,12 +108,7 @@ export default function useJsonFilter() {
* @param {Function} callback - Callback with new paths
* @param {number} chunkSize - Items per chunk
*/
function extractPathsLazy(
data,
startIndex = 100,
callback,
chunkSize = 100
) {
function extractPathsLazy(data, startIndex = 100, callback, chunkSize = 100) {
if (!Array.isArray(data) || startIndex >= data.length) {
return;
}
@@ -131,7 +126,9 @@ export default function useJsonFilter() {
}
});
const addedPaths = Array.from(newPaths).filter(p => !existingPaths.has(p));
const addedPaths = Array.from(newPaths).filter(
p => !existingPaths.has(p)
);
if (addedPaths.length > 0) {
addedPaths.forEach(p => existingPaths.add(p));
@@ -298,11 +295,12 @@ export default function useJsonFilter() {
const value = filterValue.value || '*';
const mode = filterMode.value;
const modeLabel = {
equals: '=',
contains: '',
regex: '~'
}[mode] || mode;
const modeLabel =
{
equals: '=',
contains: '∋',
regex: '~'
}[mode] || mode;
return `${property} ${modeLabel} ${value}`;
});