file-obj-queue 3.0.0 → 3.0.1

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.
Files changed (50) hide show
  1. package/.github/workflows/{github-actions.yml → github-actions-demo.yml} +1 -1
  2. package/.github/workflows/node.js.yml +0 -1
  3. package/LICENSE +1 -1
  4. package/README.md +7 -132
  5. package/app.js +40 -155
  6. package/base_queue/app.js +146 -0
  7. package/base_queue/appenders/base.js +77 -0
  8. package/base_queue/appenders/json_all.js +70 -0
  9. package/package.json +7 -28
  10. package/test/app.js +1 -5
  11. package/test/package.js +7 -28
  12. package/tests/appenders/all.js +1 -1
  13. package/tests/appenders/base.js +1 -1
  14. package/tests/appenders/bottom_one.js +1 -1
  15. package/tests/appenders/func_all.js +1 -1
  16. package/tests/appenders/sync.js +1 -1
  17. package/tests/appenders/sync_all.js +1 -1
  18. package/tests/appenders/top_one.js +1 -1
  19. package/tests/appenders/version.js +1 -1
  20. package/tests/files.js +32 -50
  21. package/lib/appenders/all.js +0 -17
  22. package/lib/appenders/base.js +0 -189
  23. package/lib/appenders/bottom_one.js +0 -17
  24. package/lib/appenders/func_all.js +0 -17
  25. package/lib/appenders/name.js +0 -17
  26. package/lib/appenders/status.js +0 -17
  27. package/lib/appenders/sync.js +0 -17
  28. package/lib/appenders/sync_all.js +0 -17
  29. package/lib/appenders/top_one.js +0 -17
  30. package/lib/appenders/version.js +0 -17
  31. package/tests/all.js +0 -85
  32. package/tests/bottom_one.js +0 -86
  33. package/tests/func_all.js +0 -94
  34. package/tests/json_all.js +0 -107
  35. package/tests/json_bottom_one.js +0 -108
  36. package/tests/json_func_all.js +0 -109
  37. package/tests/json_name_matching.js +0 -109
  38. package/tests/json_name_non_matching.js +0 -109
  39. package/tests/json_status_matching.js +0 -110
  40. package/tests/json_status_non_matching.js +0 -110
  41. package/tests/json_top_one.js +0 -108
  42. package/tests/json_version_matching.js +0 -110
  43. package/tests/json_version_non_matching.js +0 -110
  44. package/tests/name_matching.js +0 -90
  45. package/tests/name_non_matching.js +0 -90
  46. package/tests/status_matching.js +0 -90
  47. package/tests/status_non_matching.js +0 -90
  48. package/tests/top_one.js +0 -85
  49. package/tests/version_matching.js +0 -90
  50. package/tests/version_non_matching.js +0 -90
@@ -15,4 +15,4 @@ jobs:
15
15
  - name: List files in the repository
16
16
  run: |
17
17
  ls ${{ github.workspace }}
18
- - run: echo "🍏 This job's status is ${{ job.status }}."
18
+ - run: echo "🍏 This job's status is ${{ job.status }}."
@@ -79,4 +79,3 @@ jobs:
79
79
 
80
80
  - run: npm run build --if-present
81
81
  - run: npm run test_files
82
- - run: npm run test_all
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 jman717
3
+ Copyright (c) 2023 jman717
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,30 +1,11 @@
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
- [![CodeQL](https://github.com/jman717/QueueObj/actions/workflows/github-actions.yml/badge.svg)](https://github.com/jman717/QueueObj/blob/main/.github/workflows/github-actions.yml)
4
- [![Node.js CI](https://github.com/jman717/QueueObj/actions/workflows/node.js.yml/badge.svg)](https://github.com/jman717/QueueObj/actions/workflows/node.js.yml)
1
+ [![npm Package](https://img.shields.io/npm/v/file-obj-queue.svg)](https://www.npmjs.org/package/file-obj-queue)
2
+ [![License](https://img.shields.io/npm/l/file-obj-queue.svg)](https://github.com/jman717/file-obj-queue/blob/master/LICENSE)
3
+ [![CodeQL](https://github.com/jman717/file-obj-queue/actions/workflows/github-actions-demo.yml/badge.svg)](https://github.com/jman717/file-obj-queue/actions/workflows/github-actions-demo.yml)
4
+ [![Node.js CI](https://github.com/jman717/file-obj-queue/actions/workflows/node.js.yml/badge.svg)](https://github.com/jman717/file-obj-queue/actions/workflows/node.js.yml)
5
5
 
6
- [![NPM](https://nodei.co/npm/queueobj.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/queueobj/)
6
+ [![NPM](https://nodei.co/npm/file-obj-queue.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/file-obj-queue/)
7
7
 
8
- Queue javascript objects dynamically then process the queue according to the appender. All appenders are handled synchronously.
9
-
10
- Included tag appenders:
11
-
12
- * files - See if inputed files exists.
13
- * all - process all added objects.
14
- * top_one - process only the object in the 0(zero) position of the process array.
15
- * bottom_one - process only the object in the last position of the process array.
16
- * func_all - process custom function names in created objects. Custom processing names can be used in any appender, this is just one example.
17
- * status - queue and process all objects by status.
18
- * name - queue and process all objects by name.
19
- * version - queue and process all objects by version.
20
-
21
- * json_all - process a class object per json input array variables.
22
- * json_top_one - process a class object per the first json input array variable.
23
- * json_bottom_one - process a class object per the last json input array variable.
24
- * json_func_all - process custom function names in created objects. Custom processing names can be used in any json appender, this is just one example.
25
- * json_status - queue and process all objects by status.
26
- * json_name - queue and process all objects by name.
27
- * json_version - queue and process all objects by version.
8
+ An array of objects containing file path information. One use is for dynamically import require modules.
28
9
 
29
10
  Mocha Test
30
11
  ---------
@@ -36,111 +17,5 @@ General Setup Test
36
17
  ---------
37
18
  ```
38
19
  npm run test_files
39
- npm run test_all
40
- npm run test_top_one
41
- npm run test_bottom_one
42
- npm run test_func_all
43
- npm run test_status_matching
44
- npm run test_status_non_matching
45
- npm run test_name_matching
46
- npm run test_name_non_matching
47
- npm run test_version_matching
48
- npm run test_version_non_matching
49
- npm run test_json_all
50
- npm run test_json_top_one
51
- npm run test_json_bottom_one
52
- npm run test_json_func_all
53
- npm run test_json_status_matching
54
- npm run test_json_status_non_matching
55
- npm run test_json_version_matching
56
- npm run test_json_version_non_matching
57
- npm run test_json_name_matching
58
- npm run test_json_name_non_matching
59
-
60
- ```
61
-
62
- Usage
63
- ---------
64
- ```js
65
-
66
- var queue = require("queueobj");
67
-
68
- var tst1 = class test1 {
69
- constructor(props) {
70
- let t = this, fname = "test_all.test1.constructor"
71
- t.log = props.log
72
- t.id = props.id
73
- }
74
-
75
- process(callback) {
76
- let t = this, fname = "test_all.test1.process"
77
- t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
78
- callback({ success: { msg: `processing all test1` } })
79
- }
80
- }
81
-
82
- var tst2 = class test2 {
83
- constructor(props) {
84
- let t = this, fname = "test_all.test2.constructor"
85
- t.log = props.log
86
- t.id = props.id
87
- }
88
-
89
- process(callback) {
90
- let t = this, fname = "test_all.test2.process"
91
- t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
92
- setTimeout(() => {
93
- callback({ success: { msg: `processing all test2` } })
94
- }, 4000)
95
- }
96
- }
97
-
98
- var tst3 = class test3 {
99
- constructor(props) {
100
- let t = this, fname = "test_all.test3.constructor"
101
- t.log = props.log
102
- t.id = props.id
103
- }
104
-
105
- process(callback) {
106
- let t = this, fname = "test_all.test3.process"
107
- t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
108
- // callback({success: { msg: `processing all test3` }})
109
- callback({ error: { msg: `there is some problem thrown here on test3` } })
110
- }
111
- }
112
-
113
- var tst4 = class test4 {
114
- constructor(props) {
115
- let t = this, fname = "test_all.test4.constructor"
116
- t.log = props.log
117
- t.id = props.id
118
-
119
- }
120
-
121
- process(callback) {
122
- let t = this, fname = "test_all.test4.process"
123
- t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
124
- callback({ success: { msg: `processing all test4` } })
125
- }
126
- }
127
-
128
- var qObj = new queue()
129
-
130
- qObj.init().process({
131
- appender: "all",
132
- exclude_logMsg: ["debug"], /* example ["debug", "info"] */
133
- process_objects: [tst1, tst2, tst3, tst4]
134
- }).then((success) => {
135
- qObj.logMsg({ msg: `test success: {msg: "all objects processed with no errors"}`.success.italic.bold, type: "success" })
136
- }, (error) => {
137
- if (typeof error == "string") {
138
- qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
139
- } else {
140
- let add_s = (error.error_count > 1) ? 's' : ''
141
- qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
142
- }
143
- })
144
-
145
- ```
146
20
 
21
+ ```
package/app.js CHANGED
@@ -3,185 +3,70 @@
3
3
  * Main processing app
4
4
  */
5
5
 
6
- let base_queue = require("base-queue"),
7
- log_queue = require("log-queue"),
8
- fs = require('fs'),
9
- validPath = require('valid-path')
10
-
11
- const { memoryUsage } = require('process')
12
-
13
- var log_data = [
14
- { props: { id: 100, name: "console_basic", absolute_path: __filename, check: true } }
15
- ]
16
-
17
-
18
- var log_object = class log_obj {
19
- constructor(props) {
20
- let t = this
21
- t.id = props.id
22
- t.log = props.log
23
- t.name = props.name
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.status = 'init'
27
- t.errors = false
28
- t.error_msg = 'none'
29
-
30
- t.process = t.process.bind(t)
31
- t.do_checks = t.do_checks.bind(t)
32
-
33
- if (props.check) {
34
- t.do_checks()
35
- }
36
-
37
- return t
38
- }
39
-
40
- do_checks() {
41
- let t = this, path_to_check,
42
- last_item = t.absolute_path.split("\\").pop(),
43
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('../')
44
-
45
- check_file = check_file.replace(/\\/g, "/");
46
- path_to_check = validPath(t.path);
47
-
48
- if (!path_to_check.valid) {
49
- t.errors = true
50
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
51
- }
52
-
53
- // check_path.map((dat, i) => {
54
- // if (/^[a-zA-Z._]+$/.test(dat)) {
55
- // if (dat != '.' || dat != '..')
56
- // check_file += dat + '/'
57
- // }
58
- // })
59
- // check_file = check_file.slice(0, -1)
60
- check_file += check_path[1]
61
- check_file += `${t.name}.js`
62
- try {
63
- if (!fs.existsSync(check_file)) {
64
- t.errors = true
65
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
66
- }
67
- } catch (e) {
68
- e.message = "file_obj do_checks error: " + e.message
69
- throw (e)
70
- }
71
- }
72
-
73
- process(callback) {
74
- let t = this
75
- if (t.errors)
76
- callback({ error: {msg: t.error_msg} })
77
- else {
78
- callback({ success: {msg: `id = ${t.id} name(${t.name}) success`} })
79
- }
80
- }
81
- }
82
-
83
- exports = module.exports = class QueueObj {
6
+ let colors = require('colors'),
7
+ base_queue = require("./base_queue/app")
8
+
9
+ colors.setTheme({
10
+ silly: 'rainbow',
11
+ input: 'grey',
12
+ verbose: 'cyan',
13
+ prompt: 'grey',
14
+ info: 'green',
15
+ data: 'grey',
16
+ help: 'cyan',
17
+ warn: 'yellow',
18
+ debug: 'blue',
19
+ error: 'red',
20
+ success: 'green'
21
+ });
22
+
23
+ exports = module.exports = class FilesQueue {
84
24
  constructor() {
85
- var t = this, fname = 'QueueObj.constructor'
86
25
  try {
87
- t.promise = null
88
- t.resolve = null
89
- t.reject = null
90
- t.promise_2q = null
91
- t.resolve_2q = null
92
- t.reject_2q = null
26
+ var t = this
27
+ t.app_resolve = null
28
+ t.app_reject = null
93
29
  t.successMsg = ''
94
- t.log_queue = null
95
30
 
96
31
  t.logMsg = t.logMsg.bind(t)
97
- t.init = t.init.bind(t)
98
32
  t.process = t.process.bind(t)
99
33
  t.getFileObject = t.getFileObject.bind(t)
100
34
 
101
- // t.logMsg(`QueueObj.constructor`.debug)
102
-
103
- return t
104
- } catch (e) {
105
- e.message = `QueueObj app.js constructor error: ${e.message}`.error
106
- console.log(e.message)
107
- }
108
- }
35
+ t.logMsg(`FilesQueue.constructor`.debug)
109
36
 
110
- init() {
111
- var t = this, fname = `QueueObj.init`
112
- try {
113
- t.promise = new Promise((resolve, reject) => {
114
- t.resolve = resolve
115
- t.reject = reject
116
- })
117
- t.promise_2q= new Promise((resolve, reject) => {
118
- t.resolve_2q = resolve
119
- t.reject_2q = reject
120
- })
121
37
  return t
122
38
  } catch (e) {
123
- t.logMsg({ msg: `${fname} error: (${e.message})`.error, type: 'error' })
124
- // e.message = `QueueObj app.js constructor error: ${e.message}`.error
125
- // console.log(e.message)
39
+ e.message = `FilesQueue app.js constructor error: ${e.message}`.error
40
+ throw (e)
126
41
  }
127
42
  }
128
43
 
129
44
  process(props = {}) {
130
- let t = this, fname = `app.process`
45
+ let t = this
131
46
 
132
- // if (typeof props.data_to_process_array == 'undefined')
133
- // t.reject('base_queue no props.data_to_process_array')
47
+ return new Promise((resolve, reject) => {
48
+ t.app_resolve = resolve
49
+ t.app_reject = reject
134
50
 
135
- if (typeof props.appender == 'undefined')
136
- t.reject('base_queue no props.appender')
51
+ if (typeof props.data_to_process_array == 'undefined')
52
+ t.app_reject('base_queue no props.data_to_process_array')
137
53
 
138
- if (typeof props.process_objects == 'undefined')
139
- t.reject(`props.process_objects not defined`)
54
+ if (typeof props.appender == 'undefined')
55
+ t.app_reject('base_queue no props.appender')
140
56
 
141
- try {
142
- t.log_queue = new log_queue({
143
- parent: t,
144
- relative_path: "../base_queue/appenders/log/",
145
- exclude_logMsg: props.exclude_logMsg,
146
- resolve: t.resolve,
147
- reject: t.reject
148
- }).init({
149
- appender: "console_basic",
150
- process_objects: [log_object],
151
- data_to_process_array: log_data
152
- })
153
- t.base_queue = new base_queue({
154
- parent: t,
155
- relative_path: "./appenders/",
156
- logMsg: t.logMsg,
157
- resolve: t.resolve_2q,
158
- reject: t.reject_2q
159
- }).load(props).process()
160
- return t.promise_2q
161
- } catch (e) {
162
- console.log(`${fname} error: (${e.message})`)
163
- }
57
+ if (typeof props.process_objects == 'undefined')
58
+ t.app_reject(`props.process_objects not defined`)
59
+
60
+ props.parent = t
61
+ t.base_queue = new base_queue().load(props).process()
62
+ })
164
63
  }
165
64
 
166
65
  getFileObject() {
167
66
  return this.qJson.get_class_obj_array()
168
67
  }
169
68
 
170
- logMsg(props = { msg: '', type: '' }) {
171
- let t = this, fname = "QueueObj.logMsg"
172
- try {
173
- if (typeof props.msg == "undefined")
174
- throw new Error(`no msg property in (${JSON.stringify(props)}) `)
175
- if (typeof props.type == "undefined")
176
- throw new Error(`no type property in (${JSON.stringify(props)}) `)
177
- if (t.log_queue != null && typeof t.log_queue.logMsg != 'undefined') {
178
- t.log_queue.logMsg(props)
179
- } else {
180
- throw new Error(`t.log_queue does not exist`)
181
- }
182
- } catch (e) {
183
- e.message = `${fname} error: ${e.message})`
184
- t.reject(e.message)
185
- }
69
+ logMsg(msg, props = {}) {
70
+ console.log(msg)
186
71
  }
187
72
  }
@@ -0,0 +1,146 @@
1
+
2
+ /*
3
+ * @author Jim Manton: jrman@risebroadband.net
4
+ * @since 2023-02-02
5
+ * apps.js
6
+ */
7
+
8
+ let cc = require("colors"),
9
+ file_requre_data = [
10
+ { props: { id: 100, name: "all", path: "./lib/appenders/all.js", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ cc.setTheme({
14
+ silly: 'rainbow',
15
+ input: 'grey',
16
+ verbose: 'cyan',
17
+ prompt: 'grey',
18
+ info: 'green',
19
+ data: 'grey',
20
+ help: 'cyan',
21
+ warn: 'yellow',
22
+ debug: 'blue',
23
+ error: 'red'
24
+ });
25
+
26
+
27
+ class process_object {
28
+ constructor(props) {
29
+ let t = this
30
+ t.parent = props.parent
31
+ t.status = 'process'
32
+ t.objs = t.parent.getParent().getObjs()
33
+ }
34
+
35
+ process() {
36
+ let t = this
37
+ }
38
+
39
+ continueProcessing() {
40
+ let t = this
41
+ }
42
+
43
+ getStatus() {
44
+ return this.status
45
+ }
46
+
47
+ setStatus(v) {
48
+ this.status = v
49
+ }
50
+ }
51
+
52
+ exports = module.exports = class BaseQueue {
53
+ constructor(props = {}) {
54
+ let t = this, fname = `BaseQueue app constructor`
55
+ try {
56
+ t.parent = null
57
+ t.appenders_dir = './appenders/'
58
+ t.appender = null
59
+
60
+ t.logMsg = t.logMsg.bind(t)
61
+ t.init = t.init.bind(t)
62
+ t.load = t.load.bind(t)
63
+ t.process = t.process.bind(t)
64
+ t.set_base_promise = t.set_base_promise.bind(t)
65
+ t.base_promise = null
66
+ t.base_resolve = null
67
+ t.base_reject = null
68
+
69
+ t.set_base_promise()
70
+
71
+ return t
72
+ } catch (e) {
73
+ t.logMsg(`${fname}: ${e.message}`.error)
74
+ }
75
+ }
76
+
77
+ set_base_promise() {
78
+ let t = this, fname = `BaseQueue set_base_promise`
79
+
80
+ t.base_promise = new Promise((resolve, reject) => {
81
+ t.base_resolve = resolve
82
+ t.base_reject = reject
83
+ })
84
+
85
+ t.base_promise.then(function (success) {
86
+ t.parent.app_resolve(success)
87
+ }).catch(function (err) {
88
+ t.parent.app_reject(err)
89
+ })
90
+
91
+ }
92
+
93
+ init(props = {}) {
94
+ let t = this, fname = `BaseQueue init`
95
+ }
96
+
97
+ load(props = {}) {
98
+ let t = this, fname = `BaseQueue load`, a, app, req
99
+
100
+ if (typeof props.parent == 'undefined')
101
+ t.base_reject(`${fname}: props.parent not defined`)
102
+
103
+ t.parent = props.parent
104
+ props.parent = t
105
+ app = props.appender
106
+ a = t.appenders_dir + app + '.js'
107
+ req = require(a)
108
+ t.parent.logMsg(`${fname} loading appender(${a})`.debug)
109
+ t.appender = new req(props)
110
+ return t
111
+ }
112
+
113
+ process() {
114
+ let t = this, fname = `BaseQueue process`, res, error_count = 0
115
+ try {
116
+ t.logMsg(`${fname}`.debug)
117
+
118
+ res = t.appender.init().process().get_results_array()
119
+ res.map((json, i) => {
120
+ if (typeof json.success != "undefined")
121
+ t.logMsg(`${JSON.stringify(json)}`.success)
122
+ if (typeof json.error != "undefined") {
123
+ t.logMsg(`${JSON.stringify(json)}`.error)
124
+ error_count++
125
+ }
126
+ })
127
+ if (error_count) {
128
+ res.error_count = error_count
129
+ t.base_reject(res)
130
+ } else
131
+ t.base_resolve(res)
132
+ } catch (e) {
133
+ t.base_reject(`${fname}: ${e.message}.`)
134
+ }
135
+ }
136
+
137
+ logMsg(msg, props = {}) {
138
+ let t = this
139
+ try {
140
+ console.log(msg)
141
+ return t
142
+ } catch (e) {
143
+ t.base_reject(`BaseQueue log: ${e.message} for message (${msg})`)
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * @author Jim Manton: jrman@risebroadband.net
3
+ * @since 2023-02-03
4
+ * base.js
5
+ */
6
+
7
+ exports = module.exports = class base {
8
+ constructor(props) {
9
+ let t = this, fname = `base appenders constructor`
10
+ try {
11
+ t.parent = props.parent
12
+ t.parent.logMsg(`${fname}`.debug)
13
+ t.class_obj_array = []
14
+ t.data_to_process_array = []
15
+ t.objects_to_process = []
16
+ t.results_array = []
17
+ t.base_name_appender = ''
18
+
19
+ if (typeof props.data_to_process_array == 'undefined')
20
+ throw new Error(`props.data_to_process_array not defined`)
21
+
22
+ if (typeof props.process_objects == 'undefined')
23
+ throw new Error(`props.process_objects not defined`)
24
+
25
+ if (typeof props.appender == 'undefined')
26
+ throw new Error(`appender not defined)`)
27
+
28
+ t.base_name_appender = props.appender
29
+ t.data_to_process_array = props.data_to_process_array
30
+ t.objects_to_process = props.process_objects
31
+
32
+ t.init = t.init.bind(t)
33
+ t.get_objects_to_process = t.get_objects_to_process.bind(t)
34
+ t.get_data_to_process_array = t.get_data_to_process_array.bind(t)
35
+ t.process = t.process.bind(t)
36
+ t.get_results_array = t.get_results_array.bind(t)
37
+
38
+ return t
39
+ } catch (e) {
40
+ t.parent.base_reject(`${fname} error: ${e.message})`)
41
+ }
42
+ }
43
+
44
+ process (props = {}) {
45
+ var t = this, fname = `base.process`
46
+ try {
47
+ t.parent.logMsg(`${fname}`.debug)
48
+
49
+ return t
50
+ } catch (e) {
51
+ t.parent.base_reject(`${fname} error: ${e.message})`)
52
+ }
53
+ }
54
+
55
+ get_results_array () {
56
+ return this.results_array
57
+ }
58
+
59
+ get_data_to_process_array () {
60
+ return this.data_to_process_array
61
+ }
62
+
63
+ get_objects_to_process () {
64
+ return this.objects_to_process
65
+ }
66
+
67
+ init (props = {}) {
68
+ var t = this, fname = `base.init`
69
+ try {
70
+
71
+ t.parent.logMsg(`${fname}`.debug)
72
+ return t
73
+ } catch (e) {
74
+ t.parent.base_reject(`${fname} error: ${e.message})`)
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,70 @@
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 json_all extends base {
10
+ constructor(props) {
11
+ super(props)
12
+ var t = this, fname = 'json_all.constructor'
13
+ try {
14
+ t.aname = 'json_all'
15
+ t.main_process_objects = []
16
+
17
+ if (t.base_name_appender != t.aname)
18
+ throw new Error(`(${t.base_name_appender}) does not equal the appender name (${t.aname}))`)
19
+
20
+ t.parent.logMsg(`${fname}`.debug)
21
+
22
+ t.init = t.init.bind(t)
23
+ t.process = t.process.bind(t)
24
+
25
+ return t
26
+ } catch (e) {
27
+ t.parent.base_reject(`${fname} error: ${e.message})`)
28
+ }
29
+ }
30
+
31
+ init (props = {}) {
32
+ var t = this, fname = `json_all.init`, gotp, gdtpa, obj
33
+ try {
34
+ t.parent.logMsg(`${fname}`.debug)
35
+
36
+ if (typeof t.get_objects_to_process()[0] == "undefined")
37
+ throw new Error(`get_objects_to_process[0] has no data`)
38
+
39
+ t.get_data_to_process_array().map((dat, i)=>{
40
+ dat.props.log = t.parent.logMsg
41
+ obj = t.get_objects_to_process()[0]
42
+ t.main_process_objects.push(new obj(dat.props))
43
+ })
44
+
45
+ super.init(props)
46
+ return t
47
+ } catch (e) {
48
+ t.parent.base_reject(`${fname} error: ${e.message})`)
49
+ }
50
+ }
51
+
52
+ process (props = {}) {
53
+ var t = this, fname = `json_all.process`
54
+ try {
55
+ t.parent.logMsg(`${fname} length(${t.main_process_objects.length})`.debug)
56
+
57
+ t.main_process_objects.map((obj, i)=>{
58
+ obj.process((res)=>{
59
+ // t.parent.logMsg(`${fname}${JSON.stringify(res)})`.debug)
60
+ t.results_array.push(res)
61
+ })
62
+ })
63
+
64
+ super.process(props)
65
+ return t
66
+ } catch (e) {
67
+ t.parent.base_reject(`${fname} error: ${e.message})`)
68
+ }
69
+ }
70
+ }