queueobj 10.0.0 → 10.1.0
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 +8 -6
- package/lib/appenders/base.js +5 -5
- package/package.json +1 -1
- package/test/package.js +1 -1
- package/test_all.js +4 -4
- package/test_bottom_one.js +2 -2
- package/test_func_all.js +2 -2
- package/test_status.js +5 -5
- package/test_sync_all.js +5 -5
- package/test_top_one.js +2 -2
- package/test_version.js +5 -5
package/app.js
CHANGED
|
@@ -39,6 +39,7 @@ class QueueObj {
|
|
|
39
39
|
t.getObjectToProcess = t.getObjectToProcess.bind(this)
|
|
40
40
|
t.getObjectById = t.getObjectById.bind(this)
|
|
41
41
|
t.getObjs = t.getObjs.bind(this)
|
|
42
|
+
t.logMsg = t.logMsg.bind(this)
|
|
42
43
|
return t
|
|
43
44
|
} catch (e) {
|
|
44
45
|
e.message = "queueObj app.js init error: " + e.message
|
|
@@ -108,15 +109,16 @@ class QueueObj {
|
|
|
108
109
|
return this.objs[itm]
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
logMsg(msg, props = {}) {
|
|
113
|
+
console.log(msg)
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
load(props) {
|
|
112
117
|
try {
|
|
113
118
|
var t = this
|
|
114
119
|
t.props = props
|
|
115
120
|
t.stats = (typeof props.stats != 'undefined') ? props.stats : false;
|
|
116
121
|
if (typeof props != `undefined`) {
|
|
117
|
-
if (typeof props.log != `undefined`) {
|
|
118
|
-
console.log = props.log
|
|
119
|
-
}
|
|
120
122
|
if (typeof props.appender != `undefined` &&
|
|
121
123
|
typeof props.appender == 'string') {
|
|
122
124
|
props.getParent = t.getParent
|
|
@@ -153,7 +155,7 @@ class QueueObj {
|
|
|
153
155
|
}
|
|
154
156
|
} catch (e) {
|
|
155
157
|
e.message = "queueObj app.js load error: " + e.message
|
|
156
|
-
|
|
158
|
+
t.logMsg(e.message)
|
|
157
159
|
throw (e)
|
|
158
160
|
}
|
|
159
161
|
}
|
|
@@ -208,7 +210,7 @@ class QueueObj {
|
|
|
208
210
|
return t
|
|
209
211
|
} catch (e) {
|
|
210
212
|
e.message = "queueObj app.js add error: " + e.message
|
|
211
|
-
|
|
213
|
+
t.logMsg(e.message.red)
|
|
212
214
|
throw (e)
|
|
213
215
|
}
|
|
214
216
|
}
|
|
@@ -245,7 +247,7 @@ class QueueObj {
|
|
|
245
247
|
}
|
|
246
248
|
} catch (e) {
|
|
247
249
|
e.message = "queueObj app.js load error: " + e.message
|
|
248
|
-
|
|
250
|
+
t.logMsg(e.message.red)
|
|
249
251
|
throw (e)
|
|
250
252
|
}
|
|
251
253
|
}
|
package/lib/appenders/base.js
CHANGED
|
@@ -43,7 +43,7 @@ class process_all_obj {
|
|
|
43
43
|
try {
|
|
44
44
|
pro = (typeof obj == 'function') ? obj : obj.process;
|
|
45
45
|
} catch (e) {
|
|
46
|
-
|
|
46
|
+
t.parent.getParent()(`pro error: (${e.message})`.red)
|
|
47
47
|
throw e
|
|
48
48
|
}
|
|
49
49
|
if (typeof t.parent.pro_props != 'undefined' &&
|
|
@@ -68,19 +68,19 @@ class process_all_obj {
|
|
|
68
68
|
try {
|
|
69
69
|
if (typeof obj_props != 'undefined' && typeof obj_props.error != 'undefined') {
|
|
70
70
|
t.any_errors = true
|
|
71
|
-
|
|
71
|
+
t.parent.getParent().logMsg(`${JSON.stringify(obj_props)}`.red)
|
|
72
72
|
} else {
|
|
73
|
-
|
|
73
|
+
t.parent.getParent().logMsg(`${JSON.stringify(obj_props)}`.green)
|
|
74
74
|
}
|
|
75
75
|
t.parent.results_array.push(obj_props)
|
|
76
76
|
t.continueProcessing()
|
|
77
77
|
} catch (e) {
|
|
78
|
-
|
|
78
|
+
t.parent.getParent().logMsg(`pro obj error: (${e.message})`.red)
|
|
79
79
|
throw e
|
|
80
80
|
}
|
|
81
81
|
})
|
|
82
82
|
} catch (e) {
|
|
83
|
-
e.message = `
|
|
83
|
+
e.message = `error: ${e.message} `
|
|
84
84
|
throw e
|
|
85
85
|
}
|
|
86
86
|
} catch (e) {
|
package/package.json
CHANGED
package/test/package.js
CHANGED
package/test_all.js
CHANGED
|
@@ -31,13 +31,13 @@ class test4 {
|
|
|
31
31
|
let qObj = new queue(), props = { appender: 'all', stats: true }
|
|
32
32
|
|
|
33
33
|
qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4()).process({}).then(res => {
|
|
34
|
-
|
|
34
|
+
qObj.logMsg(`success with all processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
35
35
|
}, err => {
|
|
36
|
-
//
|
|
37
|
-
|
|
36
|
+
// qObj.logMsg(`error with all processing: (${JSON.stringify(err)})`.red) //show all results
|
|
37
|
+
qObj.logMsg(`error with all processing: (${err})`.red) //show the execution time
|
|
38
38
|
err.responses.map((jItem, i) => {
|
|
39
39
|
if (typeof jItem.error != 'undefined' && typeof jItem.error.msg != 'undefined') {
|
|
40
|
-
|
|
40
|
+
qObj.logMsg(`error: ${jItem.error.msg}`.red) //show the error
|
|
41
41
|
}
|
|
42
42
|
})
|
|
43
43
|
})
|
package/test_bottom_one.js
CHANGED
|
@@ -23,7 +23,7 @@ class test3 {
|
|
|
23
23
|
let qObj = new queue(), props = { appender: 'bottom_one', stats: false}
|
|
24
24
|
|
|
25
25
|
qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
|
|
26
|
-
|
|
26
|
+
qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
27
27
|
}, err => {
|
|
28
|
-
|
|
28
|
+
qObj.logMsg(`errors with all sync processing: (${JSON.stringify(err)})`.red)
|
|
29
29
|
})
|
package/test_func_all.js
CHANGED
|
@@ -37,8 +37,8 @@ let tst1 = new test1(),
|
|
|
37
37
|
tst3 = new test3(qObj, tst4)
|
|
38
38
|
|
|
39
39
|
qObj.load(props).add(tst1.some_function).add(tst2.a_func).add(tst3.cool).process().then(res => {
|
|
40
|
-
|
|
40
|
+
qObj.logMsg(`success with func_all processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
41
41
|
}, err => {
|
|
42
|
-
|
|
42
|
+
qObj.logMsg(`errors with func_all processing: (${JSON.stringify(err)})`.red)
|
|
43
43
|
})
|
|
44
44
|
|
package/test_status.js
CHANGED
|
@@ -37,7 +37,7 @@ class test2 {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
ping() {
|
|
40
|
-
|
|
40
|
+
qObj.logMsg('hello from test2'.rainbow)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -74,13 +74,13 @@ let qObj = new queue(), props = { appender: 'status', stats: true }
|
|
|
74
74
|
qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4())
|
|
75
75
|
|
|
76
76
|
qObj.process({ property: 'status', items: ['init'] }).then(res => {
|
|
77
|
-
|
|
77
|
+
qObj.logMsg(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
78
78
|
}, err => {
|
|
79
|
-
|
|
79
|
+
qObj.logMsg(`errors with status processing: (${JSON.stringify(err)})`.red)
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
// qObj.process({ property: 'status', items: ['error'] }).then(res => {
|
|
83
|
-
//
|
|
83
|
+
// qObj.logMsg(`success with status error processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
84
84
|
// }, err => {
|
|
85
|
-
//
|
|
85
|
+
// qObj.logMsg(`errors with status error processing: (${JSON.stringify(err)})`.red)
|
|
86
86
|
// })
|
package/test_sync_all.js
CHANGED
|
@@ -15,8 +15,8 @@ class test1 {
|
|
|
15
15
|
|
|
16
16
|
process(callback) {
|
|
17
17
|
setTimeout(() => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
qObj.logMsg(`processing test1`.cyan)
|
|
19
|
+
qObj.logMsg(`some async process`)
|
|
20
20
|
callback({success: {msg: `processing all (${this.id})`}})
|
|
21
21
|
}, 3000)
|
|
22
22
|
}
|
|
@@ -35,7 +35,7 @@ class test2 {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
ping() {
|
|
38
|
-
|
|
38
|
+
qObj.logMsg('hello from test2'.rainbow)
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -71,9 +71,9 @@ let qObj = new queue(), props = { appender: 'sync_all' }
|
|
|
71
71
|
qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(tst4.custom_function)
|
|
72
72
|
|
|
73
73
|
qObj.process().then(res => {
|
|
74
|
-
|
|
74
|
+
qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
75
75
|
}, err => {
|
|
76
|
-
|
|
76
|
+
qObj.logMsg(`errors with all sync processing: (${JSON.stringify(err)})`.red)
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
|
package/test_top_one.js
CHANGED
|
@@ -23,8 +23,8 @@ class test3 {
|
|
|
23
23
|
let qObj = new queue(), props = { appender: 'top_one', stats: true}
|
|
24
24
|
|
|
25
25
|
qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
|
|
26
|
-
|
|
26
|
+
qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
27
27
|
}, err => {
|
|
28
|
-
|
|
28
|
+
qObj.logMsg(`errors with all sync processing: (${JSON.stringify(err)})`.red)
|
|
29
29
|
})
|
|
30
30
|
|
package/test_version.js
CHANGED
|
@@ -35,7 +35,7 @@ class test2 {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
ping() {
|
|
38
|
-
|
|
38
|
+
qObj.logMsg('hello from test2'.rainbow)
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -85,13 +85,13 @@ let qObj = new queue(), props = { appender: 'version' }
|
|
|
85
85
|
qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4()).add(new test5())
|
|
86
86
|
|
|
87
87
|
qObj.process({ property: 'version', items: ['dev', 'test'] }).then(res => {
|
|
88
|
-
|
|
88
|
+
qObj.logMsg(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
89
89
|
}, err => {
|
|
90
|
-
|
|
90
|
+
qObj.logMsg(`errors with status processing: (${JSON.stringify(err)})`.red)
|
|
91
91
|
})
|
|
92
92
|
|
|
93
93
|
// qObj.process({ property: 'version', items: ['v1234'] }).then(res => {
|
|
94
|
-
//
|
|
94
|
+
// qObj.logMsg(`4) done with version synchronous processing: (${res})`.bold.italic.green)
|
|
95
95
|
// }, err => {
|
|
96
|
-
//
|
|
96
|
+
// qObj.logMsg(`4) errors with version synchronous processing: (${err})`.red)
|
|
97
97
|
// })
|