Skip to content

Commit 7348f08

Browse files
author
hs
committed
update
1 parent 530d35a commit 7348f08

26 files changed

+6307
-7056
lines changed

docs/data/hsDatab.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"flags": {
1313
"isExported": true
1414
},
15-
"originalName": "/Users/sth1pal/Documents/Development/JavaScript/nodejs/ts6/dev/hsLibs/standalone/hsDatab/src/Data.ts",
15+
"originalName": "/Downloads/npm/hsDatab/src/Data.ts",
1616
"comment": {},
1717
"children": [
1818
{
@@ -2667,7 +2667,7 @@
26672667
"flags": {
26682668
"isExported": true
26692669
},
2670-
"originalName": "/Users/sth1pal/Documents/Development/JavaScript/nodejs/ts6/dev/hsLibs/standalone/hsDatab/src/DataFilters.ts",
2670+
"originalName": "/Downloads/npm/hsDatab/src/DataFilters.ts",
26712671
"comment": {
26722672
"shortText": "Use the {@link filter `filter`} function to executes a queries on a {@link Data `Data`} object.\nEach row in the data is checked and those for which `conditions` holds true are returned as a new `Data` object.",
26732673
"text": "# Condition construction\n\n### General Condition\n```\nCondition =\n IndexCondition -> conditions on the row index\n|| RecursiveCondition -> (set of) conditions on column values\n```\n\n### IndexCondition\n```\nIndexCondition =\n rowIndex:number -> true if row index matches\n```\n\n### RecursiveCondition\n```\nRecursiveCondition =\n OrCondition -> OR: true if any compound condition is true\n|| AndCondition -> AND: true if all compound conditions are true\n\nOrCondition = -> OR: true if\n AndCondition[] -> any of the AndConditions are true\n|| IndexCondition[] -> any of thr IndexConditions are true\n\nAndCondition = -> AND: true if\n SetAndCondition -> all SetAndConditions are true\n|| TermAndCondition -> or if all TermAndConditions are true\n\nSetAndCondition = { -> AND: true if all sub-conditions are true\n 'or': RecursiveCondition -> true if any RecursiveCondition is true\n|| 'and': RecursiveCondition -> true if all RecursiveCondition are true\n|| 'not': RecursiveCondition -> true if the condition is false\n\nTermAndCondition = { -> Terminal AND: true if all terminal sub-conditions are true\n colDesc:colValue -> true if colValue matches\n|| colDesc:[colValue, ...] -> true if any of the colValues match\n|| colDesc:function(value,row) -> true if function returns true\n}\n\ncolDesc = either column name or index\n```\n\n### Practical Tips\n```\n {'or': [recurCond, ...]} -> OR, same as [recurCond, ...]\n|| {'or': {SetCond, ...}} -> OR, same as [SetCond, ...]\n|| {'and': [recurCond, ...]} -> AND, true if all recurCond are true\n|| {'and': {SetCond, ...}} -> AND, same as {SetCond, ...}\n|| {'not': {SetCond, ...}} -> NAND: true if the SetCond are true\n|| {'not': [recurCond, ...]} -> NOR: true if any of the recurCond are true\n```\n\n# Example\n<example height=1000px>\n<file name=\"script.js\">\nconst colNames = ['Name', 'Value', 'Start', 'End'];\nconst rows = [\n ['Harry', '100', '3/1/14', '11/20/14'],\n ['Mary', '1500', '7/1/14', '9/30/14'],\n ['Peter', '400', '5/20/14', '4/30/15'],\n ['Jane', '700', '11/13/14', '8/15/15']\n]\nconst data = new hsdatab.Data({colNames:colNames, rows:rows});\n\nqueries = [\n ['0', undefined, 'undefined query => pass all'],\n ['1', [], 'empty OR: [] => fail all'],\n ['2', {}, 'empty AND: {} => pass all'],\n ['3', 1, '2nd row: pass row 1'],\n ['4', [1,3], '2nd+4th: pass rows: 1 and 3'],\n ['5', {Name:\"Jane\"}, 'Name is Jane'],\n ['6', {1:1500}, 'Column 2 is 1500'],\n ['7', {Name:[\"Peter\", \"Jane\"]}, 'Name is Peter or Jane'],\n ['8', [{Name:\"Peter\"}, {Value:1500}], 'Name is Peter or Value is 1500'],\n ['9', {or:{Name:\"Peter\", Value:1500}}, 'OR: same as 8:'],\n ['A', {or:[{Name:\"Peter\"}, {Value:1500}]}, 'OR: [{Name is Peter}, {Value is 1500}]'],\n ['B', {Name:\"Peter\", Value:400}, 'Name is Peter and Value is 400'],\n ['C', {and:{Name:\"Peter\", Value:400}}, 'AND: {Name is Peter, Value is 400}'],\n ['D', {and:{Name:\"Peter\", Value:1500}}, 'AND: {Name is Peter, Value is 1500}'],\n ['E', {and:[{Name:\"Peter\"}, {Value:400}]}, 'AND:[{Name is Peter}, {Value is 400}]'],\n ['F', {and:[{Name:\"Peter\"}, {Value:1500}]},'AND:[{Name is Peter}, {Value is 1500}]'],\n ['G', {not:{Name:\"Peter\", Value:400}}, 'NAND: not {Name is Peter and Value is 400}'],\n ['H', {not:{Name:\"Peter\", Value:1500}}, 'NAND: not {Name is Peter and Value is 1500}'],\n ['I', {not:[{Name:\"Peter\"}, {Value:1500}]},'NOR: not [{Name is Peter} or {Value is 1500}]'],\n ['J', {Name:(v) => v.length===4}, 'Name has 4 letters']\n];\n\nm.mount(root, {\n view:() => m('', [\n m('h3', 'Given the data set:'),\n m('table#data', [\n m('tr', colNames.map(n => m('th', n))),\n ...rows.map(row => m('tr', [m('td', row[0]),m('td', row[1]),m('td', row[2].toDateString()),m('td', row[3].toDateString())]))\n ]),\n m('h3', 'The following queries yield:'),\n m('table', [\n m('tr', [m('th','#'), m('th','Query'), m('th',\"Live Result, by 'Name' field\")]),\n ...queries.map(q => {\n const result = data.filter(q[1]).getColumn('Name').join(', ');\n return m('tr', [m('td',`${q[0]}:`), m('td',`${q[2]}`), m('td',`[ ${result} ]`)]);\n })\n ])\n ])\n});\n</file>\n<file name='style.css'>\n $exampleID { height: 600px; }\n #data th { width:15%; }\n table {\n font-size: 10pt;\n margin-left: 10px;\n }\n</file>\n</example>\n"
@@ -3421,7 +3421,7 @@
34213421
"flags": {
34223422
"isExported": true
34233423
},
3424-
"originalName": "/Users/sth1pal/Documents/Development/JavaScript/nodejs/ts6/dev/hsLibs/standalone/hsDatab/src/index.ts",
3424+
"originalName": "/Downloads/npm/hsDatab/src/index.ts",
34253425
"sources": [
34263426
{
34273427
"fileName": "index.ts",
@@ -3438,7 +3438,7 @@
34383438
"flags": {
34393439
"isExported": true
34403440
},
3441-
"originalName": "/Users/sth1pal/Documents/Development/JavaScript/nodejs/ts6/dev/hsLibs/standalone/hsDatab/src/overview.ts",
3441+
"originalName": "/Downloads/npm/hsDatab/src/overview.ts",
34423442
"comment": {
34433443
"shortText": "# hsDatab",
34443444
"text": "Helpful Scripts framework-independent data management functions.\n[`[Github page]`](https://github.com/HelpfulScripts/hsDatab)\n[`[Coverage Info]`](./data/src/hsDatab/coverage/)\n___\n\n**hsDatab** provides a JavaScript-based data management and query mechanism.\nData is managed in a simple in-memory database that holds data in rows of columns.\nIt autodetermines the types of data held in each column, along with the\ndomain range for each column of data.\nComplex filters can be applied by defining {@link DataFilters `Condition`}s using a simple query object structure.\n\n## Data Types\nsupported {@link Data.Data.type data types} include\n- **number**: numeric values\n- **name**: nominal values, represented by arbitrary words\n- **date**: date values\n- **currency**: Currently supported: '$dd[,ddd]'\n- **percent**: 'd%'\n\n## Data Class\nThe fundamental object in this library is {@link Data.Data `Data`},\na simple row-column based database object,\nfeaturing named columns, sorting, mapping and filtering functions.\n\n## Example\n<example height=500>\n<file name=\"script.js\">\nconst colNames = ['Name', 'Value', 'Start', 'End'];\nconst rows = [\n ['Harry', '100', '3/1/14', '11/20/14'],\n ['Mary', '1500', '7/1/14', '9/30/14'],\n ['Peter', '400', '5/20/14', '4/30/15'],\n ['Jane', '700', '11/13/14', '8/15/15']\n]\nconst data = new hsdatab.Data({colNames:colNames, rows:rows});\n\nquery = {Name:[\"Peter\", \"Jane\"]};\nconst result = data.filter(query);\n\nm.mount(root, {\n view:() => m('', [\n m('h3', 'Given the data set:'),\n m('pre',\n m('table#data', [\n m('tr', colNames.map(n => m('th', n))),\n ...rows.map(row => m('tr', [\n m('td', row[0]),\n m('td', row[1]),\n m('td', `${row[2].getMonth()+1}/${row[2].getDate()}/${row[2].getFullYear()}`),\n m('td', `${row[3].getMonth()+1}/${row[3].getDate()}/${row[3].getFullYear()}`)\n ]))\n ])),\n m('h3', 'The column types and domains are'),\n m('pre', m('table',\n m('tr', m('th', 'Column'), m('th', 'Type'), m('th', 'Domain')),\n m('tr', m('td', '\"Name\":'), m('td', data.colType(\"Name\")), m('td', data.findDomain(\"Name\").join(', '))),\n m('tr', m('td', '\"Value\":'), m('td', data.colType(\"Value\")), m('td', data.findDomain(\"Value\").join(' - '))),\n m('tr', m('td', '\"Start\":'), m('td', data.colType(\"Start\")), m('td', data.findDomain(\"Start\").map(d => d.toDateString()).join(' - '))),\n m('tr', m('td', '\"Stop\":'), m('td', data.colType(\"End\")), m('td', data.findDomain(\"End\").map(d => d.toDateString()).join(' - ')))\n )),\n m('h3', 'The query:'),\n m('code', '{Name:[\"Peter\", \"Jane\"]}'),\n m('h3', 'yields results with \"Name\"'),\n m('code', result.getColumn('Name').join(', '))\n ])\n});\n</file>\n<file name='style.css'>\n $exampleID { height: 600px; }\n #data th { width:15%; }\n #data { font-size: 11pt; }\n</file>\n</example>\n"

0 commit comments

Comments
 (0)