You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: QWEN.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@
4
4
5
5
`flat-json-tree` is a TypeScript library that provides a simple way to manipulate JSON tree objects. The core idea is to transform a JSON tree object into a flat array, allowing standard array operations like `find`, `findIndex`, `filter`, `map`, and others. It's built as a Vue 3 composable function.
6
6
7
-
The library is published as `@vuebro/flat-json-tree` with the current version being 2.1.12. It's designed to work with tree structures where each element has a unique identifier field.
8
-
9
-
The project follows the AGPL-3.0 license and is maintained by Jerry Bruwes.
7
+
The library is published as `@vuebro/flat-json-tree` with the current version being 2.1.14. It's designed to work with tree structures where each element has a unique identifier field.
Copy file name to clipboardExpand all lines: README.md
+41-65Lines changed: 41 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
-
# A dead simple way to manipulate JSON tree objects
1
+
# flat-json-tree
2
2
3
-
The core idea is to transform a JSON tree object into a flat array, allowing standard operations like find, findIndex, filter, map, and others.
3
+
A dead simple way to manipulate JSON tree objects by transforming them into flat arrays for standard operations.
4
4
5
-
A mandatory requirement for the algorithm is that each element in the JSON tree must have a field with a unique identifier.
5
+
## Overview
6
+
7
+
The core idea is to transform a JSON tree object into a flat array, allowing standard operations like find, findIndex, filter, map, and others. A mandatory requirement for the algorithm is that each element in the JSON tree must have a field with a unique identifier.
6
8
7
9
To preserve the tree structure and enable manipulations, the following computed properties are added to each child object:
8
10
@@ -23,67 +25,45 @@ To preserve the tree structure and enable manipulations, the following computed
23
25
}
24
26
```
25
27
26
-
The transformation is performed using the `useFlatJsonTree` composable:
28
+
## Installation
27
29
28
-
```ts
29
-
function useFlatJsonTree(
30
-
// The JSON tree object
31
-
tree:Record<string, unknown>[],
32
-
// Optional object to define alternative names for id, children, and computed properties
33
-
{
34
-
branch,
35
-
children,
36
-
id,
37
-
index,
38
-
next,
39
-
parent,
40
-
prev,
41
-
siblings,
42
-
}?: {
43
-
branch?:string|undefined;
44
-
children?:string|undefined;
45
-
id?:string|undefined;
46
-
index?:string|undefined;
47
-
next?:string|undefined;
48
-
parent?:string|undefined;
49
-
prev?:string|undefined;
50
-
siblings?:string|undefined;
51
-
},
52
-
);
30
+
```bash
31
+
npm i @vuebro/flat-json-tree
53
32
```
54
33
55
-
The composable returns an object with the following properties:
34
+
## API
56
35
57
-
```ts
58
-
{
59
-
// Computed flat array of objects (access via .value)
0 commit comments