✨ Improve code formatting and readability, handle edge cases in tests, and enhance lazy path extraction logic
This commit is contained in:
@@ -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}`;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user