node-red-contrib-prib-functions 0.22.0 → 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 +142 -92
- 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/common.js +128 -0
- package/lib/objectExtensions.js +213 -80
- package/lib/timeDimension.js +36 -0
- package/lib/typedInput.js +77 -0
- package/matrix/matrixNode.html +2 -1
- package/package.json +15 -13
- package/test/00-objectExtensions.js +192 -1
- package/test/02-graphdb.js +46 -0
- package/test/data/.config.nodes.json +3 -3
- package/test/data/.config.nodes.json.backup +3 -3
- package/test/data/.config.users.json +3 -2
- package/test/data/.config.users.json.backup +3 -2
- package/test/data/.flow.json.backup +3875 -472
- package/test/data/flow.json +3874 -471
- 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 +63 -29
- package/transform/transform.html +185 -20
- package/transform/transform.js +272 -265
- package/transform/xlsx2.js +74 -0
- package/visual/shapes/base..js +1 -0
- package/visual/visual.js +0 -0
- package/visual/visualNode.js +45 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const assert=require('assert');
|
|
2
2
|
const should=require("should");
|
|
3
|
-
require("../lib/objectExtensions");
|
|
3
|
+
const {coalesce,nullif}=require("../lib/objectExtensions");
|
|
4
4
|
|
|
5
5
|
describe('/lib/objectExtensions array ', function() {
|
|
6
6
|
it("array find sorted empty set", function(done) {
|
|
@@ -92,3 +92,194 @@ describe('/lib/objectExtensions csvLine', function() {
|
|
|
92
92
|
done()
|
|
93
93
|
})
|
|
94
94
|
})
|
|
95
|
+
describe('/lib/objectExtensions number', function() {
|
|
96
|
+
it("isBetween", function(done) {
|
|
97
|
+
assert.deepStrictEqual(Number(1).isBetween(0,1),true)
|
|
98
|
+
assert.deepStrictEqual(Number(0).isBetween(0,1),true)
|
|
99
|
+
assert.deepStrictEqual(Number(-1).isBetween(0,1),false)
|
|
100
|
+
assert.deepStrictEqual(Number(2).isBetween(0,1),false)
|
|
101
|
+
done()
|
|
102
|
+
})
|
|
103
|
+
it("toSimpleArray", function(done) {
|
|
104
|
+
assert.deepStrictEqual({}.toSimpleArray(),[])
|
|
105
|
+
assert.deepStrictEqual({a:1,b:"2"}.toSimpleArray(),[["a",1,"number"],["b","2","string"]])
|
|
106
|
+
done()
|
|
107
|
+
})
|
|
108
|
+
it("toSimpleArrayIgnoreNulls", function(done) {
|
|
109
|
+
assert.deepStrictEqual({}.toSimpleArrayIgnoreNulls(),[])
|
|
110
|
+
assert.deepStrictEqual({a:1,b:"2"}.toSimpleArrayIgnoreNulls(),[["a",1,"number"],["b","2","string"]])
|
|
111
|
+
assert.deepStrictEqual({a:1,b:"2",c:null}.toSimpleArrayIgnoreNulls(),[["a",1,"number"],["b","2","string"]])
|
|
112
|
+
done()
|
|
113
|
+
})
|
|
114
|
+
it("in", function(done) {
|
|
115
|
+
assert.deepStrictEqual("abc".in(),false)
|
|
116
|
+
assert.deepStrictEqual("abc".in("abc"),true)
|
|
117
|
+
assert.deepStrictEqual("abc".in("abc","c"),true)
|
|
118
|
+
assert.deepStrictEqual("abc".in("a","abc","c"),true)
|
|
119
|
+
assert.deepStrictEqual("abc".in("a","no","c"),false)
|
|
120
|
+
done()
|
|
121
|
+
})
|
|
122
|
+
it("startsWithList", function(done) {
|
|
123
|
+
assert.deepStrictEqual("abc".startsWithList("a"),true)
|
|
124
|
+
assert.deepStrictEqual("Abc".startsWithList("a"),false)
|
|
125
|
+
assert.deepStrictEqual("abc".startsWithList("b","ab"),true)
|
|
126
|
+
assert.deepStrictEqual("abc".startsWithList("c"),false)
|
|
127
|
+
done()
|
|
128
|
+
})
|
|
129
|
+
it("startsWithListAnyCase", function(done) {
|
|
130
|
+
assert.deepStrictEqual("abc".startsWithListAnyCase("a"),true)
|
|
131
|
+
assert.deepStrictEqual("Abc".startsWithListAnyCase("a"),true)
|
|
132
|
+
assert.deepStrictEqual("aBc".startsWithListAnyCase("b","ab"),true)
|
|
133
|
+
assert.deepStrictEqual("abc".startsWithListAnyCase("c"),false)
|
|
134
|
+
done()
|
|
135
|
+
})
|
|
136
|
+
it("toAbbreviated", function(done) {
|
|
137
|
+
const test=(n,a)=>{
|
|
138
|
+
const t=n.toAbbreviated()
|
|
139
|
+
console.log(n+" => "+t+" s/be "+a)
|
|
140
|
+
assert.deepStrictEqual(t,a)
|
|
141
|
+
}
|
|
142
|
+
test(0,"0.00")
|
|
143
|
+
test(1,"1.00")
|
|
144
|
+
test(-1,"-1.00")
|
|
145
|
+
test(0.1,"0.10")
|
|
146
|
+
test(1.1234567,"1.12")
|
|
147
|
+
test(1001.0,"1.00K")
|
|
148
|
+
test(-1001.0,"-1.00K")
|
|
149
|
+
test(1011.0,"1.01K")
|
|
150
|
+
test(-1011.0,"-1.01K")
|
|
151
|
+
test(2011000.1,"2.01M")
|
|
152
|
+
test(2011002003,"2.01G")
|
|
153
|
+
test(2011002003004,"2.01T")
|
|
154
|
+
test(2011002003004005,"2.01P")
|
|
155
|
+
done()
|
|
156
|
+
})
|
|
157
|
+
it("xmlStringEncode", function(done) {
|
|
158
|
+
assert.deepStrictEqual("a&c".xmlStringEncode("a"),"a&c")
|
|
159
|
+
assert.deepStrictEqual("a\"c".xmlStringEncode("a"),"a"c")
|
|
160
|
+
assert.deepStrictEqual("a<>c".xmlStringEncode("a"),"a<>c")
|
|
161
|
+
done()
|
|
162
|
+
})
|
|
163
|
+
it("getWord", function(done) {
|
|
164
|
+
assert.deepStrictEqual("".getWord(1),"")
|
|
165
|
+
assert.deepStrictEqual("one two three".getWord(1),"one")
|
|
166
|
+
assert.deepStrictEqual("one two three".getWord(2),"two")
|
|
167
|
+
assert.deepStrictEqual("one two three".getWord(3),"three")
|
|
168
|
+
assert.deepStrictEqual("one two three".getWord(4),"")
|
|
169
|
+
done()
|
|
170
|
+
})
|
|
171
|
+
it("coalesce", function(done) {
|
|
172
|
+
const anull=null,notanull="notnull"
|
|
173
|
+
assert.deepStrictEqual(coalesce(anull,"test"),"test")
|
|
174
|
+
assert.deepStrictEqual(coalesce(notanull,"test"),"notnull")
|
|
175
|
+
done()
|
|
176
|
+
})
|
|
177
|
+
it("nullif", function(done) {
|
|
178
|
+
const anull="test",notanull="notnull"
|
|
179
|
+
assert.deepStrictEqual(nullif(anull,"test"),null)
|
|
180
|
+
assert.deepStrictEqual(nullif(notanull,"test"),"notnull")
|
|
181
|
+
done()
|
|
182
|
+
})
|
|
183
|
+
it("deepClone", function(done) {
|
|
184
|
+
const n=new Number(1)
|
|
185
|
+
const s=new String("astring")
|
|
186
|
+
const a=[s,n,[,s,n]]
|
|
187
|
+
assert.deepStrictEqual({}.deepClone(),{})
|
|
188
|
+
assert.deepStrictEqual([].deepClone(),[])
|
|
189
|
+
assert.deepStrictEqual(n.deepClone(),n)
|
|
190
|
+
assert.deepStrictEqual(s.deepClone(),s)
|
|
191
|
+
assert.deepStrictEqual(a.deepClone(),a)
|
|
192
|
+
done()
|
|
193
|
+
})
|
|
194
|
+
it("rangeLimit", function(done) {
|
|
195
|
+
const test=(type,min,max,value,result)=>{
|
|
196
|
+
const typedValue=new type(value)
|
|
197
|
+
assert.deepStrictEqual(typedValue.rangeLimit(new type(min),new type(max)),new type(result))
|
|
198
|
+
}
|
|
199
|
+
test(Number,2,4,1,2)
|
|
200
|
+
test(Number,2,4,2,2)
|
|
201
|
+
test(Number,2,4,3,3)
|
|
202
|
+
test(Number,2,4,4,4)
|
|
203
|
+
test(Number,2,4,5,4)
|
|
204
|
+
|
|
205
|
+
const test2=(type,min,max,value,result)=>{
|
|
206
|
+
const typedValue=type(value)
|
|
207
|
+
const typedResult=type(result)
|
|
208
|
+
const typedMin=type(min)
|
|
209
|
+
const typeMax=type(max)
|
|
210
|
+
assert.equal(typedValue.rangeLimit(typedMin,typeMax),typedResult)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
test2(BigInt,2,4,1,2)
|
|
214
|
+
test2(BigInt,2,4,2,2)
|
|
215
|
+
test2(BigInt,2,4,3,3)
|
|
216
|
+
test2(BigInt,2,4,4,4)
|
|
217
|
+
|
|
218
|
+
test2(Date,"2/2/2022","4/2/2022","1/2/2022","2/2/2022")
|
|
219
|
+
test2(Date,"2/2/2022","4/2/2022","2/2/2022","2/2/2022")
|
|
220
|
+
test2(Date,"2/2/2022","4/2/2022","3/2/2022","3/2/2022")
|
|
221
|
+
test2(Date,"2/2/2022","4/2/2022","4/2/2022","4/2/2022")
|
|
222
|
+
test2(Date,"2/2/2022","4/2/2022","5/2/2022","4/2/2022")
|
|
223
|
+
|
|
224
|
+
test2(String,"bb","bcd","aa","bb")
|
|
225
|
+
test2(String,"bb","bcd","bb","bb")
|
|
226
|
+
test2(String,"bb","bcd","bc","bc")
|
|
227
|
+
test2(String,"bb","bcd","bcd","bcd")
|
|
228
|
+
test2(String,"bb","bcd","bce","bcd")
|
|
229
|
+
done()
|
|
230
|
+
})
|
|
231
|
+
it("capitalize", function(done) {
|
|
232
|
+
assert.equal("".capitalize(),"")
|
|
233
|
+
assert.equal("abc".capitalize(),"Abc")
|
|
234
|
+
assert.equal("aBcd".capitalize(),"ABcd")
|
|
235
|
+
done()
|
|
236
|
+
})
|
|
237
|
+
it("toTitle", function(done) {
|
|
238
|
+
assert.equal("".toTitle(),"")
|
|
239
|
+
assert.equal("abc".toTitle(),"Abc")
|
|
240
|
+
assert.equal("aBcd".toTitle(),"ABcd")
|
|
241
|
+
assert.equal("aBcd def".toTitle(),"ABcd Def")
|
|
242
|
+
done()
|
|
243
|
+
})
|
|
244
|
+
it("toTitleGrammatical", function(done) {
|
|
245
|
+
assert.equal("to be or not to be".toTitleGrammatical(),"To Be or Not to Be")
|
|
246
|
+
assert.equal("a small dog".toTitleGrammatical(),"A Small Dog")
|
|
247
|
+
done()
|
|
248
|
+
})
|
|
249
|
+
it("deunderscore", function(done) {
|
|
250
|
+
assert.equal("abc_def_".deunderscore(),"abc def ")
|
|
251
|
+
done()
|
|
252
|
+
})
|
|
253
|
+
it("deunderscoreCapitilize", function(done) {
|
|
254
|
+
assert.equal(" abc_def_".deunderscoreCapitilize()," Abc Def ")
|
|
255
|
+
done()
|
|
256
|
+
})
|
|
257
|
+
it("dropSquareBracketPrefix", function(done) {
|
|
258
|
+
assert.equal("[abc] def".dropSquareBracketPrefix(),"def")
|
|
259
|
+
done()
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
describe('/lib/objectExtensions string', function() {
|
|
263
|
+
it("isBetween", function(done) {
|
|
264
|
+
assert.deepStrictEqual("a".isBetween("b","de"),false)
|
|
265
|
+
assert.deepStrictEqual("f".isBetween("b","de"),false)
|
|
266
|
+
assert.deepStrictEqual("b".isBetween("b","de"),true)
|
|
267
|
+
assert.deepStrictEqual("c".isBetween("b","de"),true)
|
|
268
|
+
assert.deepStrictEqual("d".isBetween("b","de"),true)
|
|
269
|
+
assert.deepStrictEqual("de".isBetween("b","de"),true)
|
|
270
|
+
assert.deepStrictEqual("df".isBetween("b","de"),false)
|
|
271
|
+
done()
|
|
272
|
+
})
|
|
273
|
+
})
|
|
274
|
+
describe('/lib/objectExtensions Date', function() {
|
|
275
|
+
it("isBetween", function(done) {
|
|
276
|
+
const aDate=new Date("2025/05/02")
|
|
277
|
+
assert.deepStrictEqual(aDate.isBetween("2025/05/01","2025/05/03"),true)
|
|
278
|
+
assert.deepStrictEqual(aDate.isBetween(new Date("2025/05/01"),new Date("2025/05/03")),true)
|
|
279
|
+
assert.deepStrictEqual(aDate.isBetween("2025/05/02","2025/05/03"),true)
|
|
280
|
+
assert.deepStrictEqual(aDate.isBetween("2025/05/01","2025/05/02"),true)
|
|
281
|
+
assert.deepStrictEqual(aDate.isBetween("2025/04/01","2025/05/01"),false)
|
|
282
|
+
assert.deepStrictEqual(aDate.isBetween("2025/05/03","2025/06/01"),false)
|
|
283
|
+
done()
|
|
284
|
+
})
|
|
285
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const assert=require('assert')
|
|
2
|
+
const should=require("should")
|
|
3
|
+
const GraphDB = require('../lib/GraphDB.js')
|
|
4
|
+
|
|
5
|
+
describe('GraphDB', function() {
|
|
6
|
+
it("define vertices", function(done) {
|
|
7
|
+
const graphDB=new GraphDB()
|
|
8
|
+
assert.equal(graphDB.getVerticesCount(),0)
|
|
9
|
+
assert.equal(graphDB.getEdgesCount(),0)
|
|
10
|
+
graphDB.addVertex({id:"a"})
|
|
11
|
+
assert.equal(graphDB.getVerticesCount(),1)
|
|
12
|
+
graphDB.addVertex({id:"b"})
|
|
13
|
+
assert.equal(graphDB.getVerticesCount(),2)
|
|
14
|
+
done()
|
|
15
|
+
});
|
|
16
|
+
const graphDB=new GraphDB()
|
|
17
|
+
const a=graphDB.addVertex({id:"a",name:"aname"})
|
|
18
|
+
const b=graphDB.addVertex({id:"b",name:"bname"})
|
|
19
|
+
const c=graphDB.addVertex({id:"c",name:"cname"})
|
|
20
|
+
it("find vertices", function(done) {
|
|
21
|
+
assert.deepEqual(graphDB.getVertices(v=>v.id=="d"),[])
|
|
22
|
+
assert.deepEqual(graphDB.getVertices(v=>v.id=="a"),[a])
|
|
23
|
+
assert.deepEqual(graphDB.getVertices(v=>v.id=="c"),[c])
|
|
24
|
+
assert.deepEqual(graphDB.getVertices(v=>v.id=="a"||v.id=="c"),[a,c])
|
|
25
|
+
done()
|
|
26
|
+
});
|
|
27
|
+
const ea=graphDB.addEdge(a,b,{id:"ea",name:"eaname"})
|
|
28
|
+
const eb=graphDB.addEdge(b,c,{id:"eb",name:"ebname"})
|
|
29
|
+
const ec=graphDB.addEdge(a,c,{id:"ec",name:"ecname"})
|
|
30
|
+
it("define edges", function(done) {
|
|
31
|
+
assert.throws(graphDB.addEdge({}),Error("from not type Vertex"))
|
|
32
|
+
assert.throws(graphDB.addEdge(a,{}),Error("to not type Vertex"))
|
|
33
|
+
assert.equal(graphDB.getEdgesCount(),0)
|
|
34
|
+
graphDB.addEdge(a,b)
|
|
35
|
+
assert.equal(graphDB.getEdgesCount(),1)
|
|
36
|
+
graphDB.addEdge(b,c,{cost:1})
|
|
37
|
+
assert.equal(graphDB.getEdgesCount(),2)
|
|
38
|
+
done()
|
|
39
|
+
});
|
|
40
|
+
it("find edges", function(done) {
|
|
41
|
+
assert.deepEqual(graphDB.getEdges(e=>e.id=="ed"),[])
|
|
42
|
+
assert.deepEqual(graphDB.getEdges(e=>e.id=="ea"),[a])
|
|
43
|
+
assert.deepEqual(graphDB.getEdges(e=>e.id=="ec"),[c])
|
|
44
|
+
assert.deepEqual(graphDB.getEdges(e=>e.id=="ea"||e.id=="ec"),[ea,ec])
|
|
45
|
+
});
|
|
46
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"node-red": {
|
|
3
3
|
"name": "node-red",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.9-git",
|
|
5
5
|
"local": false,
|
|
6
6
|
"user": false,
|
|
7
7
|
"nodes": {
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
},
|
|
430
430
|
"node-red-contrib-logger": {
|
|
431
431
|
"name": "node-red-contrib-logger",
|
|
432
|
-
"version": "0.1.
|
|
432
|
+
"version": "0.1.1",
|
|
433
433
|
"local": false,
|
|
434
434
|
"user": false,
|
|
435
435
|
"nodes": {
|
|
@@ -448,7 +448,7 @@
|
|
|
448
448
|
},
|
|
449
449
|
"node-red-contrib-prib-functions": {
|
|
450
450
|
"name": "node-red-contrib-prib-functions",
|
|
451
|
-
"version": "0.
|
|
451
|
+
"version": "0.23.3",
|
|
452
452
|
"local": true,
|
|
453
453
|
"user": true,
|
|
454
454
|
"nodes": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"node-red": {
|
|
3
3
|
"name": "node-red",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.9-git",
|
|
5
5
|
"local": false,
|
|
6
6
|
"user": false,
|
|
7
7
|
"nodes": {
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
},
|
|
430
430
|
"node-red-contrib-logger": {
|
|
431
431
|
"name": "node-red-contrib-logger",
|
|
432
|
-
"version": "0.1.
|
|
432
|
+
"version": "0.1.1",
|
|
433
433
|
"local": false,
|
|
434
434
|
"user": false,
|
|
435
435
|
"nodes": {
|
|
@@ -448,7 +448,7 @@
|
|
|
448
448
|
},
|
|
449
449
|
"node-red-contrib-prib-functions": {
|
|
450
450
|
"name": "node-red-contrib-prib-functions",
|
|
451
|
-
"version": "0.
|
|
451
|
+
"version": "0.23.2",
|
|
452
452
|
"local": true,
|
|
453
453
|
"user": true,
|
|
454
454
|
"nodes": {
|