dt-toolbox 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +9 -1
- package/package.json +1 -1
- package/src/convertors/breadcrumbs.js +47 -49
package/Changelog.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Release History
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
### 4.0.3 (2022-02-23)
|
|
6
|
+
- [x] Fix: Initialize with breadcrumbs is not working at all;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
4
10
|
### 4.0.2 (2022-02-21)
|
|
5
11
|
- [x] Fix: Methods 'keep' and 'remove' received `flat keys` instead of `breadcrumbs keys`. If need a `flat key`, its still available as third argument.
|
|
6
12
|
```js
|
|
@@ -8,12 +14,14 @@
|
|
|
8
14
|
// ... set your filter here...
|
|
9
15
|
})
|
|
10
16
|
```
|
|
17
|
+
- [ ] Bug: Initialize with breadcrumbs is not working at all;
|
|
11
18
|
|
|
12
19
|
|
|
13
20
|
|
|
14
21
|
### 4.0.1 (2021-04-08)
|
|
15
22
|
- [x] Fix: Methods "add/update/overwrite/combine/append/prepend" expect by default data-type 'standard'. Should be a 'flat' data-type. This update is coming as major release because may require some changes. Everything else is according documentation for version 3.x.x;
|
|
16
|
-
- [] Bug: Methods 'keep' and 'remove' received `flat keys` instead of `breadcrumbs keys`
|
|
23
|
+
- [ ] Bug: Methods 'keep' and 'remove' received `flat keys` instead of `breadcrumbs keys`
|
|
24
|
+
- [ ] Bug: Initialize with breadcrumbs is not working at all;
|
|
17
25
|
|
|
18
26
|
|
|
19
27
|
|
package/package.json
CHANGED
|
@@ -35,55 +35,53 @@ function toFlat ( dependencies, rawValue ) {
|
|
|
35
35
|
.keys ( rawValue )
|
|
36
36
|
.map ( x => x.split('/') )
|
|
37
37
|
.sort ( (a,b) => b.length - a.length )
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}} // for deepList
|
|
86
|
-
return [ structure, value ]
|
|
38
|
+
, tProps = {} // { objectLocation<string> : childObjectNames<set> }
|
|
39
|
+
, structRaw = [] // objectLocation strings
|
|
40
|
+
, propDone = []
|
|
41
|
+
;
|
|
42
|
+
keyList.forEach ( (keyArr) => { // Setup our temp structures: tProps and structRaw
|
|
43
|
+
keyArr.forEach ( (k,i) => {
|
|
44
|
+
let parent = keyArr.slice( 0, i ).join ( '/' );
|
|
45
|
+
if ( !parent ) return
|
|
46
|
+
if ( !tProps[parent] ) {
|
|
47
|
+
tProps[parent] = new Set()
|
|
48
|
+
structRaw.push ( parent )
|
|
49
|
+
}
|
|
50
|
+
tProps[parent].add ( k )
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
structRaw.forEach ( (el,i) => { // Build the structure rows
|
|
54
|
+
let elChildren = false;
|
|
55
|
+
if ( !structure[i] ) structure[i] = [ 'object', i ]
|
|
56
|
+
if ( propDone[i] ) el = propDone[i]
|
|
57
|
+
elChildren = Array.from ( tProps[el] )
|
|
58
|
+
elChildren.forEach ( name => { // Setup connections between object
|
|
59
|
+
let test = tProps[`${el}/${name}`];
|
|
60
|
+
if ( !test ) return
|
|
61
|
+
let
|
|
62
|
+
childProps = Array.from (test)
|
|
63
|
+
, type = help.hasNumbers ( childProps ) ? 'array' : 'object'
|
|
64
|
+
, lastIndex = structure.length
|
|
65
|
+
;
|
|
66
|
+
propDone[lastIndex] = `${el}/${name}`
|
|
67
|
+
structure.push ([type, lastIndex])
|
|
68
|
+
structure[i].push ( [lastIndex, name])
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
keyList.forEach ( k => { // Create flat keys and write values
|
|
73
|
+
let
|
|
74
|
+
name = k.pop()
|
|
75
|
+
, keySearch = k.join ( '/' )
|
|
76
|
+
, objNumber = null
|
|
77
|
+
, theKey = ''
|
|
78
|
+
;
|
|
79
|
+
objNumber = propDone.indexOf ( keySearch )
|
|
80
|
+
if ( objNumber < 0 ) objNumber = structRaw.indexOf(keySearch)
|
|
81
|
+
theKey = `root/${objNumber}/${name}`
|
|
82
|
+
value[theKey] = rawValue[`${keySearch}/${name}`]
|
|
83
|
+
})
|
|
84
|
+
return [ structure, value ]
|
|
87
85
|
} // toFlat func.
|
|
88
86
|
|
|
89
87
|
|