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,171 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function toFlat ( dependencies, d ) { // Converts data to 'dt' model
6
+ const
7
+ { walk } = dependencies ()
8
+ , indexes = {}
9
+ , buffer = {root:[]}
10
+ , dt = []
11
+ ;
12
+ function readKey ( k ) {
13
+ let name, crumbs, key;
14
+ if ( k == 'root' ) {
15
+ name= 'root'
16
+ crumbs = 'root'
17
+ key = null
18
+ return [ name, crumbs, key ]
19
+ }
20
+
21
+ const splited = k.split ( '/' )
22
+ if ( splited.length === 2 ) {
23
+ name = 'root'
24
+ crumbs = 'root'
25
+ key = splited.pop ()
26
+ }
27
+ if ( splited.length > 2 ) {
28
+ key = splited.pop ()
29
+ name = splited.pop ()
30
+ if ( splited.length === 0 ) crumbs = `root/${name}`
31
+ else crumbs = `${splited.join('/')}/${name}`
32
+ }
33
+ return [ name, crumbs, key ]
34
+ } // readKey func.
35
+
36
+
37
+
38
+ function makeContainers ( k ) {
39
+ if ( k === 'root' ) return
40
+ const ar = k.split ( '/' );
41
+ ar.pop ()
42
+ const container = ar.join ( '/' );
43
+ if ( !buffer[container] ) buffer[container] = []
44
+ if ( container.includes('/') ) makeContainers(container)
45
+ } // makeContainers func.
46
+
47
+
48
+
49
+ d.forEach ( tupleRow => {
50
+ const [ k, v ] = tupleRow
51
+ , key = ( k === 'root') ? 'root' : `root/${k}`
52
+ ;
53
+ if ( buffer[key] ) buffer[key].push ( v )
54
+ else buffer[key] = [ v ]
55
+ makeContainers ( key )
56
+ }) // d forEach
57
+
58
+
59
+
60
+ // Setup containers only objects/arrays
61
+ let bufferEntries = Object.entries ( buffer ).sort();
62
+ const containers = { root:'object' }
63
+ bufferEntries.forEach ( ([k,v]) => {
64
+ if ( k === 'root' ) return
65
+ const
66
+ arr = k.split('/')
67
+ , el = arr.pop ()
68
+ , parent = arr.join ( '/' )
69
+ , notArray = (containers[parent] === 'array') ? false : true
70
+ ;
71
+ if ( notArray && !isNaN(el) ) containers[parent] = 'array'
72
+ if ( v.length === 0 ) containers[k] = 'object'
73
+ })
74
+
75
+
76
+
77
+ // Fill the data
78
+ bufferEntries = Object.entries ( buffer ).sort();
79
+ bufferEntries.forEach ( ([ k, v]) => {
80
+ const
81
+ [ name, crumbs, key ] = readKey ( k )
82
+ , isContainer = (v.length === 0) ? true : false
83
+ , isProp = (v.length === 1) ? true : false
84
+ ;
85
+ let line, structure;
86
+
87
+ if ( isContainer ) {
88
+ if ( indexes[`${crumbs}/${key}`] ) return
89
+ if ( key == null ) { // case 'root'
90
+ structure = (containers['root'] === 'object') ? {} : []
91
+ line = [ 'root', structure, 'root', []]
92
+ indexes['root'] = line
93
+ dt.push ( line )
94
+ return
95
+ }
96
+
97
+ structure = ( containers[`${crumbs}/${key}`] === 'object' ) ? {} : [];
98
+ line = [ key, structure, `${crumbs}/${key}`, [] ]
99
+ indexes[`${crumbs}/${key}`] = line
100
+ dt.push ( line )
101
+ return
102
+ }
103
+
104
+ if ( !isProp ) { // arrays with values
105
+ line = [ key, v, `${crumbs}/${key}`, []]
106
+ indexes [`${crumbs}/${key}`] = line
107
+ dt.push ( line )
108
+ return
109
+ }
110
+
111
+ if ( indexes[`${crumbs}`] ) indexes[crumbs][1][key] = v[0]
112
+ else {
113
+ const obj = {}
114
+ obj[key] = v[0]
115
+ line = [ name, obj, crumbs, []]
116
+ indexes[crumbs] = line
117
+ dt.push ( line )
118
+ }
119
+ }) // buffEntries forEach
120
+
121
+ // Setup edges
122
+ dt.reverse ()
123
+ dt.forEach ( line => {
124
+ const
125
+ [ name, flatData, breadcrumbs ] = line
126
+ , parentCrumbs = breadcrumbs.replace ( `/${name}`, '' )
127
+ , l = indexes[parentCrumbs]
128
+ ;
129
+ if ( parentCrumbs === breadcrumbs ) return
130
+ if ( l ) l[3].push ( breadcrumbs )
131
+ }) // revDT
132
+ dt.reverse ()
133
+ const copy = walk ({ data : d });
134
+ return [ copy, indexes, dt ]
135
+ } // toFlat func.
136
+
137
+
138
+
139
+
140
+
141
+ function toType ( dt ) { // Converts data to tuples
142
+ let result = [];
143
+ dt.forEach ( line => {
144
+ const
145
+ [ name, flatData, breadcrumbs ] = line
146
+ , isArray = flatData instanceof Array ? true : false
147
+ // , result = []
148
+ ;
149
+ let nakedBread = '';
150
+ if ( name !== 'root' ) nakedBread = breadcrumbs.replace ( `root/`, '' )
151
+
152
+ if ( isArray ) {
153
+ if ( nakedBread.length == 0 ) result.push (['root', el])
154
+ else flatData.forEach ( el => result.push ([nakedBread, el]))
155
+ return
156
+ }
157
+
158
+ const scan = Object.entries ( flatData )
159
+ scan.forEach ( ([k, v]) => {
160
+ if ( nakedBread.length == 0 ) result.push ([k, v])
161
+ else result.push ([`${nakedBread}/${k}`, v])
162
+ })
163
+ }) // forEach line
164
+ return result
165
+ } // toType func.
166
+
167
+
168
+
169
+ export default { toFlat, toType }
170
+
171
+
@@ -0,0 +1,50 @@
1
+ 'use strict'
2
+
3
+
4
+ function connect ( selectionIx ) {
5
+ return function connect ( list ) {
6
+ list.forEach ( item => {
7
+ let arr = item.split ( '/' )
8
+ const
9
+ child = arr.pop ()
10
+ , parent = arr.pop ()
11
+ , line = selectionIx[parent]
12
+ , childLine = selectionIx[child]
13
+ ;
14
+
15
+ if ( !childLine ) return this
16
+ if ( !line ) return this
17
+ if ( line[1][child] ) return this
18
+
19
+ let breadcrumbs = `${line[2]}/${child}`;
20
+
21
+ updateBreadcrumbs ( selectionIx , child, breadcrumbs )
22
+ if ( line[3].includes(breadcrumbs) ) return this
23
+ line[3].push ( breadcrumbs )
24
+ return this
25
+ })
26
+ }} // connect func.
27
+
28
+
29
+
30
+ function updateBreadcrumbs ( selectionIx, child, bread ) {
31
+ const
32
+ childLine = selectionIx[child]
33
+ , oldBread = childLine [2]
34
+ ;
35
+
36
+ childLine[2] = bread
37
+ selectionIx[oldBread] = childLine
38
+
39
+ childLine[3].forEach ( (br,i) => {
40
+ const search = new RegExp (`^${oldBread}\/`);
41
+ const brUpdate = br.replace ( search, `${bread}/` );
42
+ updateBreadcrumbs ( selectionIx[br], br, brUpdate )
43
+ })
44
+ } // updateBreadcrumbs func.
45
+
46
+
47
+
48
+ export default connect
49
+
50
+
@@ -0,0 +1,46 @@
1
+ 'use struct'
2
+
3
+ function ex ( flatStorage ) {
4
+ return function ex ( name ) {
5
+ const [ , indexes, flatData ] = flatStorage;
6
+
7
+ if ( name && !indexes[name] ) return []
8
+ if ( !name ) {
9
+ const exportCopy = []
10
+ flatData.forEach ( line => {
11
+ const
12
+ [ lnName, data, breadcrumbs, edges ] = line
13
+ , dataChange = ( data instanceof Array ) ? [ ...data] : { ...data }
14
+ ;
15
+ exportCopy.push ([ lnName, dataChange, breadcrumbs, [...edges] ])
16
+
17
+ })
18
+ return exportCopy
19
+ }
20
+
21
+ // If existing name:
22
+ const selection = [];
23
+ flatData.forEach ( line => {
24
+ const
25
+ [ lnName, data, breadcrumbs, edges ] = line
26
+ , search = new RegExp ( `^${name}\/`)
27
+ ;
28
+ if ( breadcrumbs === name || breadcrumbs.match(search) ) {
29
+ let
30
+ nameChange = ( lnName === breadcrumbs ) ? 'root' : lnName
31
+ , dataChange = ( data instanceof Array ) ? [ ...data ] : { ...data }
32
+ , breadcrumbsChange = ( breadcrumbs.includes('/') ) ? breadcrumbs.replace ( search, 'root/' ) : 'root'
33
+ , edgesChange = edges.map ( edge => edge.replace ( search, 'root/'))
34
+ ;
35
+ selection.push ([ nameChange, dataChange, breadcrumbsChange, edgesChange ])
36
+ }
37
+
38
+ })
39
+ return selection
40
+ }}
41
+
42
+
43
+
44
+ export default ex
45
+
46
+
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ function list ({flatData}) {
4
+ if ( flatData instanceof Array ) return true
5
+ return false
6
+ } // list func.
7
+
8
+
9
+ export default list
10
+
11
+
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ function listObject ({name,flatData}) {
4
+ if ( flatData instanceof Array ) return false
5
+ if ( !isNaN(name) ) return true
6
+ return false
7
+ } // listObject func.
8
+
9
+
10
+
11
+ export default listObject
12
+
13
+
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ function object ({flatData}) {
4
+ if ( flatData instanceof Array ) return false
5
+ return true
6
+ } // object func.
7
+
8
+
9
+
10
+ export default object
11
+
12
+
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ function root ({name,breadcrumbs}) {
4
+ if ( name === breadcrumbs ) return true
5
+ return false
6
+ } // root func.
7
+
8
+
9
+
10
+ export default root
11
+
12
+
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function find ( flatIO ) {
6
+ return function find ( name ) {
7
+ const list = [];
8
+ flatIO.getScanList().forEach ( line => {
9
+ const lnName = line[0];
10
+ if ( lnName === name ) list.push( line )
11
+ })
12
+ flatIO.setupScanList ( list )
13
+ return this
14
+ }} // find func.
15
+
16
+
17
+
18
+ export default find
19
+
20
+
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+
4
+ function fr ( flatIO ) {
5
+ return function fr ( breadcrumbs ) {
6
+ const
7
+ indexes = flatIO.getIndexes ()
8
+ , start = indexes[breadcrumbs]
9
+ , list = []
10
+ ;
11
+
12
+ if ( !start ) return this
13
+ list.push ( start )
14
+ findDeep ( indexes, list, start[3] )
15
+ flatIO.setupScanList ( list )
16
+ return this
17
+ }} // fr func.
18
+
19
+
20
+ function findDeep ( indexes, list, ls ) {
21
+ ls.forEach ( br => {
22
+ const line = indexes[br];
23
+ if ( !line ) return
24
+ list.push ( line )
25
+ findDeep ( indexes, list, line[3] )
26
+ })
27
+ } // findDeep func.
28
+
29
+
30
+
31
+ export default fr
32
+
33
+
@@ -0,0 +1,29 @@
1
+ 'use strict'
2
+
3
+ /**
4
+ * Find an object on specific route
5
+ *
6
+ */
7
+
8
+
9
+
10
+ function get ( flatIO ) {
11
+ return function find ( name ) {
12
+ const list = [];
13
+ flatIO.getScanList().every ( line => {
14
+ const loc = line[2];
15
+ if ( loc === name ) {
16
+ list.push( line )
17
+ return false
18
+ }
19
+ return true
20
+ })
21
+ flatIO.setupScanList ( list )
22
+ return this
23
+ }} // get func.
24
+
25
+
26
+
27
+ export default get
28
+
29
+
@@ -0,0 +1,101 @@
1
+ 'use strict'
2
+
3
+ import insert from './insert.js'
4
+ import ex from './export.js'
5
+ import setupFilter from './setupFilter.js'
6
+
7
+ import set from './set.js'
8
+ import connect from './connect.js'
9
+ import save from './save.js'
10
+ import push from './push.js'
11
+
12
+ import fr from './from.js'
13
+ import use from './use.js'
14
+ import find from './find.js'
15
+ import like from './like.js'
16
+ import look from './look.js'
17
+ import get from './get.js'
18
+
19
+
20
+ // Default filters
21
+ import list from './filters/list.js'
22
+ import listObject from './filters/listObject.js'
23
+ import object from './filters/object.js'
24
+ import root from './filters/root.js'
25
+
26
+ function flatData ( dependencies, d ) {
27
+ const
28
+ [ copy, indexes, flatData ] = d
29
+ , flatStorage = [ copy, indexes, flatData ]
30
+ , filters = {} // { filterName : [selected flat items] }
31
+ , filterFn = { list, listObject, object, root } // { filter functions}
32
+ ;
33
+
34
+ let
35
+ selection = [] // Place for building a query/model result;
36
+ , selectionIx = {}
37
+ , scanList = flatData // Where 'look' function will be executed;
38
+ ;
39
+
40
+ const
41
+ getFilterNames = () => Object.keys ( filterFn )
42
+ , filtering = ( filterName, line ) => {
43
+ if ( filterFn[filterName] ) {
44
+ const [ name, flatData, breadcrumbs, edges ] = line;
45
+ if ( !filters[filterName] ) filters[filterName] = []
46
+ if ( filterFn[filterName]({name, flatData, breadcrumbs, edges}) ) {
47
+ const item = indexes[breadcrumbs];
48
+ filters[filterName].push ( item )
49
+ }
50
+ }
51
+ }
52
+ ;
53
+
54
+ // Apply default filters
55
+ const filterNames = getFilterNames ();
56
+ filterNames.forEach ( name => flatData.forEach ( line => filtering(name, line) ))
57
+
58
+ const
59
+ flatIO_API = {
60
+ insert : insert ( flatStorage, filtering, getFilterNames ) // Insert a new rows to existing flatData;
61
+ , export : ex ( flatStorage ) // Exports a copy of flatData;
62
+ , getCopy : name => ( copy[name] ) ? copy[name] : null
63
+ , getSelection : () => selection
64
+ , getSelectionIx : () => selectionIx
65
+ , getIndexes : () => indexes
66
+ , getLine : k => indexes[k] ? indexes[k] : null
67
+ , getFilters : () => filters
68
+ , getScanList : () => scanList
69
+ , setupScanList : l => scanList = l
70
+ , setupFilter : setupFilter ( flatStorage, filterFn, filtering, getFilterNames ) // Add and apply a new filter function to flatData;
71
+ , reset : () => { selection = [], scanList = flatData } // Removes 'selection' and reset the scanList to use all flatData;
72
+ , resetScan : () => { scanList = flatData }
73
+ }
74
+ , flatStoreSelection_API = {
75
+ set : set ( selection, selectionIx ) // Selection: Creates a new row;
76
+ , connect : connect ( selectionIx ) // Selection: Creates an edges among rows;
77
+ , save : save ( selectionIx ) // Selection: Sets property+value in specified selection row;
78
+ , push : push ( selectionIx ) // Selection: Adds a new value to selection row if data is an array structure;
79
+ }
80
+ , flatStore_API = {
81
+ set : flatStoreSelection_API.set
82
+ , connect : flatStoreSelection_API.connect
83
+ , save : flatStoreSelection_API.save
84
+ , push : flatStoreSelection_API.push
85
+
86
+ , from : fr ( flatIO_API ) // Scan: Scan deeper from object;
87
+ , use : use ( flatIO_API ) // Scan: Use filter to select objects to scan;
88
+ , get : get ( flatIO_API ) // Scan: Take a single object with specific breadcrumbs;
89
+ , find : find ( flatIO_API ) // Scan: String search for exact object name;
90
+ , like : like ( flatIO_API ) // Scan: String search in object name;
91
+ , look : look ( flatIO_API ) // Scan: Executes on each object property in the selection list;
92
+ }
93
+ ;
94
+ return [ flatIO_API , flatStore_API ]
95
+ } // flatData func.
96
+
97
+
98
+
99
+ export default flatData
100
+
101
+
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ function insert ( flat, flitering, getFilterNames ) {
4
+ return function insert ( d ) {
5
+ const
6
+ [ copy,, flatData ] = d
7
+ , name = flatData[0][0]
8
+ , [ copies, indexes, flatStorage ] = flat
9
+ , filterNames = getFilterNames ()
10
+ ;
11
+ copies [ name ] = copy
12
+ flatData.forEach ( line => {
13
+ const [ ,, breadcrumbs ] = line;
14
+ indexes[breadcrumbs] = line
15
+ flatStorage.push ( line )
16
+ filterNames.forEach ( fname => flitering (fname, line ) )
17
+ })
18
+ }} // insert func.
19
+
20
+
21
+
22
+ export default insert
23
+
24
+
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function like ( flatIO ) {
6
+ return function like ( name ) {
7
+ const
8
+ list = []
9
+ , listNames = (name instanceof Array) ? name : [name]
10
+ ;
11
+
12
+ flatIO.getScanList().forEach ( line => {
13
+ const lnName = line[0];
14
+ listNames.forEach ( nm => { if ( lnName.includes(nm) ) list.push ( line ) })
15
+ })
16
+ flatIO.setupScanList ( list )
17
+ return this
18
+ }} // like func.
19
+
20
+
21
+
22
+ export default like
23
+
24
+
@@ -0,0 +1,49 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function look ( flatIO ) {
6
+ return function look ( fn ) {
7
+ flatIO.getScanList().forEach ( line => {
8
+ const
9
+ [ name, flatData, breadcrumbs, edges ] = line
10
+ , isArray = flatData instanceof Array ? true : false
11
+ ;
12
+
13
+ const links = edges.map ( edge => {
14
+ let child = edge.replace ( `${breadcrumbs}/`, '')
15
+ return [ name, child ]
16
+ })
17
+
18
+ if ( isArray ) {
19
+ if ( flatData.length === 0 ) empty([])
20
+ else {
21
+ flatData.every ( (value,key) => {
22
+ const callback = fn({ value, key, name, flatData, breadcrumbs, links });
23
+ return ( callback === 'next' ) ? false : true
24
+ })
25
+ }
26
+ }
27
+ else {
28
+ const test = Object.entries(flatData);
29
+ if ( test.length === 0 ) empty({})
30
+ else {
31
+ test.every ( ([key, value]) => {
32
+ const callback = fn ({ value, key, name, flatData, breadcrumbs, links });
33
+ return ( callback === 'next' ) ? false : true
34
+ })
35
+ }
36
+
37
+ }
38
+ function empty ( flatData ) {
39
+ fn ({ value:null, key:null, name, flatData, breadcrumbs, links, empty: true })
40
+ } // empty func.
41
+ flatIO.resetScan ()
42
+ })
43
+ }} // look func.
44
+
45
+
46
+
47
+ export default look
48
+
49
+
@@ -0,0 +1,19 @@
1
+ 'use strict'
2
+
3
+
4
+ function push ( selectionIx ) {
5
+ return function push ( target, val ) {
6
+ const line = selectionIx[target] ? selectionIx[target][1] : false;
7
+
8
+ if ( !line ) return this
9
+ if ( !(line instanceof Array) ) return this
10
+ if ( typeof value === 'object' ) return this
11
+ line.push ( val )
12
+ return this
13
+ }} // push func.
14
+
15
+
16
+
17
+ export default push
18
+
19
+
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+
4
+ function save ( selectionIx ) {
5
+ return function save ( target, key, value ) {
6
+ const lineData = selectionIx[target] ? selectionIx[target][1] : false;
7
+ if ( !lineData ) return this
8
+ if ( lineData[key] ) return this
9
+ lineData[key] = value
10
+ return this
11
+ }} // save func.
12
+
13
+
14
+
15
+ export default save
16
+
17
+
@@ -0,0 +1,26 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function set ( selection, selectionIx ) {
6
+ return function set ( name, data ) {
7
+ const
8
+ isArray = ( data instanceof Array )
9
+ , newRecord = []
10
+ ;
11
+
12
+ newRecord.push (name)
13
+ if ( isArray ) newRecord.push ( [...data] )
14
+ else newRecord.push ( {...data} )
15
+ newRecord.push ( name )
16
+ newRecord.push ( [] )
17
+ selection.push ( newRecord )
18
+ selectionIx[name] = newRecord
19
+ return this
20
+ }} // set func.
21
+
22
+
23
+
24
+ export default set
25
+
26
+