dt-toolbox 4.0.9 → 6.0.0

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.
Files changed (85) hide show
  1. package/Changelog.md +7 -12
  2. package/LICENSE +1 -1
  3. package/Migration.guide.md +14 -1
  4. package/README.md +976 -352
  5. package/README_v.2.x.x.md +0 -1
  6. package/README_v.4.x.x.md +532 -0
  7. package/package.json +24 -32
  8. package/src/convertors/index.js +44 -37
  9. package/src/convertors/midflat.js +77 -133
  10. package/src/convertors/standard.js +62 -87
  11. package/src/convertors/tuples.js +171 -0
  12. package/src/flatData/connect.js +50 -0
  13. package/src/flatData/export.js +46 -0
  14. package/src/flatData/filters/list.js +11 -0
  15. package/src/flatData/filters/listObject.js +13 -0
  16. package/src/flatData/filters/object.js +12 -0
  17. package/src/flatData/filters/root.js +12 -0
  18. package/src/flatData/find.js +20 -0
  19. package/src/flatData/from.js +33 -0
  20. package/src/flatData/get.js +29 -0
  21. package/src/flatData/index.js +101 -0
  22. package/src/flatData/insert.js +24 -0
  23. package/src/flatData/like.js +24 -0
  24. package/src/flatData/look.js +49 -0
  25. package/src/flatData/push.js +19 -0
  26. package/src/flatData/save.js +17 -0
  27. package/src/flatData/set.js +26 -0
  28. package/src/flatData/setupFilter.js +21 -0
  29. package/src/flatData/use.js +16 -0
  30. package/src/flatObject/copy.js +19 -0
  31. package/src/flatObject/export.js +13 -0
  32. package/src/flatObject/index.js +47 -0
  33. package/src/flatObject/insert.js +28 -0
  34. package/src/flatObject/model.js +32 -0
  35. package/src/flatObject/query.js +24 -0
  36. package/src/flatObject/setupFilter.js +12 -0
  37. package/src/main.js +21 -690
  38. package/src/mainLib.js +105 -0
  39. package/dist/dt-toolbox.min.js +0 -1
  40. package/dist/index.html +0 -65
  41. package/src/compareMethod/change.js +0 -21
  42. package/src/compareMethod/different.js +0 -18
  43. package/src/compareMethod/identical.js +0 -21
  44. package/src/compareMethod/index.js +0 -16
  45. package/src/compareMethod/missing.js +0 -18
  46. package/src/compareMethod/same.js +0 -18
  47. package/src/convertors/breadcrumbs.js +0 -148
  48. package/src/help/extractSelection.js +0 -12
  49. package/src/help/filterObject.js +0 -25
  50. package/src/help/hasNumbers.js +0 -14
  51. package/src/help/index.js +0 -37
  52. package/src/help/isItPrimitive.js +0 -10
  53. package/src/help/objectsByLevel.js +0 -16
  54. package/src/help/reduceTuples.js +0 -29
  55. package/src/help/sanitizeFlatKeys.js +0 -30
  56. package/src/help/toBreadcrumbsKeys.js +0 -28
  57. package/src/help/tuplesToBreadcrumbs.js +0 -25
  58. package/src/help/updateSelection.js +0 -14
  59. package/src/help/zipObject.js +0 -24
  60. package/src/lib/assemble.js +0 -45
  61. package/src/lib/attach.js +0 -20
  62. package/src/lib/block.js +0 -33
  63. package/src/lib/combine.js +0 -38
  64. package/src/lib/deep.js +0 -23
  65. package/src/lib/find.js +0 -36
  66. package/src/lib/folder.js +0 -42
  67. package/src/lib/index.js +0 -58
  68. package/src/lib/modify.js +0 -22
  69. package/src/lib/parent.js +0 -51
  70. package/src/lib/purify.js +0 -39
  71. package/src/lib/transform.js +0 -55
  72. package/src/modifiers/add.js +0 -18
  73. package/src/modifiers/append.js +0 -18
  74. package/src/modifiers/combineShallow.js +0 -119
  75. package/src/modifiers/flatten.js +0 -39
  76. package/src/modifiers/index.js +0 -34
  77. package/src/modifiers/insert.js +0 -21
  78. package/src/modifiers/keyPrefix.js +0 -27
  79. package/src/modifiers/mix.js +0 -25
  80. package/src/modifiers/overwrite.js +0 -18
  81. package/src/modifiers/prepend.js +0 -19
  82. package/src/modifiers/reverse.js +0 -23
  83. package/src/modifiers/update.js +0 -18
  84. package/src/simple.js +0 -49
  85. package/webpack.config.js +0 -28
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ function setupFilter ( flatStorage, filterFn, filtering, getFilterNames ) {
4
+ return function setupFilter ( name, fn ) {
5
+ const
6
+ filterNames = getFilterNames ()
7
+ , [,, flatData ] = flatStorage
8
+ ;
9
+ if ( filterNames.includes( name )) {
10
+ console.error ( `Filter name "${name}" is already defined` )
11
+ return this
12
+ }
13
+ filterFn[name] = fn
14
+ flatData.forEach ( line => filtering ( name, line ))
15
+ }} // setupFilter func.
16
+
17
+
18
+
19
+ export default setupFilter
20
+
21
+
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function use ( flatIO ) {
6
+ return function use ( name ) {
7
+ const filter = flatIO.getFilters()[name];
8
+ if ( filter ) flatIO.setupScanList ( filter )
9
+ return this
10
+ }} // use func.
11
+
12
+
13
+
14
+ export default use
15
+
16
+
@@ -0,0 +1,19 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function copy ( dependencies, flatIO ) {
6
+ return function copy ( name = 'root' ) {
7
+ const
8
+ c = flatIO.getCopy (name)
9
+ , { walk } = dependencies ()
10
+ ;
11
+ if ( !c ) return null
12
+ return walk ({ data : c })
13
+ }} // copy func.
14
+
15
+
16
+
17
+ export default copy
18
+
19
+
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function ex ( dependencies, flatIO ) {
6
+ return name => flatIO.export ( name )
7
+ }
8
+
9
+
10
+
11
+ export default ex
12
+
13
+
@@ -0,0 +1,47 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ import insert from './insert.js'
6
+ import ex from './export.js'
7
+ import copy from './copy.js'
8
+ import model from './model.js'
9
+ import query from './query.js'
10
+ import setupFilter from './setupFilter.js'
11
+
12
+
13
+
14
+ function flatObject ( dependencies, d ) {
15
+ const
16
+ { flatData } = dependencies ()
17
+ , [ flatIO, flatStore ] = flatData ( dependencies, d )
18
+ , objectAPI = {
19
+ // I/O Operations
20
+ insert : insert ( dependencies, flatIO ) // Extends available data;
21
+ , export : ex ( dependencies, flatIO ) // Returns flat data;
22
+ , copy : copy ( dependencies, flatIO ) // Creates deep copy of original data
23
+ , model : model ( dependencies, flatIO, flatStore ) // Arrange data according specific data-model. Model should come as a function;
24
+ , query : query ( dependencies, flatIO, flatStore ) // Request, and evaluate data. Returns a new flat object;
25
+ , setupFilter : setupFilter ( flatIO ) // Functions should filter content according some criteria. Generated indexes will help for data search in
26
+ , index : n => {
27
+ if ( n == null ) return null
28
+ let r = flatIO.getLine(n)
29
+ if ( r ) {
30
+ let [ name, d, breadcrumbs, links ] = r;
31
+ let copy;
32
+ if ( d instanceof Array ) copy = [...d ]
33
+ else copy = {...d }
34
+ return [ name, copy, breadcrumbs, [...links] ]
35
+ }
36
+ else return null
37
+ } // index
38
+ }
39
+ ;
40
+ return objectAPI
41
+ } // flatObject func.
42
+
43
+
44
+
45
+ export default flatObject
46
+
47
+
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ function insert ( dependencies, flatIO ) {
4
+ return function insert ( name, inData ) {
5
+
6
+ if ( !inData.export && !(typeof( inData.export) === 'function')) return null
7
+ let
8
+ d = inData.export ()
9
+ , copy = inData.copy ()
10
+ ;
11
+
12
+ const search = new RegExp ( `^root\/` );
13
+ d.forEach ( line => { // Word 'root' should be changed to the argument 'name'.
14
+ if ( line[0] === line[2] ) {
15
+ line[0] = name
16
+ line[2] = name
17
+ }
18
+ line[2] = line[2].replace ( search, `${name}/` )
19
+ line[3].forEach ( (edge,i) => line[3][i] = edge.replace ( search, `${name}/` ) )
20
+ })
21
+ flatIO.insert ( [copy,,d])
22
+ }} // insert func.
23
+
24
+
25
+
26
+ export default insert
27
+
28
+
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function model ( dependencies, flatIO ,flatStore ) {
6
+ return function model () {
7
+ const
8
+ [ fn, ...args ] = arguments
9
+ , { as } = fn ( flatStore, ...args ) || {}
10
+ , { convert } = dependencies ()
11
+ , selection = flatIO.getSelection ()
12
+ , data = ( selection.length === 0 ) ? flatIO.export() : selection
13
+ , CONVERTOR_NAMES = [ 'standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs' ]
14
+ , hasConvertor = as ? CONVERTOR_NAMES.includes ( as ) : false
15
+ ;
16
+
17
+ let result;
18
+ if ( as && !hasConvertor ) {
19
+ console.error ( `Model '${as}' is unknown data-model.` )
20
+ return null
21
+ }
22
+ if ( as ) result = convert.to ( as, dependencies, data )
23
+ else result = data
24
+ flatIO.reset ()
25
+ return result
26
+ }} // model func.
27
+
28
+
29
+
30
+ export default model
31
+
32
+
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function query ( dependencies, flatIO ,flatStore ) {
6
+ return function query () {
7
+ const
8
+ { main } = dependencies ()
9
+ , { load } = main ()
10
+ , [ fn, ...args ] = arguments
11
+ ;
12
+
13
+ fn ( flatStore, ...args )
14
+ const result = flatIO.getSelection ();
15
+ flatIO.reset ()
16
+ if ( result.length === 0 ) return this
17
+ return load ( result )
18
+ }} // query func.
19
+
20
+
21
+
22
+ export default query
23
+
24
+
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+
4
+ function setupFilter ( flatIO ) {
5
+ return ( name, filterFn ) => flatIO.setupFilter ( name, filterFn )
6
+ } // setupFilter func.
7
+
8
+
9
+
10
+ export default setupFilter
11
+
12
+