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
@@ -1,119 +0,0 @@
1
- function combineShallow ( mainData, update ) {
2
- let
3
- mainKeys = Object.keys(mainData)
4
- , updateKeys = Object.keys ( update )
5
- , allKeys = [...mainKeys]
6
- , result = {root:{}}
7
- , extraContent = {}
8
- ;
9
-
10
- for ( key of updateKeys ) {
11
- if ( !allKeys.includes(key) ) allKeys.push ( key )
12
- }
13
-
14
- let sortedKeys = allKeys.sort ( (a,b) => b.split('/').length - a.split('/').length )
15
-
16
- let duplicateNames = sortedKeys.reduce ( (res,key) => {
17
- let
18
- mainObject = mainData['root']
19
- , updateObject = update [key]
20
- , check = key.split('/').pop ()
21
- , mainKeys = Object.keys ( mainObject )
22
- ;
23
-
24
- if ( key!= 'root' && mainData[key] ) { // key already has more than one value in mainData. Converted to object
25
- res.add ( check )
26
- if ( !extraContent[check] ) extraContent[check] = []
27
- extraContent[check] = Object.keys ( mainData[key] ).reduce ( (res,k) => {
28
- res.push ( mainData[key][k] )
29
- return res
30
- }, extraContent[check])
31
- }
32
-
33
- if ( check!='root' && updateObject ) { // key exists as object in updateObject
34
- res.add ( check )
35
- if (!extraContent[check]) extraContent[check] = []
36
- extraContent[check] = Object.keys ( updateObject ).reduce ( (res,k) => {
37
- res.push ( updateObject[k] )
38
- return res
39
- }, extraContent[check])
40
- }
41
-
42
-
43
- for ( k in updateObject ) {
44
- if ( mainData[`root/${k}`] && updateObject[k] ) {
45
- res.add ( k )
46
- if ( !extraContent[k] ) extraContent[k] = []
47
- extraContent[k].push ( updateObject[k] )
48
- }
49
-
50
- if ( mainObject[k] && updateObject[k]) {
51
- res.add ( k )
52
- if ( extraContent[k] ) extraContent[k].push ( updateObject[k] )
53
- else extraContent [ k ] = [ mainObject[k], updateObject[k]]
54
- }
55
- }
56
- return res
57
- }, new Set() )
58
-
59
- mainKeys.forEach ( key => { // Insert mainKeys but ignore duplicates
60
- let obj = mainData[key];
61
- result[key] = {}
62
- for ( k in obj ) {
63
- if ( !duplicateNames.has(k) ) result[key][k] = obj[k]
64
- }
65
- }) // forEach mainKeys
66
-
67
- updateKeys.forEach ( key => {
68
- let
69
- obj = update[key]
70
- , updateKeyList = Object.keys ( obj )
71
- , check = key.split ( '/' ).pop ()
72
- ;
73
- if ( duplicateNames.has(check) ) return
74
- updateKeyList.forEach ( k => {
75
- let testKey = `root/${k}`;
76
- if ( result[testKey] ) {
77
- let digitCount = _findDigitKeys ( result[testKey]);
78
- if ( obj[k] === '_fake$$$' ) return
79
- result[testKey][digitCount] = obj[k]
80
- return
81
- }
82
- if ( !duplicateNames.has(k) ) {
83
- if ( obj[k] === '_fake$$$' ) return
84
- result[key][k] = obj[k]
85
- }
86
- })
87
- }) // forEach updateKeys
88
-
89
-
90
-
91
- for ( k in extraContent ) {
92
- const resKey = `root/${k}`;
93
-
94
- result[resKey] = extraContent[k].reduce ( (res,item,i) => {
95
- res[i] = item
96
- return res
97
- },{})
98
- } // for extraContent
99
- return result
100
- } // combineShallow func.
101
-
102
-
103
-
104
-
105
-
106
- function _findDigitKeys ( obj ) {
107
- let count = 0;
108
- for ( k in obj ) {
109
- let isDigit = isNaN ( parseInt(k)) ? false : true;
110
- if ( isDigit ) count++
111
- } // for obj
112
- return count
113
- } // findDigitKeys func.
114
-
115
-
116
-
117
- module.exports = combineShallow
118
-
119
-
@@ -1,39 +0,0 @@
1
- const
2
- combineShallow = require ('./combineShallow')
3
- , separator = ';'
4
- ;
5
-
6
-
7
- function flatten ( mainData ) {
8
-
9
- let keyList = Object
10
- .keys ( mainData )
11
- .filter ( x => x != 'root' );
12
- let flatter = keyList.reduce ( (res,k) => {
13
- let update = { 'root': {...mainData[k]} }
14
- return combineShallow ( res, update )
15
- },{ 'root': {...mainData['root']}})
16
-
17
- let flatterKeyList = Object
18
- .keys ( flatter )
19
- .filter ( x => x != 'root' );
20
-
21
- return flatterKeyList.reduce ( (res,k) => {
22
- let
23
- key = k.split ('/')[1]
24
- , val = ''
25
- ;
26
- for ( prop in flatter[k]) {
27
- if ( val ) val += separator
28
- val += flatter[k][prop]
29
- }
30
- res['root'][key] = val
31
- return res
32
- }, {'root':{...flatter['root']}})
33
- } //flatten func.
34
-
35
-
36
-
37
- module.exports = flatten
38
-
39
-
@@ -1,34 +0,0 @@
1
- // NOTE: modifiers require a midFlat data-type for mainData and update
2
- const
3
- overwrite = require ( './overwrite' )
4
- , update = require ( './update' )
5
- , add = require ( './add' )
6
- , insert = require ( './insert' )
7
- , append = require ( './append' )
8
- , prepend = require ( './prepend' )
9
- , keyPrefix = require ( './keyPrefix' )
10
- , flatten = require ( './flatten' )
11
- , combineShallow = require ( './combineShallow' )
12
- , mix = require ( './mix' )
13
- , reverse = require ( './reverse' )
14
- ;
15
-
16
- const modifier = {
17
- add
18
- , update
19
- , overwrite
20
- , insert
21
- , append
22
- , prepend
23
- , keyPrefix
24
- , flatten
25
- , combineShallow
26
- , mix
27
- , reverse
28
- }
29
-
30
-
31
-
32
- module.exports = modifier
33
-
34
-
@@ -1,21 +0,0 @@
1
- function insert ( mainData, update ) {
2
- // *** Objects(midFlat) will be converted to arrays of values. Value will contain the collection of all values ( mainData and update)
3
- for (const updateKey in update ) {
4
- let
5
- mainVals = Object.values ( mainData[updateKey])
6
- , updateVals = Object.values ( update[updateKey] )
7
- , mixed = mainVals.concat ( updateVals )
8
- ;
9
- mainData[updateKey] = mixed.reduce ( (r,item,i) => {
10
- r[i] = item
11
- return r
12
- }, {} )
13
- }
14
- return mainData
15
- } // insert func.
16
-
17
-
18
-
19
- module.exports = insert
20
-
21
-
@@ -1,27 +0,0 @@
1
- function keyPrefix ( mainData, update ) {
2
- let
3
- keyList = Object.keys ( mainData )
4
- , { separationSymbol } = update
5
- ;
6
- return keyList.reduce ( (res,k) => {
7
- let
8
- name = k
9
- .substr ( 5 )
10
- .split ( '/' )
11
- .join ( separationSymbol )
12
- ;
13
- res[k] = {}
14
- let localList = Object.keys ( mainData[k]);
15
- localList.forEach ( kk => {
16
- if ( k == 'root' ) res[k][kk] = mainData['root'][kk]
17
- else res[k][`${name}${separationSymbol}${kk}`] = mainData[k][kk]
18
- })
19
- return res
20
- }, {})
21
- } // keyPrefix func.
22
-
23
-
24
-
25
- module.exports = keyPrefix
26
-
27
-
@@ -1,25 +0,0 @@
1
- const combine = require('../lib/combine');
2
- const combineShallow = require ( './combineShallow' );
3
-
4
- function mix ( mainData, update ) {
5
- const host = update.pop ();
6
- let master = {};
7
-
8
- master[host] = {...mainData[host]}
9
- if ( !master['root'] ) master['root'] = {...mainData['root']}
10
-
11
- return update.reduce ( (res,k) => {
12
- let
13
- mainObj = {root:{...res[host]}}
14
- , upObj = {root: {...mainData[k]}}
15
- ;
16
- res[host] = combineShallow ( mainObj, upObj ).root
17
- return res
18
- }, master )
19
- } // mix func.
20
-
21
-
22
-
23
- module.exports = mix
24
-
25
-
@@ -1,18 +0,0 @@
1
- function overwrite ( mainData, update ) {
2
- for (const updateKey in update ) {
3
- let selectObject = mainData[updateKey]
4
- if ( !selectObject ) mainData[updateKey] = {...update[updateKey]}
5
- else {
6
- for (let prop in update[updateKey]) {
7
- mainData[updateKey][prop] = update[updateKey][prop]
8
- }
9
- }
10
- }
11
- return mainData
12
- } // overwrite func.
13
-
14
-
15
-
16
- module.exports = overwrite
17
-
18
-
@@ -1,19 +0,0 @@
1
- function prepend ( mainData, update ) {
2
- // *** Concatinate values for duplicated props.
3
- for (const updateKey in update ) {
4
- if ( mainData[updateKey] ) {
5
- for (let prop in update[updateKey]) {
6
- const val = mainData[updateKey][prop];
7
- if ( val ) mainData[updateKey][prop] = update[updateKey][prop] + val
8
- else mainData[updateKey][prop] = update[updateKey][prop]
9
- }
10
- }
11
- }
12
- return mainData
13
- } // prepend func.
14
-
15
-
16
-
17
- module.exports = prepend
18
-
19
-
@@ -1,23 +0,0 @@
1
- function reverse ( mainData, list ) {
2
- let main = {...mainData };
3
- for ( const name of list ) {
4
- if ( main[name] ) {
5
- let
6
- source = {...main[name]}
7
- , keys = Object.keys(source)
8
- ;
9
- main[name] = {}
10
- keys.forEach ( k => {
11
- let v = source[k];
12
- main[name][v] = k
13
- })
14
- }
15
- }
16
- return main
17
- } // reverse func.
18
-
19
-
20
-
21
- module.exports = reverse
22
-
23
-
@@ -1,18 +0,0 @@
1
- function update ( mainData, update ) {
2
- for (const updateKey in update ) {
3
- if ( mainData.hasOwnProperty(updateKey) ) {
4
- for (let prop in update[updateKey]) {
5
- if ( mainData[updateKey].hasOwnProperty(prop) ) {
6
- mainData[updateKey][prop] = update[updateKey][prop]
7
- }
8
- }
9
- }
10
- }
11
- return mainData
12
- } // update func.
13
-
14
-
15
-
16
- module.exports = update
17
-
18
-
package/src/simple.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
-
4
-
5
- const simple = { // * Simple instruments
6
-
7
- notObject : function notObject ( str ) {
8
- let result = false
9
- if ( str == null ) { result = true }
10
- if ( typeof str == 'string' ) { result = true }
11
- if ( typeof str == 'number' ) { result = true }
12
- if ( typeof str == 'boolean' ) { result = true }
13
- if ( typeof str == 'function' ) { result = true }
14
- return result
15
- } // notObject func.
16
-
17
-
18
-
19
- , isObject : str => !simple.notObject(str)
20
- , folderKind : test => test instanceof Array ? 'array' : 'object'
21
- , getIterator : list => Object.keys ( list )
22
-
23
-
24
-
25
- , removeLast ( path ) {
26
- let list = path.split('/')
27
- list.pop()
28
- return list.join('/')
29
- } // removeLast func.
30
-
31
-
32
-
33
- , getPenult ( path ) {
34
- let list = path.split ( '/' )
35
- list.pop()
36
- return list.pop()
37
- } // getPenult func.
38
-
39
-
40
-
41
- , getUlt ( path ) {
42
- let list = path.split ( '/' )
43
- return list.pop()
44
- } // getUlt func.
45
-
46
- } // simple
47
-
48
-
49
- module.exports = simple
package/webpack.config.js DELETED
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- const webpack = require ( 'webpack' );
4
-
5
- module.exports = {
6
- entry: "./src/main.js"
7
- , mode: 'production'
8
- , output: {
9
- filename: "dt-toolbox.min.js"
10
- , path: __dirname + "/dist"
11
- , library: 'dtbox'
12
- , libraryTarget: "var"
13
- , umdNamedDefine : true
14
- }
15
- , optimization: {}
16
- , module: {
17
- rules: [
18
- {
19
- test: /\.js$/
20
- , exclude: /node_modules/
21
- , use : {
22
- loader: 'babel-loader'
23
- , options : { presets: ['@babel/preset-env']}
24
- }
25
- }
26
- ]
27
- }
28
- }