queueobj 11.0.2 → 12.0.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.
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
+ [![npm Package](https://img.shields.io/npm/v/queueobj.svg)](https://www.npmjs.org/package/queueobj)
2
+ [![License](https://img.shields.io/npm/l/queueobj.svg)](https://github.com/jman717/queueobj/blob/master/LICENSE)
3
+
4
+ [![NPM](https://nodei.co/npm/queueobj.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/queueobj/)
5
+
1
6
  Queue javascript objects dynamically then process the queue according to the appender.
2
7
 
8
+ ---------
9
+
3
10
  Included tag appenders:
4
11
 
5
12
  * all - synchronous - process all added objects.
@@ -11,11 +18,6 @@ Included tag appenders:
11
18
  * name - synchronous - queue and process all objects by name.
12
19
  * version - synchronous - queue and process all objects by version.
13
20
 
14
- Installation
15
- ---------
16
-
17
- [![NPM](https://nodei.co/npm/queueobj.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/queueobj/)
18
-
19
21
  Mocha Test
20
22
  ---------
21
23
  ```
package/app.js CHANGED
@@ -4,17 +4,19 @@
4
4
  */
5
5
 
6
6
  var colors = require('colors'),
7
- all = require('./lib/appenders/all'),
8
- func_all = require('./lib/appenders/func_all'),
9
- top_one = require('./lib/appenders/top_one'),
10
- bottom_one = require('./lib/appenders/bottom_one'),
11
- sync_all = require('./lib/appenders/sync_all'),
12
- status = require('./lib/appenders/status'),
13
- name = require('./lib/appenders/name'),
14
- version = require('./lib/appenders/version')
7
+ file_queue = new require('file-obj-queue'),
8
+ file_requre_data = [
9
+ { props: { id: 100, name: "all", path: "./lib/appenders/all.js", absolute_path: __filename, check: true } },
10
+ { props: { id: 101, name: "func_all", path: "./lib/appenders/func_all.js", absolute_path: __filename, check: true } },
11
+ { props: { id: 102, name: "top_one", path: "./lib/appenders/top_one.js", absolute_path: __filename, check: true } },
12
+ { props: { id: 103, name: "bottom_one", path: "./lib/appenders/bottom_one.js", absolute_path: __filename, check: true } },
13
+ { props: { id: 104, name: "sync_all", path: "./lib/appenders/sync_all.js", absolute_path: __filename, check: true } },
14
+ { props: { id: 105, name: "status", path: "./lib/appenders/status.js", absolute_path: __filename, check: true } },
15
+ { props: { id: 106, name: "name", path: "./lib/appenders/name.js", absolute_path: __filename, check: true } },
16
+ { props: { id: 107, name: "version", path: "./lib/appenders/version.js", absolute_path: __filename, check: true } }
17
+ ]
15
18
 
16
19
  class QueueObj {
17
-
18
20
  constructor() {
19
21
  try {
20
22
  var t = this
@@ -26,6 +28,7 @@ class QueueObj {
26
28
  t.bottom_one = null
27
29
  t.array = null
28
30
  t.status = null
31
+ t.name = null
29
32
  t.version = null
30
33
  t.stats = false
31
34
  t.sync_all = null
@@ -34,14 +37,15 @@ class QueueObj {
34
37
  t.objs = []
35
38
  t.resolve = null
36
39
  t.reject = null
40
+ t.qRequire = new file_queue().init({ input_data: file_requre_data })
37
41
 
38
- t.load = t.load.bind(this)
39
- t.process = t.process.bind(this)
40
- t.getParent = t.getParent.bind(this)
41
- t.getObjectToProcess = t.getObjectToProcess.bind(this)
42
- t.getObjectById = t.getObjectById.bind(this)
43
- t.getObjs = t.getObjs.bind(this)
44
- t.logMsg = t.logMsg.bind(this)
42
+ t.load = t.load.bind(t)
43
+ t.process = t.process.bind(t)
44
+ t.getParent = t.getParent.bind(t)
45
+ t.getObjectToProcess = t.getObjectToProcess.bind(t)
46
+ t.getObjectById = t.getObjectById.bind(t)
47
+ t.getObjs = t.getObjs.bind(t)
48
+ t.logMsg = t.logMsg.bind(t)
45
49
  return t
46
50
  } catch (e) {
47
51
  e.message = "queueObj app.js constructor error: " + e.message
@@ -117,44 +121,21 @@ class QueueObj {
117
121
 
118
122
  load(props) {
119
123
  try {
120
- var t = this
124
+ var t = this, file_obj, obj
121
125
  t.props = props
126
+ file_obj = t.qRequire.getFileObject()
127
+
122
128
  t.stats = (typeof props.stats != 'undefined') ? props.stats : false;
123
129
  if (typeof props != `undefined`) {
124
130
  if (typeof props.appender != `undefined` &&
125
131
  typeof props.appender == 'string') {
126
132
  props.getParent = t.getParent
127
- switch (props.appender) {
128
- case 'all':
129
- t.all = new all(props)
130
- break
131
- case 'top_one':
132
- t.top_one = new top_one(props)
133
- break
134
- case 'bottom_one':
135
- t.bottom_one = new bottom_one(props)
136
- break
137
- case 'func_all':
138
- t.func_all = new func_all(props)
139
- break
140
- case 'array':
141
- t.array = new array(props)
142
- break
143
- case 'status':
144
- t.status = new status(props)
145
- break
146
- case 'version':
147
- t.version = new version(props)
148
- break
149
- case 'sync_all':
150
- t.sync_all = new sync_all(props)
151
- break
152
- case 'name':
153
- t.name = new name(props)
154
- break
155
- default:
156
- throw new Error(`appender(${props.appender}) not found`)
157
- }
133
+ file_obj.map((jsObj, i) => {
134
+ if (jsObj.name == props.appender) {
135
+ obj = require(jsObj.path)
136
+ eval(`t.${jsObj.name} = new obj(props)`)
137
+ }
138
+ })
158
139
  }
159
140
  return t
160
141
  }
@@ -2,7 +2,6 @@
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
3
  * @since 2017-10-01
4
4
  * lib/appenders/base.js
5
- * jrm debug 8/4 https://www.npmjs.com/package/temporary-stamp
6
5
  */
7
6
 
8
7
  var colors = require('colors')
@@ -147,11 +146,10 @@ exports = module.exports = class base {
147
146
  let t = this
148
147
  t.dt_end = new Date();
149
148
  let ret_str = '', st = t.dt_start, ed = t.dt_end, ml = t.dt_end - t.dt_start
150
- // ret_str += JSON.stringify(t.results_array)
151
149
  if (t.getParent().getStats()) {
152
150
  ret_str += `start (${st}) end(${ed}) milliseconds(${ml})`
153
151
  }
154
- return ret_str //jrm debug
152
+ return ret_str
155
153
  }
156
154
 
157
155
  process_all = () => {
package/package.json CHANGED
@@ -2,13 +2,15 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "11.0.2",
6
- "bundleDependencies": false,
5
+ "version": "12.0.2",
6
+ "bundleDependencies": [],
7
7
  "dependencies": {
8
8
  "chai": "^4.3.7",
9
- "node-console-colors": "^1.1.4",
10
9
  "diffler": "^2.0.4",
11
- "mocha": "^10.2.0"
10
+ "file-obj-queue": "^1.0.1",
11
+ "mocha": "^10.2.0",
12
+ "node-console-colors": "^1.1.4",
13
+ "queuejson": "^8.4.0"
12
14
  },
13
15
  "scripts": {
14
16
  "start": "node app.ts",
package/test/package.js CHANGED
@@ -6,13 +6,15 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "11.0.2",
10
- "bundleDependencies": false,
9
+ "version": "12.0.2",
10
+ "bundleDependencies": [],
11
11
  "dependencies": {
12
12
  "chai": "^4.3.7",
13
- "node-console-colors": "^1.1.4",
14
13
  "diffler": "^2.0.4",
15
- "mocha": "^10.2.0"
14
+ "file-obj-queue": "^1.0.1",
15
+ "mocha": "^10.2.0",
16
+ "node-console-colors": "^1.1.4",
17
+ "queuejson": "^8.4.0"
16
18
  },
17
19
  "scripts": {
18
20
  "start": "node app.ts",
@@ -32,8 +32,8 @@ class test2 {
32
32
 
33
33
  process(callback) {
34
34
  let t = this, msg = `some kinda problem here test2 id(${this.id}) name(${this.name})`
35
- callback({error: {msg: msg}}) //this will show errors
36
- // callback({success: {msg: `processing test2 id(${this.id}) name(${this.name})`}}) //this will show no errors
35
+ // callback({error: {msg: msg}}) //this will show errors
36
+ callback({success: {msg: `processing test2 id(${this.id}) name(${this.name})`}}) //this will show no errors
37
37
  }
38
38
 
39
39
  ping() {
@@ -69,7 +69,7 @@ class test4 {
69
69
  }
70
70
  }
71
71
 
72
- let qObj = new queue(), props = { appender: 'status', stats: true }
72
+ let qObj = new queue(), props = { appender: 'name', stats: true }
73
73
 
74
74
  qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(new test4())
75
75