node-red-contrib-prib-functions 0.23.2 → 0.23.3
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/README.md +139 -141
- package/lib/AlphaBeta.js +32 -0
- package/lib/GraphDB.js +40 -9
- package/lib/MinMax.js +17 -0
- package/lib/Tree.js +64 -0
- package/lib/objectExtensions.js +28 -5
- package/lib/timeDimension.js +36 -0
- package/package.json +4 -3
- package/test/02-graphdb.js +46 -0
- package/test/data/.config.nodes.json +1 -1
- package/test/data/.config.nodes.json.backup +2 -2
- package/test/data/.flow.json.backup +813 -193
- package/test/data/flow.json +809 -191
- package/test/data/package-lock.json +11 -11
- package/test/data/shares/.config.nodes.json +589 -0
- package/test/data/shares/.config.runtime.json +4 -0
- package/test/data/shares/.config.runtime.json.backup +3 -0
- package/test/data/shares/.config.users.json +32 -0
- package/test/data/shares/.config.users.json.backup +29 -0
- package/test/data/shares/.flow.json.backup +230 -0
- package/test/data/shares/.flow_cred.json.backup +3 -0
- package/test/data/shares/flow.json +267 -0
- package/test/data/shares/flow_cred.json +3 -0
- package/test/data/shares/package.json +6 -0
- package/test/data/shares/settings.js +544 -0
- package/testing/test.js +8 -7
- package/transform/transform.html +23 -2
- package/transform/transform.js +239 -283
- package/transform/xlsx2.js +74 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//see https://docs.sheetjs.com/docs/api/utilities/array
|
|
2
|
+
|
|
3
|
+
let XLSX=()=>{
|
|
4
|
+
const requireXLSX=require('xlsx')
|
|
5
|
+
XLSX=()=>requireXLSX
|
|
6
|
+
return requireXLSX
|
|
7
|
+
}
|
|
8
|
+
const XMLoptions = {
|
|
9
|
+
// attributeNamePrefix : "@_",
|
|
10
|
+
// attrNodeName: "attr", //default is 'false'
|
|
11
|
+
// textNodeName : "#text",
|
|
12
|
+
ignoreAttributes : false,
|
|
13
|
+
ignoreNameSpace : false,
|
|
14
|
+
allowBooleanAttributes : true,
|
|
15
|
+
parseNodeValue : true,
|
|
16
|
+
parseAttributeValue : false,
|
|
17
|
+
// cdataTagName: "__cdata", //default is 'false'
|
|
18
|
+
// cdataPositionChar: "\\c",
|
|
19
|
+
// parseTrueNumberOnly: false,
|
|
20
|
+
// arrayMode: false, //"strict"
|
|
21
|
+
// attrValueProcessor: (val, attrName) => he.decode(val, {isAttributeValue: true}),//default is a=>a
|
|
22
|
+
// tagValueProcessor : (val, tagName) => he.decode(val), //default is a=>a
|
|
23
|
+
// stopNodes: ["parse-me-as-string"]
|
|
24
|
+
trimValues: false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const addWorksheet2JSON=(object,worksheet,workbook,options={header:1,raw:true})=>{
|
|
28
|
+
object[worksheet]=XLSX().utils.sheet_to_json(workbook.Sheets[worksheet],options)
|
|
29
|
+
return object
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const XLSXObject2JSON=(workbook,options)=>workbook.SheetNames.reduce((a,worksheet)=>addWorksheet2JSON(a,worksheet,workbook,options),{})
|
|
33
|
+
const XLSX2Array=data=>XLSXObject2Array(XLSX2XLSXObject(data))
|
|
34
|
+
const XLSX2JSON=data=>XLSX2XLSXObject(XLSXObject2JSON(data))
|
|
35
|
+
const XLSX2XLSXObject=data=>XLSX().read(data, {raw:true,type: 'buffer' })
|
|
36
|
+
const XLSXObject2Array=(workbookoptions={header:1,raw:true})=>workbook.SheetNames.reduce((a,worksheet)=>{
|
|
37
|
+
a.push(XLSX().utils.sheet_to_json(workbook.Sheets[worksheet],options))
|
|
38
|
+
return a
|
|
39
|
+
},[])
|
|
40
|
+
const JSON2XLSX=data=>XLSX().write(JSON2XLSXObject(data), {bookType:"xlsx", type:'buffer'})
|
|
41
|
+
const JSON2XLSXObject=data=>{
|
|
42
|
+
const workbook = XLSX().utils.book_new();
|
|
43
|
+
for(const worksheet in data) {
|
|
44
|
+
const ws=XLSX().utils.json_to_sheet(data[worksheet]);
|
|
45
|
+
XLSX().utils.book_append_sheet(workbook, ws, worksheet);
|
|
46
|
+
}
|
|
47
|
+
return workbook
|
|
48
|
+
}
|
|
49
|
+
const Array2XLSX=data=>XLSX().write(Array2XLSXObject(data), {bookType:"xlsx", type:'buffer'})
|
|
50
|
+
const Array2XLSXObject=data=>{
|
|
51
|
+
const workbook = XLSX().utils.book_new();
|
|
52
|
+
if(Array.isArray(data)) {
|
|
53
|
+
const ws=XLSX().utils.aoa_to_sheet(data);
|
|
54
|
+
XLSX().utils.book_append_sheet(workbook, ws,"worksheet 1");
|
|
55
|
+
return workbook
|
|
56
|
+
}
|
|
57
|
+
for(const worksheet in data) {
|
|
58
|
+
const ws=XLSX().utils.aoa_to_sheet(data[worksheet]);
|
|
59
|
+
XLSX().utils.book_append_sheet(workbook, ws, worksheet);
|
|
60
|
+
}
|
|
61
|
+
return workbook
|
|
62
|
+
}
|
|
63
|
+
module.exports={
|
|
64
|
+
addWorksheet2JSON:addWorksheet2JSON,
|
|
65
|
+
XLSXObject2JSON:XLSXObject2JSON,
|
|
66
|
+
XLSX2Array:XLSX2Array,
|
|
67
|
+
XLSX2JSON:XLSX2JSON,
|
|
68
|
+
XLSX2XLSXObject:XLSX2XLSXObject,
|
|
69
|
+
XLSXObject2Array:XLSXObject2Array,
|
|
70
|
+
JSON2XLSX:JSON2XLSX,
|
|
71
|
+
JSON2XLSXObject:JSON2XLSXObject,
|
|
72
|
+
Array2XLSX:Array2XLSX,
|
|
73
|
+
Array2XLSXObject:Array2XLSXObject
|
|
74
|
+
}
|