dt-toolbox 7.0.0 → 7.1.1

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  ## Release History
2
2
 
3
+ ### 7.1.1 (2023-09-05 )
4
+ - [x] Fix: Multiple queries in same programming scope;
5
+
6
+
7
+
8
+ ### 7.1.0 (2023-08-28)
9
+ - [x] Method `extractList` was added;
10
+ - [x] Fix: Method `model` recognizes '**files**' as a model;
11
+ - [x] Fix: Tuple model if data is just an array is wrong;
12
+ - [x] Fix: Convertor to files shows 'root' in the beginning of the path;
13
+ - [x] Fix: Convertor to breadcrumbs shows 'root' in the beginning of the path;
14
+ - [ ] Bug: Multiple queries in same programming scope;
15
+
16
+
17
+
3
18
  ### 7.0.0 (2023-07-15)
4
19
  - [x] Method `look` has new arguments: functions `next` and `finish`;
5
20
  - [x] To stop iteration on current dt-line `return next()`;
@@ -7,7 +22,12 @@
7
22
  - [x] Method `insert` was renamed to `insertSegment`;
8
23
  - [x] Method `listSegments` was added to show list of all segments in dt-object;
9
24
  - [x] Method `insertSegment` expect the incoming data as dt-object, but if is not - will assume it as a standard javascript object and will convert it to dt-object automatically;
10
- - [] Method `insertSegment` can recognize a dt model object.
25
+ - [ ] Method `insertSegment` can recognize a dt model object.
26
+ - [ ] Bug: Method `model` doesn't recognize '**files**' as a model;
27
+ - [ ] Bug: Tuple model if data is just an array is wrong;
28
+ - [ ] Bug: Convertor to files shows 'root' in the beginning of the path;
29
+ - [ ] Bug: Convertor to breadcrumbs shows 'root' in the beginning of the path;
30
+ - [ ] Bug: Multiple queries in same programming scope;
11
31
 
12
32
 
13
33
 
@@ -48,7 +48,24 @@ Method `insert` was renamed to `insertSegment` to be clear that data is not mixe
48
48
 
49
49
  Method `listSegments` was added to show list of all segments in dt-object.
50
50
 
51
+ After version 7.1.x method `extractList` was added. Method helps to extract from dt-object multiple segments and properties, defined in a list. Options are coming as a second argument. Use them to define a model of extracted data.
51
52
 
53
+ ```js
54
+ const
55
+ first = { name: 'first', data: 'first data' }
56
+ , second = { name: 'second', data: 'second data' }
57
+ , third = { name: 'third', data: 'third data' }
58
+ ;
59
+ const storage = dtbox.init ( first ); // first will become a root segment
60
+ storage.insertSegment ( 'second', second );
61
+ storage.insertSegment ( 'third', third );
62
+
63
+ const [ a, b c, firstData ] = storage.extractList ( ['first', 'second', 'third', 'data' ], { type: 'std' } ));
64
+ // a -> { name: 'first', data: 'first data' }
65
+ // b -> { name: 'second', data: 'second data' }
66
+ // c -> { name: 'third', data: 'third data' }
67
+ // firstData -> 'first data' // Field 'data' from main dt-line of 'root' segment.
68
+ ```
52
69
 
53
70
  ## From v.4.x.x - v.6.x.x
54
71
 
package/README.md CHANGED
@@ -3,23 +3,14 @@
3
3
  ![version](https://img.shields.io/github/package-json/v/peterNaydenov/dt-toolbox)
4
4
  ![license](https://img.shields.io/github/license/peterNaydenov/dt-toolbox)
5
5
 
6
- - [Documentatation for old v.6.x.x is here](htts://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.6.x.x.md)
7
6
 
8
7
 
8
+ ## Last Updates
9
9
 
10
- ## Breaking changes
11
- * In version 7 look functions have 2 new arguments: Function `finish` and `next`;
12
- * Instead of returning a string 'next'(in version 6) to stop iteration on current dt-line, now you have to `return next()`;
13
- * Function `finish` is a new option. Call `return finish()` to stop iteration on all dt-lines;
14
- * Method `insert` was renamed to `insertSegment` to be clear that data is not mixed. Segments are separated peaces of data;
10
+ After version 7.1.x `dt-object` api has a new method `extractList` that helps to extract a multiple segments or properties, defined as a list. Use '**options**'(the second argument) to define a model of extracted data if needed. Reed about `extractList` bellow.
15
11
 
16
12
 
17
13
 
18
- ## Other changes
19
- * Method `listSegments` was added to show list of all segments in dt-object;
20
- * Method `insertSegment` expect the incoming data as dt-object, but if is not - will assume it as a standard javascript object and will convert it to dt-object automatically;
21
-
22
-
23
14
  ## Description
24
15
 
25
16
  DT-Toolbox is created to simplify the work with deep nested javascript objects. The library was created as an immutable data-storage(dt-object), internally based on data-model called `DT-model`.
@@ -132,6 +123,7 @@ Take a look on the library APIs and see the '**Examples**' section bellow.
132
123
  , setupFilter : 'Evaluate data according "filter" function and create a shorter scan list that can be used by "dt-storage" during execution of query and model functions'
133
124
  , index : 'Provides a copy of specified dt-line by breadcrumbs'
134
125
  , listSegments : 'Returns a list of all segments in dt-object'
126
+ , extractList : 'Extracts a list of segments and/or properties from dt-object'
135
127
  ```
136
128
 
137
129
  ### dt-storage API Fast Reference
@@ -463,9 +455,10 @@ function modelFn ( store, a,v,g ) { // optional arguments will come directly aft
463
455
  as : 'std' // property 'as' will execute final conversion. Model name should be from supported list of the library.
464
456
  }
465
457
  }
458
+ // Supported model-names are:
459
+ // 'standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs'
466
460
 
467
461
  const result = dt.model ( modelFn, a,v,g ) // modelFn is the only required argument. All other arguments are optional.
468
-
469
462
  ```
470
463
 
471
464
  ### dt.setupFilter ()
@@ -523,6 +516,30 @@ dt.listSegments ()
523
516
  // [ 'root', 'extra' ]
524
517
  ```
525
518
 
519
+ ### dt.extractList ()
520
+
521
+ After version 7.1.x method `extractList` was added. Method can extract a list of segments and properties as a single instruction. Options are coming as a second argument. Use optioins(the second argument) to define a model of extracted data if needed. Modeling is applied only on objects.
522
+
523
+ If requested segment or property is not available, response will be '**null**'.
524
+ Segments have priority over properties. If there is a segment with the same name as a property, segment will be extracted.
525
+
526
+ ```js
527
+ const
528
+ first = { name: 'first', data: 'first data' }
529
+ , second = { name: 'second', data: 'second data' }
530
+ , third = { name: 'third', data: 'third data' }
531
+ ;
532
+ const storage = dtbox.init ( first ); // first will become a root segment
533
+ storage.insertSegment ( 'second', second );
534
+ storage.insertSegment ( 'third', third );
535
+
536
+ const [ a, b c, firstData, otherData ] = storage.extractList ( ['first', 'second', 'third', 'data', 'secondData' ], { type: 'std' } ));
537
+ // a -> { name: 'first', data: 'first data' }
538
+ // b -> { name: 'second', data: 'second data' }
539
+ // c -> { name: 'third', data: 'third data' }
540
+ // firstData -> 'first data' // Field 'data' from main dt-line of 'root' segment.
541
+ // otherData -> null // There is no 'secondData' in 'root' segment. No segment 'secondData' as well.
542
+ ```
526
543
 
527
544
 
528
545
 
@@ -1157,8 +1174,8 @@ console.log ( result )
1157
1174
 
1158
1175
 
1159
1176
  ## External Links
1160
- - [Migration guide](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Migration.guide.md)
1161
1177
  - [History of changes](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Changelog.md)
1178
+ - [Migration guide](https://github.com/PeterNaydenov/dt-toolbox/blob/master/Migration.guide.md)
1162
1179
  - [DT-Queries. Some useful query functions for DT-Toolbox](https://github.com/PeterNaydenov/dt-queries)
1163
1180
  - [Documentation v.4.x.x](https://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.4.x.x.md)
1164
1181
  - [Documentation v.2.x.x](https://github.com/PeterNaydenov/dt-toolbox/blob/master/README_v.2.x.x.md)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dt-toolbox",
3
3
  "description": "Data manipulation tool",
4
- "version": "7.0.0",
4
+ "version": "7.1.1",
5
5
  "license": "MIT",
6
6
  "author": "Peter Naydenov",
7
7
  "keywords": [
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "c8": "^8.0.1",
35
- "chai": "^4.3.7",
35
+ "chai": "^4.3.8",
36
36
  "mocha": "^10.2.0"
37
37
  },
38
38
  "c8": {
@@ -65,7 +65,7 @@ function to ( type, dependencies, inData ) { // convert from flat to 'data-typ
65
65
  return tuples.toType ( inData )
66
66
  case 'files':
67
67
  tups = tuples.toType ( inData );
68
- return tups.map ( ([k,v]) => `${k}/${v}`)
68
+ return tups.map ( ([k,v]) => (( k === 'root' ) ? v : `${k}/${v}`) )
69
69
  case 'breadcrumb' :
70
70
  case 'breadcrumbs':
71
71
  let current;
@@ -77,7 +77,7 @@ function to ( type, dependencies, inData ) { // convert from flat to 'data-typ
77
77
  current = k
78
78
  count = 0
79
79
  }
80
- let key = `${k}/${count}`;
80
+ let key = ( k === 'root' ) ? count : `${k}/${count}`
81
81
  breadcrumbs[key] = v
82
82
  count++
83
83
  }
@@ -140,18 +140,18 @@ function toFlat ( dependencies, d ) { // Converts data to 'dt' model
140
140
 
141
141
  function toType ( dt ) { // Converts data to tuples
142
142
  let result = [];
143
+
143
144
  dt.forEach ( line => {
144
145
  const
145
146
  [ name, flatData, breadcrumbs ] = line
146
147
  , isArray = flatData instanceof Array ? true : false
147
- // , result = []
148
148
  ;
149
149
  let nakedBread = '';
150
150
  if ( name !== 'root' ) nakedBread = breadcrumbs.replace ( `root/`, '' )
151
151
 
152
152
  if ( isArray ) {
153
- if ( nakedBread.length == 0 ) result.push (['root', el])
154
- else flatData.forEach ( el => result.push ([nakedBread, el]))
153
+ if ( nakedBread.length == 0 ) flatData.forEach ( (el,i) => result.push ([`root`, el]))
154
+ else flatData.forEach ( el => result.push ([nakedBread, el]))
155
155
  return
156
156
  }
157
157
 
@@ -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,13 @@
1
+ import push from './push.js'
2
+ import set from './set.js'
3
+ import connect from './connect.js'
4
+ import save from './save.js'
5
+
6
+
7
+
8
+ export default {
9
+ push
10
+ , set
11
+ , connect
12
+ , save
13
+ }
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  function get ( flatIO ) {
11
- return function find ( name ) {
11
+ return function get ( name ) {
12
12
  const list = [];
13
13
  flatIO.getScanList().every ( line => {
14
14
  const loc = line[2];
@@ -4,11 +4,6 @@ import insert from './insert.js'
4
4
  import ex from './export.js'
5
5
  import setupFilter from './setupFilter.js'
6
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
7
  import fr from './from.js'
13
8
  import use from './use.js'
14
9
  import find from './find.js'
@@ -16,13 +11,14 @@ import like from './like.js'
16
11
  import look from './look.js'
17
12
  import get from './get.js'
18
13
 
19
-
20
14
  // Default filters
21
15
  import list from './filters/list.js'
22
16
  import listObject from './filters/listObject.js'
23
17
  import object from './filters/object.js'
24
18
  import root from './filters/root.js'
25
19
 
20
+
21
+
26
22
  function flatData ( dependencies, d ) {
27
23
  const
28
24
  [ copy, indexes, flatData ] = d
@@ -31,11 +27,7 @@ function flatData ( dependencies, d ) {
31
27
  , filterFn = { list, listObject, object, root } // { filter functions}
32
28
  ;
33
29
 
34
- let
35
- selection = [] // Place for building a query/model result;
36
- , selectionIx = {}
37
- , scanList = flatData // Where 'look' function will be executed;
38
- ;
30
+ let scanList = flatData; // Where 'look' function will be executed;
39
31
 
40
32
  const
41
33
  getFilterNames = () => Object.keys ( filterFn )
@@ -60,35 +52,23 @@ function flatData ( dependencies, d ) {
60
52
  insert : insert ( flatStorage, filtering, getFilterNames ) // Insert a new rows to existing flatData;
61
53
  , export : ex ( flatStorage ) // Exports a copy of flatData;
62
54
  , getCopy : name => ( copy[name] ) ? copy[name] : null
63
- , getSelection : () => selection
64
- , getSelectionIx : () => selectionIx
65
55
  , getIndexes : () => indexes
66
56
  , getLine : k => indexes[k] ? indexes[k] : null
67
57
  , getFilters : () => filters
68
58
  , getScanList : () => scanList
69
59
  , setupScanList : l => scanList = l
70
60
  , 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 }
61
+ , resetScan : () => { scanList = flatData } // Reset the scanList to use all flatData;
73
62
  }
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
- }
63
+
80
64
  , 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;
65
+ // Query and Model functions will add methods related to new structure: set, connect, save, push;
66
+ from : fr ( flatIO_API ) // Scan: Scan deeper from object;
67
+ , use : use ( flatIO_API ) // Scan: Use filter to select objects to scan;
68
+ , get : get ( flatIO_API ) // Scan: Take a single object with specific breadcrumbs;
69
+ , find : find ( flatIO_API ) // Scan: String search for exact object name;
70
+ , like : like ( flatIO_API ) // Scan: String search in object name;
71
+ , look : look ( flatIO_API ) // Scan: Executes on each object property in the selection list;
92
72
  }
93
73
  ;
94
74
  return [ flatIO_API , flatStore_API ]
@@ -0,0 +1,46 @@
1
+ 'use strict'
2
+
3
+
4
+
5
+ function extractList ( dependencies, flatIO, indexFn ) {
6
+ return function exportList ( list, options={} ) {
7
+ const
8
+ root = indexFn ( 'root' )
9
+ , { main:{load} } = dependencies ()
10
+ , possibleAs = ['standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs', 'files', 'file' ]
11
+ ;
12
+ let
13
+ error = false
14
+ , errorMsg = ''
15
+ ;
16
+
17
+ if ( options ) {
18
+ if ( !options.as ) {
19
+ error = true
20
+ errorMsg = `Options should be an object and property "as" is required`
21
+ }
22
+ if ( !error && !possibleAs.includes(options.as) ) {
23
+ error = true
24
+ errorMsg = `Invalid option "as" value: ${options.as}. Choose one of: std, standard, ''`
25
+ }
26
+ if ( error ) throw new Error ( `Invalid option "as" value: ${options.as}` )
27
+ }
28
+
29
+ return list
30
+ .map ( name => {
31
+ let lines = flatIO.export ( name );
32
+ if ( lines.length === 0 ) return root[1][name] ? root[1][name] : null
33
+ else return lines
34
+ })
35
+ .map ( item => {
36
+ if ( item == null ) return null
37
+ if ( !(item instanceof Array)) return item
38
+ return options ? load(item).model(() => options ) : load(item)
39
+ })
40
+ }} // extractList func.
41
+
42
+
43
+
44
+ export default extractList
45
+
46
+
@@ -8,6 +8,9 @@ import copy from './copy.js'
8
8
  import model from './model.js'
9
9
  import query from './query.js'
10
10
  import setupFilter from './setupFilter.js'
11
+ import extractList from './extractList.js'
12
+
13
+
11
14
 
12
15
 
13
16
 
@@ -31,20 +34,24 @@ function flatObject ( dependencies, d ) {
31
34
  return res
32
35
  }, [] )
33
36
  }
34
- , index : n => {
35
- if ( n == null ) return null
36
- let r = flatIO.getLine(n)
37
- if ( r ) {
38
- let [ name, d, breadcrumbs, links ] = r;
39
- let copy;
40
- if ( d instanceof Array ) copy = [...d ]
41
- else copy = {...d }
42
- return [ name, copy, breadcrumbs, [...links] ]
43
- }
44
- else return null
45
- } // index
37
+ , index
46
38
  }
47
39
  ;
40
+
41
+ function index (n) {
42
+ if ( n == null ) return null
43
+ let r = flatIO.getLine(n)
44
+ if ( r ) {
45
+ let [ name, d, breadcrumbs, links ] = r;
46
+ let copy;
47
+ if ( d instanceof Array ) copy = [...d ]
48
+ else copy = {...d }
49
+ return [ name, copy, breadcrumbs, [...links] ]
50
+ }
51
+ else return null
52
+ } // index func.
53
+
54
+ objectAPI [ 'extractList' ] = extractList ( dependencies, flatIO, index )
48
55
  return objectAPI
49
56
  } // flatObject func.
50
57
 
@@ -8,7 +8,6 @@ return function insert ( name, inData ) {
8
8
  if ( isDTO(inData) ) {
9
9
  d = inData.export ()
10
10
  copy = inData.copy ()
11
-
12
11
  }
13
12
  else if ( isDTM(inData) ) {
14
13
  d = walk ({ data : inData })
@@ -4,13 +4,22 @@
4
4
 
5
5
  function model ( dependencies, flatIO ,flatStore ) {
6
6
  return function model () {
7
+ let
8
+ selection = [] // Place for building a query/model result;
9
+ , selectionIx = {}
10
+ ;
7
11
  const
8
- [ fn, ...args ] = arguments
9
- , { as } = fn ( flatStore, ...args ) || {}
10
- , { convert } = dependencies ()
11
- , selection = flatIO.getSelection ()
12
+ { convert, draft } = dependencies ()
13
+ , draft_API = {
14
+ set : draft.set ( selection, selectionIx ) // Selection: Creates a new row;
15
+ , connect : draft.connect ( selectionIx ) // Selection: Creates an edges among rows;
16
+ , save : draft.save ( selectionIx ) // Selection: Sets property+value in specified selection row;
17
+ , push : draft.push ( selectionIx ) // Selection: Adds a new value to selection row if data is an array structure;
18
+ }
19
+ , [ fn, ...args ] = arguments
20
+ , { as } = fn ( {...flatStore,...draft_API}, ...args ) || {}
12
21
  , data = ( selection.length === 0 ) ? flatIO.export() : selection
13
- , CONVERTOR_NAMES = [ 'standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs' ]
22
+ , CONVERTOR_NAMES = [ 'standard', 'std', 'midFlat', 'tuple', 'tuples', 'breadcrumb', 'breadcrumbs', 'files', 'file' ]
14
23
  , hasConvertor = as ? CONVERTOR_NAMES.includes ( as ) : false
15
24
  ;
16
25
 
@@ -19,9 +28,10 @@ return function model () {
19
28
  console.error ( `Model '${as}' is unknown data-model.` )
20
29
  return null
21
30
  }
31
+
22
32
  if ( as ) result = convert.to ( as, dependencies, data )
23
33
  else result = data
24
- flatIO.reset ()
34
+ flatIO.resetScan ()
25
35
  return result
26
36
  }} // model func.
27
37
 
@@ -2,19 +2,28 @@
2
2
 
3
3
 
4
4
 
5
- function query ( dependencies, flatIO ,flatStore ) {
5
+ function query ( dependencies, flatIO, flatStore ) {
6
6
  return function query () {
7
7
  const
8
- { main } = dependencies ()
9
- , { load } = main ()
8
+ { main:{load}, draft } = dependencies ()
10
9
  , [ fn, ...args ] = arguments
11
10
  ;
11
+ let
12
+ selection = [] // Place for building a query/model result;
13
+ , selectionIx = {}
14
+ ;
15
+
16
+ const draft_API = {
17
+ set : draft.set ( selection, selectionIx ) // Selection: Creates a new row;
18
+ , connect : draft.connect ( selectionIx ) // Selection: Creates an edges among rows;
19
+ , save : draft.save ( selectionIx ) // Selection: Sets property+value in specified selection row;
20
+ , push : draft.push ( selectionIx ) // Selection: Adds a new value to selection row if data is an array structure;
21
+ }
12
22
 
13
- fn ( flatStore, ...args )
14
- const result = flatIO.getSelection ();
15
- flatIO.reset ()
16
- if ( result.length === 0 ) return this
17
- return load ( result )
23
+ fn ( {...flatStore, ...draft_API}, ...args )
24
+ flatIO.resetScan ()
25
+ if ( selection.length === 0 ) return this
26
+ return load ( selection )
18
27
  }} // query func.
19
28
 
20
29
 
package/src/main.js CHANGED
@@ -4,7 +4,7 @@
4
4
  DT object & DT Toolbox
5
5
  =======================
6
6
 
7
- Version 6.0.0
7
+ Version 7.1.0
8
8
 
9
9
  History notes:
10
10
  - Idea was born on March 17th, 2016.
@@ -30,6 +30,10 @@
30
30
  * Data inserts;
31
31
  * Filters for faster data scan;
32
32
  * Model and query functions to shape results;
33
+
34
+ - Version 7.1.0 published on August 29th, 2023
35
+ * Some fixes on version v.7.0.0;
36
+ * New method `extractList` for multiple data extraction from dt-model;
33
37
  */
34
38
 
35
39
 
package/src/mainLib.js CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
  import walk from '@peter.naydenov/walk'
6
6
 
7
- import flatObject from './flatObject/index.js' // Flat data api.
8
- import flatData from './flatData/index.js' // Query data api. Used in model functions
9
- import convert from './convertors/index.js' // Convertors
7
+ import flatObject from './flatObject/index.js' // Flat data api.
8
+ import flatData from './flatData/index.js' // Query data api. Used in model functions
9
+ import convert from './convertors/index.js' // Convertors
10
+ import draft from './draft/index.js' // Build a dt-model api
10
11
 
11
12
 
12
13
 
@@ -31,7 +32,7 @@ const mainLib = {
31
32
  , flatObject
32
33
  , convert
33
34
  , INIT_DATA_TYPES
34
- , main : () => ({ load : mainLib.load })
35
+ , main : { load : mainLib.load }
35
36
  , isDTO : d => typeof d.insertSegment === 'function'
36
37
  , isDTM : d => {
37
38
  if ( !(d instanceof Array)) return false
@@ -40,7 +41,7 @@ const mainLib = {
40
41
  if ( d[0][0] !== 'root' ) return false
41
42
  return true
42
43
  }
43
- ,
44
+ , draft
44
45
  }
45
46
  } // dependencies func.
46
47
 
@@ -56,11 +57,8 @@ const mainLib = {
56
57
  console.error ( `Can't understand your data-model: ${model}. Please, find what is possible on https://github.com/PeterNaydenov/dt-toolbox` )
57
58
  return null
58
59
  }
59
- const
60
- d = convert.from(model).toFlat ( dependencies, inData )
61
- , flat = flatObject ( dependencies, d )
62
- ;
63
- return flat
60
+ const d = convert.from(model).toFlat ( dependencies, inData );
61
+ return flatObject ( dependencies, d )
64
62
  } // init func.
65
63
 
66
64
 
File without changes
File without changes
File without changes