queueobj 8.0.0 → 9.0.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/README.md CHANGED
@@ -3,11 +3,11 @@ Queue javascript objects dynamically then process the queue according to the app
3
3
 
4
4
  Included tag appenders:
5
5
 
6
- * all - asynchronous - process all added objects.
7
- * func_all - asynchronous - process custom functions to added objects.
8
- * top_one - asynchronous - process only the object in the 0(zero) position of the process array.
9
- * bottom_one - asynchronous - process only the object in the last position of the process array.
10
- * sync_all - synchronous - queue and process all objects by items as well as custom functions.
6
+ * all - synchronous - process all added objects.
7
+ * func_all - synchronous - process custom functions to added objects.
8
+ * top_one - synchronous - process only the object in the 0(zero) position of the process array.
9
+ * bottom_one - synchronous - process only the object in the last position of the process array.
10
+ * sync_all - synchronous - All appenders are synchronous now. Sync_all is no different than all .
11
11
  * status - synchronous - queue and process all objects by status.
12
12
  * version - synchronous - queue and process all objects by version.
13
13
 
package/app.js CHANGED
@@ -8,7 +8,6 @@ var colors = require('colors'),
8
8
  func_all = require('./lib/appenders/func_all'),
9
9
  top_one = require('./lib/appenders/top_one'),
10
10
  bottom_one = require('./lib/appenders/bottom_one'),
11
- sync = require('./lib/appenders/sync'),
12
11
  sync_all = require('./lib/appenders/sync_all'),
13
12
  status = require('./lib/appenders/status'),
14
13
  version = require('./lib/appenders/version')
@@ -36,7 +35,6 @@ class QueueObj {
36
35
 
37
36
  t.load = t.load.bind(this)
38
37
  t.process = t.process.bind(this)
39
- t.await = t.await.bind(this)
40
38
  t.getParent = t.getParent.bind(this)
41
39
  t.getObjectToProcess = t.getObjectToProcess.bind(this)
42
40
  t.getObjectById = t.getObjectById.bind(this)
@@ -160,38 +158,39 @@ class QueueObj {
160
158
  var t = this
161
159
  try {
162
160
  if (t.all != null) {
163
- obj.getType = (o) => {
161
+ obj._getProperty = (o) => {
164
162
  return 'all'
165
163
  }
166
164
  }
167
165
  if (t.top_one != null) {
168
- obj.getType = (o) => {
166
+ obj._getProperty = (o) => {
169
167
  return 'top_one'
170
168
  }
171
169
  }
172
170
  if (t.bottom_one != null) {
173
171
  t.objs = []
174
- obj.getType = (o) => {
172
+ obj._getProperty = (o) => {
175
173
  return 'bottom_one'
176
174
  }
177
175
  }
178
176
  if (t.func_all != null) {
179
- obj.getType = (o) => {
177
+ obj._getProperty = (o) => {
180
178
  return 'func_all'
181
179
  }
182
180
  }
183
181
  if (t.sync_all != null) {
184
- obj.getType = (o) => {
182
+ obj._getProperty = (o) => {
185
183
  return 'sync_all'
186
184
  }
187
185
  }
188
186
  if (typeof obj.status != 'undefined') {
189
- obj.getType = (o) => {
187
+ obj._getProperty = (o) => {
190
188
  return o.status
191
189
  }
190
+
192
191
  }
193
192
  if (typeof obj.version != 'undefined') {
194
- obj.getType = (o) => {
193
+ obj._getProperty = (o) => {
195
194
  return o.version
196
195
  }
197
196
  }
@@ -218,45 +217,25 @@ class QueueObj {
218
217
  return this.objs
219
218
  }
220
219
 
221
- process() {
220
+ process(props = {}) {
222
221
  try {
223
- var t = this, pro = { dat_array: [] }
224
- switch (t.props.appender) {
222
+ var t = this
223
+ switch (t.props.appender) {
225
224
  case 'all':
226
- pro.dat_array.push('all')
227
- t.all.await(pro)
228
- return t.all.process()
225
+ return t.all.process(props)
229
226
  case 'top_one':
230
- pro.dat_array.push('top_one')
231
- t.top_one.await(pro)
232
- return t.top_one.process()
227
+ return t.top_one.process(props)
233
228
  case 'bottom_one':
234
- pro.dat_array.push('bottom_one')
235
- t.bottom_one.await(pro)
236
- return t.bottom_one.process()
229
+ return t.bottom_one.process(props)
237
230
  case 'func_all':
238
- pro.dat_array.push('func_all')
239
- t.func_all.await(pro)
240
- return t.func_all.process()
231
+ return t.func_all.process(props)
241
232
  case 'sync':
242
233
  case 'sync_all':
243
- pro.dat_array.push('sync_all')
244
- t.sync_all.await(pro)
245
- return t.sync_all.process()
234
+ return t.sync_all.process(props)
246
235
  case 'status':
247
- return t.status.process()
236
+ return t.status.process(props)
248
237
  case 'version':
249
- return t.version.process()
250
- // case 'sync_all':
251
- // t.objs.map((item, i) => {
252
- // pro.items.push(i)
253
- // })
254
- // t.sync.await(pro).then(res => {
255
- // console.log(`done with ${JSON.stringify(pro)}: (${res})`.green)
256
- // }, err => {
257
- // console.log(`error ${JSON.stringify(pro)}: (${err})`.red)
258
- // })
259
- // return t.sync.process()
238
+ return t.version.process(props)
260
239
  default:
261
240
  throw new Error(`nothing to process`)
262
241
  }
@@ -266,28 +245,6 @@ class QueueObj {
266
245
  throw (e)
267
246
  }
268
247
  }
269
-
270
- await(props) {
271
- var t = this, pro
272
- try {
273
- if (t.sync != null) {
274
- pro = { dat_array: props.items }
275
- return t.sync.await(props)
276
- }
277
- if (t.status != null) {
278
- pro = { dat_array: props.status }
279
- return t.status.await(pro)
280
- }
281
- if (t.version != null) {
282
- pro = { dat_array: props.version }
283
- return t.version.await(pro)
284
- }
285
- } catch (e) {
286
- e.message = "queueObj app.js load error: " + e.message
287
- console.log(e.message)
288
- throw (e)
289
- }
290
- }
291
248
  }
292
249
 
293
250
  exports = module.exports = function (props) {
@@ -6,43 +6,135 @@
6
6
 
7
7
  var colors = require('colors')
8
8
 
9
+ class process_all_obj {
10
+ constructor(props) {
11
+ let t = this
12
+ t.parent = props.parent
13
+ t.objs = t.parent.getParent().getObjs()
14
+ t.status = 'process'
15
+ t.process_objs_item = 0
16
+ t.process_props_item = 0
17
+ t.await_item = 0
18
+ t.any_errors = false
19
+
20
+
21
+ t.continueProcessing = t.continueProcessing.bind(t)
22
+ }
23
+
24
+ process = () => {
25
+ let t = this
26
+ try {
27
+ if (t.process_objs_item >= t.objs.length) {
28
+ if (t.any_errors)
29
+ t.setStatus('finish with errors')
30
+ else
31
+ t.setStatus('finish')
32
+ return
33
+ }
34
+ try {
35
+ let obj, pro, itm
36
+ try {
37
+ obj = t.parent.getParent().getItemToProcess(t.process_objs_item)
38
+ } catch (e) {
39
+ e.message = `base error: (${e.message})`
40
+ throw e
41
+ }
42
+ try {
43
+ pro = (typeof obj == 'function') ? obj : obj.process;
44
+ } catch (e) {
45
+ console.log(`pro error: (${e.message})`.red)
46
+ throw e
47
+ }
48
+ if (typeof t.parent.pro_props != 'undefined' &&
49
+ typeof t.parent.pro_props.property != 'undefined' &&
50
+ typeof t.parent.pro_props.items != 'undefined' &&
51
+ typeof obj._getProperty == 'function') {
52
+ let skip = true
53
+ for (let q = 0; q < t.parent.pro_props.items.length; q++) {
54
+ itm = t.parent.pro_props.items[q]
55
+ if (itm == obj._getProperty(obj)) {
56
+ skip = false
57
+ break
58
+ }
59
+ }
60
+ if (skip) {
61
+ t.continueProcessing()
62
+ return
63
+ }
64
+ }
65
+ t.setStatus('wait')
66
+ pro((obj_props) => {
67
+ try {
68
+ if (typeof obj_props != 'undefined' && typeof obj_props.error != 'undefined') {
69
+ t.any_errors = true
70
+ console.log(`${JSON.stringify(obj_props)}`.red)
71
+ } else {
72
+ console.log(`${JSON.stringify(obj_props)}`.green)
73
+ }
74
+ t.parent.results_array.push(obj_props)
75
+ t.continueProcessing()
76
+ } catch (e) {
77
+ console.log(`pro obj error: (${e.message})`.red)
78
+ throw e
79
+ }
80
+ })
81
+ } catch (e) {
82
+ e.message = `10.01 error: ${e.message} `
83
+ throw e
84
+ }
85
+ } catch (e) {
86
+ e.message = `process_all_obj error: ${e.message} `
87
+ throw e
88
+ }
89
+ }
90
+
91
+ continueProcessing = () => {
92
+ let t = this
93
+ t.process_objs_item++
94
+ t.setStatus('process')
95
+ t.parent.process_all()
96
+ }
97
+
98
+ getStatus = () => {
99
+ return this.status
100
+ }
101
+
102
+ setStatus = (v) => {
103
+ this.status = v
104
+ }
105
+ }
106
+
9
107
  exports = module.exports = class base {
10
108
  constructor(props) {
11
109
  let t = this
12
110
  t.await_array = []
13
111
  t.resolve_array = []
14
112
  t.reject_array = []
15
- t.process_objs_item = 0
16
- t.process_props_item = 0
17
- t.any_errors = false
113
+ t.results_array = []
18
114
  t.getParent = props.getParent
19
115
  t.dt_start = null
20
116
  t.dt_end = null
117
+ t.process_all_obj = null
118
+ t.pro_props = []
21
119
 
22
120
  t.process = t.process.bind(this)
23
121
  t.process_all = t.process_all.bind(this)
24
122
  }
25
123
 
124
+ // await(props) {
125
+ // let t = this
126
+ // t.await_array.push(props)
127
+ // return new Promise((resolve, reject) => {
128
+ // t.resolve_array.push(resolve)
129
+ // t.reject_array.push(reject)
130
+ // });
131
+ // }
26
132
 
27
- await(props) {
28
- let t = this
29
- t.await_array.push(props)
30
- return new Promise((resolve, reject) => {
31
- t.resolve_array.push(resolve)
32
- t.reject_array.push(reject)
33
- });
34
- }
35
-
36
- process() {
133
+ process(props) {
37
134
  let t = this
38
- t.process_objs_item = 0
39
- t.process_props_item = 0
40
- t.await_item = 0
41
135
  t.dt_start = new Date(); // start measuring time
42
- // t.await_array = []
43
- // t.resolve_array = []
44
- // t.reject_array = []
45
- // t.status_props_array = []
136
+
137
+ t.pro_props = props
46
138
 
47
139
  return new Promise((resolve, reject) => {
48
140
  t.resolve_array.push(resolve)
@@ -52,112 +144,45 @@ exports = module.exports = class base {
52
144
  }
53
145
 
54
146
  getStats() {
55
- let t = this, msg, st = `${t.dt_start}`.green, ed = `${t.dt_end}`.green, ml = `${t.dt_end - t.dt_start}`.green
56
- msg = `success`.green
57
- if (t.getParent().getStats())
58
- msg += `\nstart(${st}) end(${ed}) milliseconds(${ml})`
59
- return msg
147
+ let t = this, json_ret = { execution_time: 'status is set to false' }, st = `${t.dt_start} `.green, ed = `${t.dt_end} `.green, ml = `${t.dt_end - t.dt_start} `.green
148
+ json_ret.responses = t.results_array
149
+ if (t.getParent().getStats()) {
150
+ json_ret.execution_time = `start`.green
151
+ json_ret.execution_time += `(${st}) end(${ed}) milliseconds(${ml})`
152
+ }
153
+ return json_ret
60
154
  }
61
155
 
62
- process_all() {
63
- let t = this, obj, pro, itm, msg, itm_type, props_type, datA
156
+ process_all = () => {
157
+ let t = this, _continue
158
+ if (t.process_all_obj == null) {
159
+ t.process_all_obj = new process_all_obj({ parent: t })
160
+ }
161
+
162
+ _continue = false
64
163
  try {
65
- try {
66
- if (t.process_objs_item >= t.getParent().getObjs().length) {
67
- t.await_item++
164
+ switch (t.process_all_obj.getStatus()) {
165
+ case 'process':
166
+ t.process_all_obj.process()
167
+ _continue = true
168
+ break
169
+ case 'finish with errors':
170
+ t.reject_array[t.reject_array.length - 1](t.getStats())
171
+ break
172
+ case 'finish':
68
173
  t.resolve_array[t.resolve_array.length - 1](t.getStats())
174
+ break
175
+ case 'wait':
69
176
  return
70
- }
71
- } catch (e) {
72
- return
177
+ default:
178
+ throw new Error(`status(${t.process_all_obj.getStatus()}) does not exist`)
73
179
  }
74
- try {
75
- datA = t.await_array[t.await_item].dat_array
76
- } catch (e) {
77
- return
78
- }
79
- try {
80
180
 
81
- datA.map((dat_item, i) => {
82
- if (i == t.process_props_item) {
83
- if (t.process_props_item < datA.length) {
84
- if ((t.await_item) >= t.await_array.length) {
85
- t.resolve_array[t.resolve_array.length - 1](t.getStats())
86
- return
87
- }
88
- t.getParent().getObjs().map((pItem, x) => {
89
- if (x == t.process_objs_item) {
90
- try {
91
- obj = t.getParent().getItemToProcess(x)
92
- } catch (e) {
93
- e.message = `base error: (${e.message})`
94
- throw e
95
- }
96
- if (typeof obj != 'undefined' && typeof obj.getType != 'function') {
97
- obj.getType = (o) => { return t.aname }
98
- }
99
- if (obj.getType(obj) == dat_item) {
100
- try {
101
- pro = (typeof obj == 'function') ? obj : obj.process;
102
- } catch (e) {
103
- console.log(`pro error: (${e.message})`.red)
104
- throw e
105
- }
106
-
107
- pro((obj_props) => {
108
- try {
109
-
110
- if (typeof obj_props != 'undefined' &&
111
- typeof obj_props.error != 'undefined' &&
112
- typeof obj_props.error.msg != 'undefined' &&
113
- typeof obj_props.error.msg == 'string') {
114
- msg = `error: ${obj_props.error.msg}`
115
- msg += (typeof obj.id != 'undefined') ? ` id(${obj.id})` : ``;
116
- t.any_errors = true
117
- t.reject_array[t.process_props_item](msg)
118
- }
119
- t.process_objs_item++
120
- if (t.process_props_item < datA.length) {
121
- t.process_all()
122
- } else {
123
- t.dt_end = new Date();
124
- t.resolve_array[t.process_props_item - 1](t.getStats())
125
- t.process_props_item = 0
126
- t.process_objs_item = 0
127
- }
128
- } catch (e) {
129
- console.log(`proessing error: (${e.message})`.red)
130
- throw e
131
- }
132
- })
133
- } else {
134
- t.process_objs_item++
135
- if (t.process_objs_item >= t.getParent().getObjs().length) {
136
- t.resolve_array[t.resolve_array.length - 1](t.getStats())
137
- }
138
- }
139
- } else {
140
- if (t.process_objs_item >= t.getParent().getObjs().length) {
141
- t.process_objs_item = 0
142
- t.process_props_item++
143
- if (t.process_props_item >= datA.length) {
144
- t.await_item++
145
- t.process_props_item = 0
146
- if (t.await_item <= t.await_array.length)
147
- t.process_all()
148
- }
149
- }
150
- }
151
- })
152
- }
153
- }
154
- })
155
- } catch (e) {
156
- e.message = `await error: ${e.message}`
157
- throw e
158
- }
181
+ if (_continue)
182
+ t.process_all()
159
183
  } catch (e) {
160
- console.log(`process_all error: ${e.message}`.red)
184
+ e.message = `process_all error: ${e.message} `
185
+ throw e
161
186
  }
162
187
  }
163
188
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "8.0.0",
5
+ "version": "9.0.0",
6
6
  "bundleDependencies": false,
7
7
  "dependencies": {
8
8
  "chai": "^4.3.3",
@@ -19,9 +19,7 @@
19
19
  "processing",
20
20
  "appenders",
21
21
  "javascript",
22
- "asynchronous",
23
22
  "synchronous",
24
- "await",
25
23
  "objects",
26
24
  "promises",
27
25
  "mocha"
package/test/package.js CHANGED
@@ -6,7 +6,7 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "8.0.0",
9
+ "version": "9.0.0",
10
10
  "bundleDependencies": false,
11
11
  "dependencies": {
12
12
  "chai": "^4.3.3",
@@ -23,9 +23,7 @@ const packageMock = {
23
23
  "processing",
24
24
  "appenders",
25
25
  "javascript",
26
- "asynchronous",
27
26
  "synchronous",
28
- "await",
29
27
  "objects",
30
28
  "promises",
31
29
  "mocha"
package/test_all.js CHANGED
@@ -3,41 +3,41 @@ var colors = require('colors')
3
3
  var queue = require("./app.js");
4
4
 
5
5
  class test1 {
6
- process(callback){
7
- console.log(`processing all test1`.cyan)
8
- callback()
6
+ process(callback) {
7
+ callback({ success: { msg: `processing all test1` } })
9
8
  }
10
9
  }
11
10
 
12
11
  class test2 {
13
- constructor(obj){
14
- obj.add(new test4())
15
- }
16
12
 
17
- process(callback){
18
- console.log(`processing all test2`.cyan)
19
- callback()
13
+ process(callback) {
14
+ callback({ success: { msg: `processing all test2` } })
20
15
  }
21
16
  }
22
17
 
23
18
  class test3 {
24
- process(callback){
25
- console.log(`processing all test3`.cyan)
26
- callback()
19
+ process(callback) {
20
+ callback({success: { msg: `processing all test3` }})
21
+ // callback({ error: { msg: `there is some problem thrown here on test3` } })
27
22
  }
28
23
  }
29
24
 
30
25
  class test4 {
31
- process(callback){
32
- console.log(`processing all test4`.cyan)
33
- callback()
26
+ process(callback) {
27
+ callback({ success: { msg: `processing all test4` } })
34
28
  }
35
29
  }
36
30
 
37
- let qObj = new queue(), props = { appender: 'all', stats: true}
31
+ let qObj = new queue(), props = { appender: 'all', stats: true }
38
32
 
39
- qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
40
- console.log(res)
33
+ qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4()).process({}).then(res => {
34
+ console.log(`success with all processing: (${JSON.stringify(res)})`.bold.italic.green)
41
35
  }, err => {
42
- console.log(`errors with all processing: (${err})`.red)
36
+ // console.log(`error with all processing: (${JSON.stringify(err)})`.red) //show all results
37
+ console.log(`error with all processing: (${err.execution_time})`.red) //show the execution time
38
+ err.responses.map((jItem, i) => {
39
+ if (typeof jItem.error != 'undefined' && typeof jItem.error.msg != 'undefined') {
40
+ console.log(`error: ${jItem.error.msg}`.red) //show the error
41
+ }
42
+ })
43
43
  })
@@ -4,29 +4,26 @@ var queue = require("./app.js");
4
4
 
5
5
  class test1 {
6
6
  process(callback) {
7
- console.log(`processing test1`.cyan)
8
- callback()
7
+ callback({success: {msg: `processing test1`}})
9
8
  }
10
9
  }
11
10
 
12
11
  class test2 {
13
12
  process(callback) {
14
- console.log(`processing test2`.cyan)
15
- callback()
13
+ callback({success: {msg: `processing test2`}})
16
14
  }
17
15
  }
18
16
 
19
17
  class test3 {
20
18
  process(callback) {
21
- console.log(`processing test3`.cyan)
22
- callback()
19
+ callback({success: {msg: `processing test3`}})
23
20
  }
24
21
  }
25
22
 
26
- let qObj = new queue(), props = { appender: 'bottom_one', stats: true}
23
+ let qObj = new queue(), props = { appender: 'bottom_one', stats: false}
27
24
 
28
25
  qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
29
- console.log(res)
26
+ console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
30
27
  }, err => {
31
- console.log(`errors with bottom item processing: (${err})`.red)
28
+ console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
32
29
  })
package/test_func_all.js CHANGED
@@ -4,15 +4,13 @@ var queue = require("./app.js");
4
4
 
5
5
  class test1 {
6
6
  some_function(callback) {
7
- console.log(`some_function test1`.cyan)
8
- callback()
7
+ callback({success: {msg: `some_function test1`}})
9
8
  }
10
9
  }
11
10
 
12
11
  class test2 {
13
12
  a_func(callback) {
14
- console.log(`a_func test2`.cyan)
15
- callback()
13
+ callback({success: {msg: `a_func test2`}})
16
14
  }
17
15
  }
18
16
 
@@ -21,15 +19,13 @@ class test3 {
21
19
  obj.add(run_func.some_new_func)
22
20
  }
23
21
  cool(callback) {
24
- console.log(`cool test3`.cyan)
25
- callback()
22
+ callback({success: {msg: `cool test3`}})
26
23
  }
27
24
  }
28
25
 
29
26
  class test4 {
30
27
  some_new_func(callback) {
31
- console.log(`some_new_func test4`.cyan)
32
- callback()
28
+ callback({success: {msg: `some_new_func test4`}})
33
29
  }
34
30
  }
35
31
 
@@ -41,6 +37,8 @@ let tst1 = new test1(),
41
37
  tst3 = new test3(qObj, tst4)
42
38
 
43
39
  qObj.load(props).add(tst1.some_function).add(tst2.a_func).add(tst3.cool).process().then(res => {
44
- console.log(`success processing`.green)
40
+ console.log(`success with func_all processing: (${JSON.stringify(res)})`.bold.italic.green)
41
+ }, err => {
42
+ console.log(`errors with func_all processing: (${JSON.stringify(err)})`.red)
45
43
  })
46
44
 
package/test_status.js CHANGED
@@ -17,9 +17,7 @@ class test1 {
17
17
  }
18
18
 
19
19
  process(callback) {
20
- console.log(`processing test1`.cyan)
21
- this.status = "done"
22
- callback()
20
+ callback({success: {msg: `processing test1 id(${this.id}) status(${this.status})`}})
23
21
  }
24
22
  }
25
23
 
@@ -27,18 +25,15 @@ class test2 {
27
25
  constructor() {
28
26
  let t = this
29
27
  t.id = 200
30
- t.status = "new"
28
+ t.status = "error"
31
29
 
32
30
  t.process = t.process.bind(t)
33
31
  }
34
32
 
35
33
  process(callback) {
36
34
  let t = this, msg = `some kinda problem here`
37
- console.log(`processing test2`.cyan)
38
- t.status = "error"
39
35
  // callback({error: {msg: msg}}) //this will show errors
40
- t.status = "done"
41
- callback() //this will show no errors
36
+ callback({success: {msg: `processing test2 id(${this.id}) status(${this.status})`}}) //this will show no errors
42
37
  }
43
38
 
44
39
  ping() {
@@ -56,10 +51,7 @@ class test3 {
56
51
  }
57
52
 
58
53
  process(callback) {
59
- console.log(`processing test3`.cyan)
60
- console.log(`some async process`)
61
- this.status = "done"
62
- callback()
54
+ callback({success: {msg: `processing test3 id(${this.id}) status(${this.status})`}}) //this will show no errors
63
55
  }
64
56
  }
65
57
 
@@ -73,30 +65,22 @@ class test4 {
73
65
  }
74
66
 
75
67
  process(callback) {
76
- console.log(`processing test4`.cyan)
77
- this.status = "done"
78
- callback()
68
+ callback({success: {msg: `processing test4 id(${this.id}) status(${this.status})`}}) //this will show no errors
79
69
  }
80
70
  }
81
71
 
82
- let qObj = new queue(), props = { appender: 'status' }
72
+ let qObj = new queue(), props = { appender: 'status', stats: true }
83
73
 
84
74
  qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4())
85
75
 
86
- qObj.await({ status: ['new', 'secondary'] }).then(res => {
87
- console.log(`1) done with status'[new', 'secondary']: (${res})`.green)
76
+ qObj.process({ property: 'status', items: ['new', 'secondary'] }).then(res => {
77
+ console.log(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
88
78
  }, err => {
89
- console.log(`1) error['new', 'secondary']: (${err})`.red)
79
+ console.log(`errors with status processing: (${JSON.stringify(err)})`.red)
90
80
  })
91
81
 
92
- qObj.await({ status: ['third'] }).then(res => {
93
- console.log(`2) done with status['third']: (${res})`.green)
94
- }, err => {
95
- console.log(`2) error['third']: (${err})`.red)
96
- })
97
-
98
- qObj.process().then(res => {
99
- console.log(`3) done with status processing: (${res})`.bold.italic.blue)
100
- }, err => {
101
- console.log(`3) errors with status processing: (${err})`.red)
102
- })
82
+ // qObj.process({ property: 'status', items: ['error'] }).then(res => {
83
+ // console.log(`success with status error processing: (${JSON.stringify(res)})`.bold.italic.green)
84
+ // }, err => {
85
+ // console.log(`errors with status error processing: (${JSON.stringify(err)})`.red)
86
+ // })
package/test_sync_all.js CHANGED
@@ -10,13 +10,14 @@ var queue = require("./app.js");
10
10
  class test1 {
11
11
  constructor() {
12
12
  this.id = 100
13
+ this.process = this.process.bind(this)
13
14
  }
14
15
 
15
16
  process(callback) {
16
- setTimeout(()=>{
17
+ setTimeout(() => {
17
18
  console.log(`processing test1`.cyan)
18
19
  console.log(`some async process`)
19
- callback()
20
+ callback({success: {msg: `processing all (${this.id})`}})
20
21
  }, 3000)
21
22
  }
22
23
  }
@@ -24,13 +25,13 @@ class test1 {
24
25
  class test2 {
25
26
  constructor() {
26
27
  this.id = 200
28
+ this.process = this.process.bind(this)
27
29
  }
28
30
 
29
31
  process(callback) {
30
- let msg = `some kinda problem here`
31
- console.log(`processing test2`.cyan)
32
- //callback({error: {msg: msg}}) //this will show errors
33
- callback() //this will show no errors
32
+ let msg = `some kinda problem here in id(${this.id})`
33
+ // callback({error: {msg: msg}}) //this will show errors
34
+ callback({success: {msg: `processing all (${this.id})}`}}) //this will show no errors
34
35
  }
35
36
 
36
37
  ping() {
@@ -41,11 +42,11 @@ class test2 {
41
42
  class test3 {
42
43
  constructor() {
43
44
  this.id = 300
45
+ this.process = this.process.bind(this)
44
46
  }
45
47
 
46
48
  process(callback) {
47
- console.log(`processing test3`.cyan)
48
- callback()
49
+ callback({success: {msg: `processing all (${this.id})}`}})
49
50
  }
50
51
  }
51
52
 
@@ -58,9 +59,10 @@ class test4 {
58
59
 
59
60
  custom_function(callback) {
60
61
  let msg = `custom func problem here id(${this.id})`
61
- console.log(`processing test4`.cyan)
62
- //callback({error: {msg: msg}}) //this will show errors
63
- callback() //this will show no errors
62
+ setTimeout(() => {
63
+ // callback({error: {msg: msg}}) //this will show errors
64
+ callback({success: {msg: `processing all (${this.id})}`}}) //this will show no errors
65
+ }, 3000)
64
66
  }
65
67
  }
66
68
  let tst4 = new test4()
@@ -69,9 +71,9 @@ let qObj = new queue(), props = { appender: 'sync_all' }
69
71
  qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(tst4.custom_function)
70
72
 
71
73
  qObj.process().then(res => {
72
- console.log(`done with all sync processing: (${res})`.bold.italic.blue)
74
+ console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
73
75
  }, err => {
74
- console.log(`errors with all sync processing: (${err})`.red)
76
+ console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
75
77
  })
76
78
 
77
79
 
package/test_top_one.js CHANGED
@@ -4,29 +4,27 @@ var queue = require("./app.js");
4
4
 
5
5
  class test1 {
6
6
  process(callback){
7
- console.log(`processing test1`.cyan)
8
- callback()
7
+ callback({success: {msg: `processing test1`}})
9
8
  }
10
9
  }
11
10
 
12
11
  class test2 {
13
12
  process(callback){
14
- console.log(`processing test2`.cyan)
15
- callback()
13
+ callback({success: {msg: `processing test2`}})
16
14
  }
17
15
  }
18
16
 
19
17
  class test3 {
20
18
  process(callback){
21
- console.log(`processing test3`.cyan)
22
- callback()
19
+ callback({success: {msg: `processing test3`}})
23
20
  }
24
21
  }
25
22
 
26
23
  let qObj = new queue(), props = { appender: 'top_one', stats: true}
27
24
 
28
25
  qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
29
- console.log(res)
26
+ console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
30
27
  }, err => {
31
- console.log(`errors with top item processing: (${err})`.red)
28
+ console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
32
29
  })
30
+
package/test_version.js CHANGED
@@ -17,10 +17,7 @@ class test1 {
17
17
  }
18
18
 
19
19
  process(callback) {
20
- let t = this
21
- console.log(`processing test1 version(${t.version})`.cyan)
22
- this.status = "done"
23
- callback()
20
+ callback({success: {msg: `processing test1 id(${this.id}) version(${this.version})`}})
24
21
  }
25
22
  }
26
23
 
@@ -34,10 +31,7 @@ class test2 {
34
31
  }
35
32
 
36
33
  process(callback) {
37
- let t = this, msg = `some kinda error is detected here`
38
- console.log(`processing test2 version(${t.version})`.cyan)
39
- // callback({error: {msg: msg}}) //this will show errors
40
- callback() //this will have no errors
34
+ callback({success: {msg: `processing test2 id(${this.id}) version(${this.version})`}})
41
35
  }
42
36
 
43
37
  ping() {
@@ -55,10 +49,7 @@ class test3 {
55
49
  }
56
50
 
57
51
  process(callback) {
58
- let t = this
59
- console.log(`processing test3 version(${t.version})`.cyan)
60
- console.log(`some async process`)
61
- callback()
52
+ callback({success: {msg: `processing test3 id(${this.id}) version(${this.version})`}})
62
53
  }
63
54
  }
64
55
 
@@ -72,9 +63,7 @@ class test4 {
72
63
  }
73
64
 
74
65
  process(callback) {
75
- let t = this
76
- console.log(`processing test4 version(${t.version})`.cyan)
77
- callback()
66
+ callback({success: {msg: `processing test4 id(${this.id}) version(${this.version})`}})
78
67
  }
79
68
  }
80
69
 
@@ -88,35 +77,21 @@ class test5 {
88
77
  }
89
78
 
90
79
  process(callback) {
91
- let t = this
92
- console.log(`processing test5 version(${t.version})`.cyan)
93
- callback()
80
+ callback({success: {msg: `processing test5 id(${this.id}) version(${this.version})`}})
94
81
  }
95
82
  }
96
83
  let qObj = new queue(), props = { appender: 'version' }
97
84
 
98
85
  qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4()).add(new test5())
99
86
 
100
- qObj.await({ version: ['dev', 'test'] }).then(res => {
101
- console.log(`1) done with version['dev', 'test']: (${res})`.green)
87
+ qObj.process({ property: 'version', items: ['dev', 'test'] }).then(res => {
88
+ console.log(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
102
89
  }, err => {
103
- console.log(`1) error['dev', 'test']: (${err})`.red)
90
+ console.log(`errors with status processing: (${JSON.stringify(err)})`.red)
104
91
  })
105
92
 
106
- qObj.await({ version: ['prod'] }).then(res => {
107
- console.log(`2) done with version['prod']: (${res})`.green)
108
- }, err => {
109
- console.log(`2) error['prod']: (${err})`.red)
110
- })
111
-
112
- qObj.await({ version: ['v1234'] }).then(res => {
113
- console.log(`3) done with version['v1234']: (${res})`.green)
114
- }, err => {
115
- console.log(`3) error['v1234']: (${err})`.red)
116
- })
117
-
118
- qObj.process().then(res => {
119
- console.log(`4) done with version synchronous processing: (${res})`.bold.italic.blue)
120
- }, err => {
121
- console.log(`4) errors with version synchronous processing: (${err})`.red)
122
- })
93
+ // qObj.process({ property: 'version', items: ['v1234'] }).then(res => {
94
+ // console.log(`4) done with version synchronous processing: (${res})`.bold.italic.green)
95
+ // }, err => {
96
+ // console.log(`4) errors with version synchronous processing: (${err})`.red)
97
+ // })