queueobj 9.1.1 → 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 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,48 +109,53 @@ 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
- if (typeof props != `undefined` &&
117
- typeof props.appender != `undefined` &&
118
- typeof props.appender == 'string') {
119
- props.getParent = t.getParent
120
- switch (props.appender) {
121
- case 'all':
122
- t.all = new all(props)
123
- break
124
- case 'top_one':
125
- t.top_one = new top_one(props)
126
- break
127
- case 'bottom_one':
128
- t.bottom_one = new bottom_one(props)
129
- break
130
- case 'func_all':
131
- t.func_all = new func_all(props)
132
- break
133
- case 'array':
134
- t.array = new array(props)
135
- break
136
- case 'status':
137
- t.status = new status(props)
138
- break
139
- case 'version':
140
- t.version = new version(props)
141
- break
142
- case 'sync_all':
143
- t.sync_all = new sync_all(props)
144
- break
145
- default:
146
- throw new Error(`appender(${props.appender}) not found`)
121
+ if (typeof props != `undefined`) {
122
+ if (typeof props.appender != `undefined` &&
123
+ typeof props.appender == 'string') {
124
+ props.getParent = t.getParent
125
+ switch (props.appender) {
126
+ case 'all':
127
+ t.all = new all(props)
128
+ break
129
+ case 'top_one':
130
+ t.top_one = new top_one(props)
131
+ break
132
+ case 'bottom_one':
133
+ t.bottom_one = new bottom_one(props)
134
+ break
135
+ case 'func_all':
136
+ t.func_all = new func_all(props)
137
+ break
138
+ case 'array':
139
+ t.array = new array(props)
140
+ break
141
+ case 'status':
142
+ t.status = new status(props)
143
+ break
144
+ case 'version':
145
+ t.version = new version(props)
146
+ break
147
+ case 'sync_all':
148
+ t.sync_all = new sync_all(props)
149
+ break
150
+ default:
151
+ throw new Error(`appender(${props.appender}) not found`)
152
+ }
147
153
  }
148
154
  return t
149
155
  }
150
156
  } catch (e) {
151
157
  e.message = "queueObj app.js load error: " + e.message
152
- console.log(e.message)
158
+ t.logMsg(e.message)
153
159
  throw (e)
154
160
  }
155
161
  }
@@ -204,7 +210,7 @@ class QueueObj {
204
210
  return t
205
211
  } catch (e) {
206
212
  e.message = "queueObj app.js add error: " + e.message
207
- console.log(e.message.red)
213
+ t.logMsg(e.message.red)
208
214
  throw (e)
209
215
  }
210
216
  }
@@ -241,7 +247,7 @@ class QueueObj {
241
247
  }
242
248
  } catch (e) {
243
249
  e.message = "queueObj app.js load error: " + e.message
244
- console.log(e.message.red)
250
+ t.logMsg(e.message.red)
245
251
  throw (e)
246
252
  }
247
253
  }
@@ -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
- console.log(`pro error: (${e.message})`.red)
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
- console.log(`${JSON.stringify(obj_props)}`.red)
71
+ t.parent.getParent().logMsg(`${JSON.stringify(obj_props)}`.red)
72
72
  } else {
73
- console.log(`${JSON.stringify(obj_props)}`.green)
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
- console.log(`pro obj error: (${e.message})`.red)
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 = `10.01 error: ${e.message} `
83
+ e.message = `error: ${e.message} `
84
84
  throw e
85
85
  }
86
86
  } catch (e) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "9.1.1",
5
+ "version": "10.1.0",
6
6
  "bundleDependencies": false,
7
7
  "dependencies": {
8
8
  "chai": "^4.3.3",
package/test/package.js CHANGED
@@ -6,7 +6,7 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "9.1.1",
9
+ "version": "10.1.0",
10
10
  "bundleDependencies": false,
11
11
  "dependencies": {
12
12
  "chai": "^4.3.3",
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
- console.log(`success with all processing: (${JSON.stringify(res)})`.bold.italic.green)
34
+ qObj.logMsg(`success with all processing: (${JSON.stringify(res)})`.bold.italic.green)
35
35
  }, err => {
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
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
- console.log(`error: ${jItem.error.msg}`.red) //show the error
40
+ qObj.logMsg(`error: ${jItem.error.msg}`.red) //show the error
41
41
  }
42
42
  })
43
43
  })
@@ -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
- console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
26
+ qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
27
27
  }, err => {
28
- console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
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
- console.log(`success with func_all processing: (${JSON.stringify(res)})`.bold.italic.green)
40
+ qObj.logMsg(`success with func_all processing: (${JSON.stringify(res)})`.bold.italic.green)
41
41
  }, err => {
42
- console.log(`errors with func_all processing: (${JSON.stringify(err)})`.red)
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
- console.log('hello from test2'.rainbow)
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
- console.log(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
77
+ qObj.logMsg(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
78
78
  }, err => {
79
- console.log(`errors with status processing: (${JSON.stringify(err)})`.red)
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
- // console.log(`success with status error processing: (${JSON.stringify(res)})`.bold.italic.green)
83
+ // qObj.logMsg(`success with status error processing: (${JSON.stringify(res)})`.bold.italic.green)
84
84
  // }, err => {
85
- // console.log(`errors with status error processing: (${JSON.stringify(err)})`.red)
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
- console.log(`processing test1`.cyan)
19
- console.log(`some async process`)
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
- console.log('hello from test2'.rainbow)
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
- console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
74
+ qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
75
75
  }, err => {
76
- console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
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
- console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
26
+ qObj.logMsg(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
27
27
  }, err => {
28
- console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
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
- console.log('hello from test2'.rainbow)
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
- console.log(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
88
+ qObj.logMsg(`success with status processing: (${JSON.stringify(res)})`.bold.italic.green)
89
89
  }, err => {
90
- console.log(`errors with status processing: (${JSON.stringify(err)})`.red)
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
- // console.log(`4) done with version synchronous processing: (${res})`.bold.italic.green)
94
+ // qObj.logMsg(`4) done with version synchronous processing: (${res})`.bold.italic.green)
95
95
  // }, err => {
96
- // console.log(`4) errors with version synchronous processing: (${err})`.red)
96
+ // qObj.logMsg(`4) errors with version synchronous processing: (${err})`.red)
97
97
  // })