node-red-contrib-prib-functions 0.22.0 → 0.23.2

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.
@@ -146,7 +146,8 @@
146
146
 
147
147
  defineProperty({name:"dataType",label:"number Type" ,icon:"tag"},[
148
148
  { value: "Float32Array", label: "float32 -3.4e38 to 3.4e38" },
149
- { value: "Float64Array", label: "double/float64 -1.8e308 to 1.8e308" }, { value: "Int8Array", label: "byte -128 to 122" },
149
+ { value: "Float64Array", label: "double/float64 -1.8e308 to 1.8e308" },
150
+ { value: "Int8Array", label: "byte -128 to 122" },
150
151
  { value: "Uint8Array", label: "octet 0 to 255" },
151
152
  { value: "Uint8ClampedArray", label: "octet clamped 0 to 255" },
152
153
  { value: "Int16Array", label: "short -32768 to 32767" },
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "node-red-contrib-prib-functions",
3
- "version": "0.22.0",
3
+ "version": "0.23.2",
4
4
  "description": "Node-RED added node functions.",
5
5
  "dependencies": {
6
6
  "avsc": ">=5.7.7",
7
7
  "compressiontool": "*",
8
- "fast-xml-parser": "^4.2.5",
9
- "node": ">=0.6.13",
8
+ "fast-xml-parser": "^5.2.1",
9
+ "node": ">=22.15.0",
10
10
  "node-red-contrib-logger": "latest",
11
11
  "node-red-contrib-noderedbase": ">=0.0.16",
12
12
  "node-red-contrib-prib-functions": "file:",
13
- "npm": "^10.9.0",
13
+ "npm": "^11.3.0",
14
14
  "xlsx": "*"
15
15
  },
16
16
  "devDependencies": {
17
- "@node-red/runtime": ">=1.2.8",
18
- "axios": ">=0.21.1",
19
- "bcrypt": "^5.0.1",
20
- "bl": "^5.0.0",
21
- "mocha": "^9.2.2",
22
- "node-red": "^3.0.2",
23
- "node-red-node-test-helper": "^0.3.0"
17
+ "@node-red/runtime": ">=4.0.9",
18
+ "axios": ">=1.9.0",
19
+ "bcrypt": "^5.1.1",
20
+ "bl": "^6.1.0",
21
+ "mocha": "^11.2.2",
22
+ "node-red": ">=4.0.9",
23
+ "node-red-node-test-helper": ">=0.3.4"
24
24
  },
25
25
  "scripts": {
26
26
  "test": "mocha \"test/dataAnalysisE*.js\"",
@@ -117,6 +117,7 @@
117
117
  "system",
118
118
  "testing",
119
119
  "test",
120
+ "tensor",
120
121
  "translate",
121
122
  "transform",
122
123
  "transpose",
@@ -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&lt;&gt;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
+ })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "node-red": {
3
3
  "name": "node-red",
4
- "version": "3.1.14",
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.0",
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.22.0",
451
+ "version": "0.23.0",
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": "3.1.14",
4
+ "version": "4.0.5-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.0",
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.21.0",
451
+ "version": "0.23.0",
452
452
  "local": true,
453
453
  "user": true,
454
454
  "nodes": {
@@ -13,9 +13,10 @@
13
13
  "view-show-welcome-tours": true
14
14
  },
15
15
  "tours": {
16
- "welcome": "3.1.5-git"
16
+ "welcome": "4.0.5-git"
17
17
  }
18
18
  },
19
- "menu-menu-item-sidebar": true
19
+ "menu-menu-item-sidebar": true,
20
+ "menu-menu-item-palette": true
20
21
  }
21
22
  }
@@ -13,9 +13,10 @@
13
13
  "view-show-welcome-tours": true
14
14
  },
15
15
  "tours": {
16
- "welcome": "3.1.5-git"
16
+ "welcome": "4.0.5-git"
17
17
  }
18
18
  },
19
- "menu-menu-item-sidebar": false
19
+ "menu-menu-item-sidebar": true,
20
+ "menu-menu-item-palette": false
20
21
  }
21
22
  }