file-obj-queue 1.0.22 → 1.0.24
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/app.js +3 -2
- package/local_queuejson/app.js +236 -0
- package/local_queuejson/lib/appenders/all.js +22 -0
- package/local_queuejson/lib/appenders/base.js +80 -0
- package/package.json +2 -2
- package/test/package.js +2 -2
package/app.js
CHANGED
|
@@ -76,7 +76,7 @@ exports = module.exports = class FilesQueue {
|
|
|
76
76
|
t.logMsg = t.logMsg.bind(t)
|
|
77
77
|
t.init = t.init.bind(t)
|
|
78
78
|
t.getFileObject = t.getFileObject.bind(t)
|
|
79
|
-
t.json_queue = require("
|
|
79
|
+
t.json_queue = require("./local_queuejson/app")
|
|
80
80
|
t.qJson = null
|
|
81
81
|
|
|
82
82
|
t.logMsg(`FilesQueue.constructor`)
|
|
@@ -100,7 +100,8 @@ exports = module.exports = class FilesQueue {
|
|
|
100
100
|
class_obj: file_obj,
|
|
101
101
|
appender: 'all',
|
|
102
102
|
stats: true,
|
|
103
|
-
debug: true
|
|
103
|
+
debug: true,
|
|
104
|
+
parent: t
|
|
104
105
|
})
|
|
105
106
|
t.logMsg(`jrm debug 1/29 8801`)
|
|
106
107
|
} catch (e) {
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
4
|
+
* @since 2022-12-11
|
|
5
|
+
* apps.js
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
let cc = require("node-console-colors"),
|
|
9
|
+
all = require("./lib/appenders/all"),
|
|
10
|
+
file_requre_data = [
|
|
11
|
+
{ props: { id: 100, name: "all", path: "./lib/appenders/all.js", absolute_path: __filename, check: true } }
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
exports = module.exports = class QueueJson {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
let t = this, fname = `app constructor`
|
|
17
|
+
try {
|
|
18
|
+
console.log(`${fname} 4000`, { "type": "debug" });
|
|
19
|
+
t.class_obj_array = [];
|
|
20
|
+
t.appenders = [{ name: 'all', obj: null }]
|
|
21
|
+
|
|
22
|
+
t.props = props
|
|
23
|
+
t.props.getParent = t.getParent
|
|
24
|
+
|
|
25
|
+
if (typeof t.props != 'undefined' && typeof t.props.debug != 'undefined') {
|
|
26
|
+
t.debug = t.props.debug
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error(`props is not defined`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
t.file_obj_queue = t.props.parent //jrm debug 1/30
|
|
32
|
+
// t.file_obj_queue = new file_queue().init({ input_data: file_requre_data }) //jrm debug 1/29
|
|
33
|
+
console.log(`jrm debug 1/31 getFileObj 1202 (${typeof t.file_obj_queue})`)
|
|
34
|
+
|
|
35
|
+
t.init = t.init.bind(t)
|
|
36
|
+
t.process = t.process.bind(t)
|
|
37
|
+
t.getParent = t.getParent.bind(t)
|
|
38
|
+
t.logMsg = t.logMsg.bind(t)
|
|
39
|
+
|
|
40
|
+
t.logMsg(`${fname} 4001`, { "type": "debug" });
|
|
41
|
+
|
|
42
|
+
return t
|
|
43
|
+
} catch (e) {
|
|
44
|
+
t.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getParent = () => {
|
|
49
|
+
return this
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get_class_obj_array = () => {
|
|
53
|
+
return this.class_obj_array
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
init = (props) => {
|
|
57
|
+
let t = this, fname = `app init`, add = false, co, file_obj, obj
|
|
58
|
+
try {
|
|
59
|
+
t.logMsg(`${fname} appender(${t.props.appender})`, { "type": "debug" })
|
|
60
|
+
// t.file_obj_queue = new file_queue().init({ input_data: file_requre_data }) //jrm debug 1/31
|
|
61
|
+
t.logMsg(`${fname} jrm debug 1/31 SHOULD BE HERE`, { "type": "debug" })
|
|
62
|
+
t.all = new all(t.props)
|
|
63
|
+
return t
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// add = true
|
|
67
|
+
|
|
68
|
+
// file_obj = t.file_obj_queue.getFileObject()
|
|
69
|
+
// if (typeof t.props != `undefined`) {
|
|
70
|
+
// if (typeof t.props.appender != `undefined` &&
|
|
71
|
+
// typeof t.props.appender == 'string') {
|
|
72
|
+
// t.props.getParent = t.getParent
|
|
73
|
+
// file_obj.map((jsObj, i) => {
|
|
74
|
+
// if (jsObj.name == t.props.appender) {
|
|
75
|
+
// obj = require(jsObj.path)
|
|
76
|
+
// eval(`t.${jsObj.name} = new obj(t.props)`)
|
|
77
|
+
// }
|
|
78
|
+
// })
|
|
79
|
+
// }
|
|
80
|
+
// return t
|
|
81
|
+
// }
|
|
82
|
+
// return t
|
|
83
|
+
|
|
84
|
+
// process.exit(22);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
try {
|
|
88
|
+
if (typeof props.input_data != 'undefined') {
|
|
89
|
+
props.input_data.map((dat, i) => {
|
|
90
|
+
add = false
|
|
91
|
+
switch (t.props.appender) {
|
|
92
|
+
case 'top_one':
|
|
93
|
+
if (i == 0)
|
|
94
|
+
add = true
|
|
95
|
+
break
|
|
96
|
+
case 'bottom_one':
|
|
97
|
+
if (i == (props.input_data.length - 1))
|
|
98
|
+
add = true
|
|
99
|
+
break
|
|
100
|
+
case 'status':
|
|
101
|
+
case 'by_status':
|
|
102
|
+
try {
|
|
103
|
+
if (props.matching.indexOf(dat.props.status) > -1)
|
|
104
|
+
add = true
|
|
105
|
+
} catch { }
|
|
106
|
+
try {
|
|
107
|
+
if (props.non_matching.indexOf(dat.props.status) == -1)
|
|
108
|
+
add = true
|
|
109
|
+
} catch { }
|
|
110
|
+
break
|
|
111
|
+
case 'name':
|
|
112
|
+
case 'by_name':
|
|
113
|
+
try {
|
|
114
|
+
if (props.matching.indexOf(dat.props.name) > -1)
|
|
115
|
+
add = true
|
|
116
|
+
} catch { }
|
|
117
|
+
try {
|
|
118
|
+
if (props.non_matching.indexOf(dat.props.name) == -1)
|
|
119
|
+
add = true
|
|
120
|
+
} catch { }
|
|
121
|
+
break
|
|
122
|
+
case 'version':
|
|
123
|
+
try {
|
|
124
|
+
if (props.matching.indexOf(dat.props.version) > -1)
|
|
125
|
+
add = true
|
|
126
|
+
} catch { }
|
|
127
|
+
try {
|
|
128
|
+
if (props.non_matching.indexOf(dat.props.version) == -1)
|
|
129
|
+
add = true
|
|
130
|
+
} catch { }
|
|
131
|
+
break
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
add = true
|
|
135
|
+
}
|
|
136
|
+
if (add) {
|
|
137
|
+
co = new t.props.class_obj(dat.props)
|
|
138
|
+
if (typeof dat.props.function_name == 'string') {
|
|
139
|
+
co._getFuncName = () => {
|
|
140
|
+
return dat.props.function_name
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
t.class_obj_array.push(co)
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
} else
|
|
147
|
+
throw new Error('no input data array defined.')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
throw e
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
} catch (e) {
|
|
153
|
+
throw `new class_obj: ${e}`
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
file_obj = t.file_obj_queue.getFileObject()
|
|
157
|
+
if (typeof t.props != `undefined`) {
|
|
158
|
+
if (typeof t.props.appender != `undefined` &&
|
|
159
|
+
typeof t.props.appender == 'string') {
|
|
160
|
+
t.props.getParent = t.getParent
|
|
161
|
+
file_obj.map((jsObj, i) => {
|
|
162
|
+
if (jsObj.name == t.props.appender) {
|
|
163
|
+
obj = require(jsObj.path)
|
|
164
|
+
eval(`t.${jsObj.name} = new obj(t.props)`)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
return t
|
|
169
|
+
}
|
|
170
|
+
return t
|
|
171
|
+
} catch (e) {
|
|
172
|
+
t.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
logMsg = (msg, props = {}) => {
|
|
177
|
+
let t = this
|
|
178
|
+
try {
|
|
179
|
+
let t = this, tp
|
|
180
|
+
if (typeof props != 'undefined' && typeof props.type != 'undefined') {
|
|
181
|
+
switch (props.type) {
|
|
182
|
+
case 'debug':
|
|
183
|
+
if (!t.debug)
|
|
184
|
+
return
|
|
185
|
+
tp = "bg_dark_gray"
|
|
186
|
+
break
|
|
187
|
+
case 'error':
|
|
188
|
+
tp = "fg_red"
|
|
189
|
+
break
|
|
190
|
+
case 'purple':
|
|
191
|
+
tp = "bg_purple"
|
|
192
|
+
break
|
|
193
|
+
case 'success':
|
|
194
|
+
tp = "fg_green"
|
|
195
|
+
break
|
|
196
|
+
case 'white':
|
|
197
|
+
tp = "bg_white"
|
|
198
|
+
break
|
|
199
|
+
default:
|
|
200
|
+
tp = 'bg_dark_gray'
|
|
201
|
+
}
|
|
202
|
+
console.log(cc.set(tp, msg))
|
|
203
|
+
return t
|
|
204
|
+
}
|
|
205
|
+
throw new Error('No props.type included')
|
|
206
|
+
} catch (e) {
|
|
207
|
+
console.log(`app log: ${e.message} for message (${msg})`)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
process = () => {
|
|
212
|
+
let t = this, fname = `local_queuejson app process`
|
|
213
|
+
try {
|
|
214
|
+
return t.all.process()
|
|
215
|
+
} catch (e) {
|
|
216
|
+
t.logMsg(`${fname}: ${e.message}.`, { "type": "error" })
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
// let t = this, fname = `app process`, file_obj, jsObj, i
|
|
221
|
+
// let pro = { 'dat_array': [''] }
|
|
222
|
+
// try {
|
|
223
|
+
// file_obj = t.file_obj_queue.getFileObject()
|
|
224
|
+
// for (i = 0; i < file_obj.length; i++) {
|
|
225
|
+
// jsObj = file_obj[i]
|
|
226
|
+
// if (jsObj.name == t.props.appender) {
|
|
227
|
+
// pro.dat_array.push(`${jsObj.name}`)
|
|
228
|
+
// return eval(`t.${jsObj.name}.process()`)
|
|
229
|
+
// }
|
|
230
|
+
// }
|
|
231
|
+
// throw new Error('no appender found to process')
|
|
232
|
+
// } catch (e) {
|
|
233
|
+
// t.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
234
|
+
// }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2022-12-11
|
|
4
|
+
* all.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var base = require('./base.js')
|
|
8
|
+
|
|
9
|
+
exports = module.exports = class all extends base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props)
|
|
12
|
+
var t = this
|
|
13
|
+
try {
|
|
14
|
+
t.aname = 'all'
|
|
15
|
+
t.parent.logMsg(`all constructor`, {"type": "debug"})
|
|
16
|
+
return t
|
|
17
|
+
} catch (e) {
|
|
18
|
+
t.parent.logMsg(e, {"type": "error"})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2022-12-11
|
|
4
|
+
* base.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var qObj = require("queueobj");
|
|
8
|
+
|
|
9
|
+
exports = module.exports = class base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
let t = this, fname = `base constructor`
|
|
12
|
+
try {
|
|
13
|
+
t.parent = props.getParent()
|
|
14
|
+
t.resolve_array = []
|
|
15
|
+
t.reject_array = []
|
|
16
|
+
|
|
17
|
+
t.qObj = new qObj()
|
|
18
|
+
t.qObj.load({ appender: props.appender, stats: props.stats, log: t.parent.logMsg })
|
|
19
|
+
|
|
20
|
+
t.process = t.process.bind(t)
|
|
21
|
+
t.process_all = t.process_all.bind(t)
|
|
22
|
+
return t
|
|
23
|
+
} catch (e) {
|
|
24
|
+
t.parent.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
25
|
+
throw e
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
process = (props) => {
|
|
30
|
+
let t = this, fname = `base process`
|
|
31
|
+
try {
|
|
32
|
+
t.dt_start = new Date(); // start measuring time
|
|
33
|
+
|
|
34
|
+
t.parent.logMsg(fname, { "type": "debug" })
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
t.resolve_array.push(resolve)
|
|
37
|
+
t.reject_array.push(reject)
|
|
38
|
+
t.process_all()
|
|
39
|
+
});
|
|
40
|
+
} catch (e) {
|
|
41
|
+
t.parent.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
process_all = () => {
|
|
46
|
+
let t = this, fname = `base process_all`, coa
|
|
47
|
+
try {
|
|
48
|
+
t.parent.logMsg(fname, { "type": "debug" })
|
|
49
|
+
|
|
50
|
+
coa = t.parent.get_class_obj_array()
|
|
51
|
+
|
|
52
|
+
if (coa.length == 0) {
|
|
53
|
+
t.reject_array[0]({ error: 'no matching data to process' })
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
coa.map((dat, i) => {
|
|
57
|
+
dat.log = t.log
|
|
58
|
+
if (typeof t.qObj == 'undefined')
|
|
59
|
+
throw new Error(`qObj does not exist`)
|
|
60
|
+
|
|
61
|
+
if (typeof dat._getFuncName == 'function') {
|
|
62
|
+
t.parent.logMsg(`${fname}: function name(${dat._getFuncName()})`, { "type": "debug" })
|
|
63
|
+
|
|
64
|
+
t.qObj.add(eval(`dat.${dat._getFuncName()}`))
|
|
65
|
+
} else {
|
|
66
|
+
t.qObj.add(dat)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
t.qObj.process({}).then((res) => {
|
|
71
|
+
t.resolve_array[0]({ res })
|
|
72
|
+
}, (err) => {
|
|
73
|
+
t.reject_array[0]({ err })
|
|
74
|
+
})
|
|
75
|
+
} catch (e) {
|
|
76
|
+
t.parent.logMsg(`${fname}: ${e}`, { "type": "error" })
|
|
77
|
+
throw e
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": {
|
|
3
3
|
"name": "Jim Manton"
|
|
4
4
|
},
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.24",
|
|
6
6
|
"bundleDependencies": [],
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"chai": "^4.3.7",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"fs": "^0.0.1-security",
|
|
11
11
|
"mocha": "^10.2.0",
|
|
12
12
|
"node-console-colors": "^1.1.4",
|
|
13
|
-
"queuejson": "^9.0.
|
|
13
|
+
"queuejson": "^9.0.11",
|
|
14
14
|
"valid-path": "^2.1.0"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
package/test/package.js
CHANGED
|
@@ -6,7 +6,7 @@ const packageMock = {
|
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jim Manton"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.24",
|
|
10
10
|
"bundleDependencies": [],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chai": "^4.3.7",
|
|
@@ -14,7 +14,7 @@ const packageMock = {
|
|
|
14
14
|
"fs": "^0.0.1-security",
|
|
15
15
|
"mocha": "^10.2.0",
|
|
16
16
|
"node-console-colors": "^1.1.4",
|
|
17
|
-
"queuejson": "^9.0.
|
|
17
|
+
"queuejson": "^9.0.11",
|
|
18
18
|
"valid-path": "^2.1.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|