base-queue 0.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.
- package/.github/workflows/actions.yml +18 -0
- package/.github/workflows/node.js.yml +80 -0
- package/README.md +22 -0
- package/app.js +109 -0
- package/appenders/all.js +69 -0
- package/appenders/base.js +149 -0
- package/appenders/bottom_one.js +68 -0
- package/appenders/common_code.js +56 -0
- package/appenders/func_all.js +83 -0
- package/appenders/json_all.js +79 -0
- package/appenders/json_bottom_one.js +79 -0
- package/appenders/json_func_all.js +79 -0
- package/appenders/json_name.js +84 -0
- package/appenders/json_status.js +86 -0
- package/appenders/json_top_one.js +79 -0
- package/appenders/json_version.js +86 -0
- package/appenders/log/console_basic.js +73 -0
- package/appenders/name.js +77 -0
- package/appenders/status.js +77 -0
- package/appenders/top_one.js +67 -0
- package/appenders/version.js +85 -0
- package/package.json +44 -0
- package/test/app.js +29 -0
- package/test/package.js +60 -0
- package/tests/base.js +101 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: GitHub Actions
|
|
2
|
+
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
|
3
|
+
on: [push]
|
|
4
|
+
jobs:
|
|
5
|
+
Explore-GitHub-Actions:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
steps:
|
|
8
|
+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
|
9
|
+
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
|
10
|
+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
|
11
|
+
- name: Check out repository code
|
|
12
|
+
uses: actions/checkout@v3
|
|
13
|
+
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
|
14
|
+
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
|
15
|
+
- name: List files in the repository
|
|
16
|
+
run: |
|
|
17
|
+
ls ${{ github.workspace }}
|
|
18
|
+
- run: echo "🍏 This job's status is ${{ job.status }}."
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "master" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "master" ]
|
|
11
|
+
workflow_dispatch: {}
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
|
|
18
|
+
defaults:
|
|
19
|
+
run:
|
|
20
|
+
shell: bash
|
|
21
|
+
|
|
22
|
+
strategy:
|
|
23
|
+
matrix:
|
|
24
|
+
os: [ubuntu-latest, windows-latest]
|
|
25
|
+
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x]
|
|
26
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
27
|
+
include:
|
|
28
|
+
- node-version: 8.x
|
|
29
|
+
npm-i: "eslint@6.x eslint-config-airbnb-base@14.x eslint-config-prettier@6.x eslint-plugin-prettier@3.x fs-extra@8.x nyc@14.x tap@14.x"
|
|
30
|
+
|
|
31
|
+
- node-version: 10.x
|
|
32
|
+
npm-i: "eslint@7.x fs-extra@9.x nyc@14.x tap@14.x"
|
|
33
|
+
|
|
34
|
+
- node-version: 12.x
|
|
35
|
+
npm-i: "nyc@14.x tap@14.x"
|
|
36
|
+
|
|
37
|
+
- node-version: 14.x
|
|
38
|
+
npm-i: "nyc@14.x tap@14.x"
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v3
|
|
42
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
43
|
+
uses: actions/setup-node@v3
|
|
44
|
+
with:
|
|
45
|
+
node-version: ${{ matrix.node-version }}
|
|
46
|
+
cache: 'npm'
|
|
47
|
+
|
|
48
|
+
- name: Configure npm
|
|
49
|
+
run: npm config set loglevel error
|
|
50
|
+
|
|
51
|
+
- name: Get npm version
|
|
52
|
+
id: npm-version
|
|
53
|
+
run: |
|
|
54
|
+
npm -v
|
|
55
|
+
npmMajorVer=$(npm -v | cut -d. -f1)
|
|
56
|
+
echo "major=$npmMajorVer" >> $GITHUB_OUTPUT
|
|
57
|
+
- name: Disable prettier on older Node.js (8.x, 10.x, 12.x)
|
|
58
|
+
run: |
|
|
59
|
+
sed -i '/"prettier": "prettier/d' package.json
|
|
60
|
+
if: contains(fromJson('["8.x", "10.x", "12.x"]'), matrix.node-version)
|
|
61
|
+
|
|
62
|
+
- name: Install downgraded modules ${{ matrix.npm-i }}
|
|
63
|
+
run: |
|
|
64
|
+
npm install --save-dev ${{ matrix.npm-i }}
|
|
65
|
+
if [ ${{ steps.npm-version.outputs.major }} -le 5 ]; then
|
|
66
|
+
npm install
|
|
67
|
+
fi
|
|
68
|
+
if: matrix.npm-i != ''
|
|
69
|
+
|
|
70
|
+
- run: npm install
|
|
71
|
+
if: matrix.npm-i == '' && steps.npm-version.outputs.major <= 5
|
|
72
|
+
|
|
73
|
+
- run: npm ci
|
|
74
|
+
if: matrix.npm-i == '' && steps.npm-version.outputs.major > 5
|
|
75
|
+
|
|
76
|
+
- name: List dependencies
|
|
77
|
+
run: npm ls --depth=0 --dev && npm ls --depth=0 --prod
|
|
78
|
+
|
|
79
|
+
- run: npm run build --if-present
|
|
80
|
+
- run: npm run test_base
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
[](https://www.npmjs.org/package/base-queue)
|
|
3
|
+
[](https://github.com/jman717/log/blob/master/LICENSE)
|
|
4
|
+
[](https://github.com/jman717/log/actions/workflows/actions.yml)
|
|
5
|
+
[](https://github.com/jman717/log/actions/workflows/node.js.yml)
|
|
6
|
+
|
|
7
|
+
[](https://nodei.co/npm/base-queue/)
|
|
8
|
+
|
|
9
|
+
Base appenders for various queueing processes.
|
|
10
|
+
|
|
11
|
+
Mocha Test
|
|
12
|
+
---------
|
|
13
|
+
```
|
|
14
|
+
npm test
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
General Setup Test
|
|
18
|
+
---------
|
|
19
|
+
```
|
|
20
|
+
npm run test_base
|
|
21
|
+
|
|
22
|
+
```
|
package/app.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
4
|
+
* @since 2023-02-02
|
|
5
|
+
* apps.js
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
exports = module.exports = class BaseQueue {
|
|
9
|
+
constructor(props = {}) {
|
|
10
|
+
let t = this, fname = `BaseQueue.constructor`
|
|
11
|
+
try {
|
|
12
|
+
t.appender = null
|
|
13
|
+
t.relative_path = props.relative_path
|
|
14
|
+
|
|
15
|
+
t.init = t.init.bind(t)
|
|
16
|
+
t.load = t.load.bind(t)
|
|
17
|
+
t.process = t.process.bind(t)
|
|
18
|
+
t.process_count = 0
|
|
19
|
+
t.reported = false
|
|
20
|
+
|
|
21
|
+
if (typeof props.parent == 'undefined') {
|
|
22
|
+
console.log(`${fname}: props.parent not defined`)
|
|
23
|
+
}
|
|
24
|
+
t.parent = props.parent
|
|
25
|
+
t.logMsg = props.logMsg
|
|
26
|
+
t.resolve = props.resolve
|
|
27
|
+
t.reject = props.reject
|
|
28
|
+
|
|
29
|
+
return t
|
|
30
|
+
} catch (e) {
|
|
31
|
+
e.message = `${fname} error: ${e.message}`
|
|
32
|
+
console.log(`${e.message}`.error)
|
|
33
|
+
throw (e)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
init(props = {}) {
|
|
38
|
+
let t = this, fname = `BaseQueue.init`
|
|
39
|
+
t.logMsg({ msg: `${fname}`.debug, type: 'debug' })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
load(props = {}) {
|
|
43
|
+
let t = this, fname = `BaseQueue.load`, a, app, req, msg
|
|
44
|
+
try {
|
|
45
|
+
props.parent = t
|
|
46
|
+
app = props.appender
|
|
47
|
+
a = t.relative_path + app + '.js'
|
|
48
|
+
try {
|
|
49
|
+
req = require(a)
|
|
50
|
+
} catch (e) {
|
|
51
|
+
msg = { "msg": `${fname} error: (${e.message})`.error, "type": "error" }
|
|
52
|
+
// t.logMsg(msg)
|
|
53
|
+
throw e
|
|
54
|
+
}
|
|
55
|
+
t.logMsg({ "msg": `${fname} loading appender(${a})`.debug, "type": "debug" })
|
|
56
|
+
props.relative_path = t.relative_path
|
|
57
|
+
t.appender = new req(props)
|
|
58
|
+
return t
|
|
59
|
+
} catch (e) {
|
|
60
|
+
e.message = `${fname} error: (${e.message})`
|
|
61
|
+
console.log(`${e.message}`.error)
|
|
62
|
+
throw e
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
process() {
|
|
67
|
+
let t = this, fname = `BaseQueue.process`, app, res, error_count = 0
|
|
68
|
+
try {
|
|
69
|
+
if (t.process_count > t.appender.main_process_objects.length)
|
|
70
|
+
t.appender.status = "done"
|
|
71
|
+
t.logMsg({ msg: `${fname} status(${t.appender.status}) process_count(${t.process_count}) process array size(${t.appender.main_process_objects.length})`.debug, type: 'debug' })
|
|
72
|
+
switch (t.appender.status) {
|
|
73
|
+
case "init":
|
|
74
|
+
t.appender.init()
|
|
75
|
+
break
|
|
76
|
+
case "process":
|
|
77
|
+
t.appender.process()
|
|
78
|
+
break
|
|
79
|
+
case "wait":
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
t.process()
|
|
82
|
+
}, 2000)
|
|
83
|
+
break
|
|
84
|
+
case "done":
|
|
85
|
+
if (!t.reported) {
|
|
86
|
+
t.reported = true
|
|
87
|
+
res = t.appender.get_results_array()
|
|
88
|
+
res.map((json, i) => {
|
|
89
|
+
if (typeof json.success != "undefined")
|
|
90
|
+
t.logMsg({ msg: `${JSON.stringify(json.success)}`.success, type: 'success' })
|
|
91
|
+
if (typeof json.error != "undefined") {
|
|
92
|
+
t.logMsg({ msg: `${JSON.stringify(json.error)}`.error, type: 'error' })
|
|
93
|
+
error_count++
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
if (error_count) {
|
|
97
|
+
res.error_count = error_count
|
|
98
|
+
t.reject(res)
|
|
99
|
+
} else {
|
|
100
|
+
t.resolve(res)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return t
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
t.reject(`${fname}: ${e.message}.`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
package/appenders/all.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2023-2-5
|
|
4
|
+
* all.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var base = require('./base.js')
|
|
8
|
+
|
|
9
|
+
exports = module.exports = class all extends base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props)
|
|
12
|
+
var t = this, fname = 'all.constructor'
|
|
13
|
+
try {
|
|
14
|
+
t.aname = 'all'
|
|
15
|
+
t.main_process_objects = []
|
|
16
|
+
|
|
17
|
+
if (t.appender != t.aname)
|
|
18
|
+
throw new Error(`(${t.appender}) does not equal the appender name (${t.aname}))`)
|
|
19
|
+
|
|
20
|
+
t.parent.logMsg({msg: `${fname} objects to process count(${t.get_objects_to_process().length})`.debug, type: "debug"})
|
|
21
|
+
|
|
22
|
+
t.init = t.init.bind(t)
|
|
23
|
+
t.process = t.process.bind(t)
|
|
24
|
+
|
|
25
|
+
return t
|
|
26
|
+
} catch (e) {
|
|
27
|
+
e.message = `${fname} error: ${e.message})`
|
|
28
|
+
throw e
|
|
29
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init(props = {}) {
|
|
34
|
+
var t = this, fname = `all.init`, obj
|
|
35
|
+
try {
|
|
36
|
+
t.parent.logMsg({msg: `${fname}`.debug, type: "debug"})
|
|
37
|
+
|
|
38
|
+
if (typeof t.get_objects_to_process()[0] == "undefined")
|
|
39
|
+
throw new Error(`get_objects_to_process[0] has no data`)
|
|
40
|
+
|
|
41
|
+
t.get_objects_to_process().map((dat, i) => {
|
|
42
|
+
dat = {props: {id: (i+1), log: t.parent.logMsg}}
|
|
43
|
+
obj = t.get_objects_to_process()[i]
|
|
44
|
+
t.main_process_objects.push(new obj(dat.props))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
super.init(props)
|
|
48
|
+
return t
|
|
49
|
+
} catch (e) {
|
|
50
|
+
e.message = `${fname} error: ${e.message})`
|
|
51
|
+
throw e
|
|
52
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
process(props = {}) {
|
|
57
|
+
var t = this, fname = `all.process`
|
|
58
|
+
try {
|
|
59
|
+
t.parent.logMsg({msg: `${fname}`.debug, type: "debug"})
|
|
60
|
+
|
|
61
|
+
super.process(props)
|
|
62
|
+
return t
|
|
63
|
+
} catch (e) {
|
|
64
|
+
e.message = `${fname} error: ${e.message})`
|
|
65
|
+
throw e
|
|
66
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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.constructor`
|
|
10
|
+
try {
|
|
11
|
+
t.parent = props.parent
|
|
12
|
+
t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
|
|
13
|
+
t.status = "init"
|
|
14
|
+
t.relative_path = ''
|
|
15
|
+
t.class_obj_array = []
|
|
16
|
+
t.data_to_process_array = []
|
|
17
|
+
t.objects_to_process = []
|
|
18
|
+
t.results_array = []
|
|
19
|
+
t.appender = ''
|
|
20
|
+
|
|
21
|
+
if (typeof props.relative_path == 'undefined')
|
|
22
|
+
throw new Error(`props.relative_path not defined`)
|
|
23
|
+
|
|
24
|
+
if (typeof props.process_objects == 'undefined')
|
|
25
|
+
throw new Error(`props.process_objects not defined`)
|
|
26
|
+
|
|
27
|
+
if (typeof props.appender == 'undefined')
|
|
28
|
+
throw new Error(`appender not defined)`)
|
|
29
|
+
|
|
30
|
+
t.appender = props.appender
|
|
31
|
+
t.data_to_process_array = props.data_to_process_array
|
|
32
|
+
t.objects_to_process = props.process_objects
|
|
33
|
+
t.include_status = props.include_status
|
|
34
|
+
t.exclude_status = props.exclude_status
|
|
35
|
+
t.include_version = props.include_version
|
|
36
|
+
t.exclude_version = props.exclude_version
|
|
37
|
+
t.include_names = props.include_names
|
|
38
|
+
t.exclude_names = props.exclude_names
|
|
39
|
+
t.relative_path = props.relative_path
|
|
40
|
+
|
|
41
|
+
t.init = t.init.bind(t)
|
|
42
|
+
t.get_objects_to_process = t.get_objects_to_process.bind(t)
|
|
43
|
+
t.get_include_status = t.get_include_status.bind(t)
|
|
44
|
+
t.get_exclude_status = t.get_exclude_status.bind(t)
|
|
45
|
+
t.get_include_names = t.get_include_names.bind(t)
|
|
46
|
+
t.get_exclude_names = t.get_exclude_names.bind(t)
|
|
47
|
+
t.get_include_version = t.get_include_version.bind(t)
|
|
48
|
+
t.get_exclude_version = t.get_exclude_version.bind(t)
|
|
49
|
+
t.get_data_to_process_array = t.get_data_to_process_array.bind(t)
|
|
50
|
+
t.process = t.process.bind(t)
|
|
51
|
+
t.get_results_array = t.get_results_array.bind(t)
|
|
52
|
+
|
|
53
|
+
return t
|
|
54
|
+
} catch (e) {
|
|
55
|
+
e.message = `${fname} error: ${e.message})`
|
|
56
|
+
throw e
|
|
57
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
process() {
|
|
62
|
+
var t = this, fname = `base.process`, pro, pro_process
|
|
63
|
+
try {
|
|
64
|
+
t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
|
|
65
|
+
|
|
66
|
+
if (t.parent.process_count > t.main_process_objects.length) {
|
|
67
|
+
t.status = "done"
|
|
68
|
+
t.parent.process()
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
if (t.status == "process") {
|
|
72
|
+
pro = t.main_process_objects[t.parent.process_count++]
|
|
73
|
+
if (typeof pro != "undefined") {
|
|
74
|
+
if (typeof pro.base_queue_process_function == "function")
|
|
75
|
+
pro_process = pro.base_queue_process_function
|
|
76
|
+
else
|
|
77
|
+
if (typeof pro.process == "function")
|
|
78
|
+
pro_process = pro.process
|
|
79
|
+
|
|
80
|
+
t.parent.logMsg({ msg: `${fname} status(${t.status}) count(${t.parent.process_count}) main objects(${t.main_process_objects.length})`.debug, type: "debug" })
|
|
81
|
+
|
|
82
|
+
pro_process((res) => {
|
|
83
|
+
t.results_array.push(res)
|
|
84
|
+
t.status = "process"
|
|
85
|
+
t.parent.process()
|
|
86
|
+
return
|
|
87
|
+
})
|
|
88
|
+
} else
|
|
89
|
+
t.status = "done"
|
|
90
|
+
}
|
|
91
|
+
if (t.status != "done")
|
|
92
|
+
t.status = "wait"
|
|
93
|
+
t.parent.process()
|
|
94
|
+
} catch (e) {
|
|
95
|
+
e.message = `${fname} error: ${e.message})`
|
|
96
|
+
t.parent.logMsg({ msg: `${fname} error: (${e.message})`.error, type: "error" })
|
|
97
|
+
throw e
|
|
98
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get_results_array() {
|
|
103
|
+
return this.results_array
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get_data_to_process_array() {
|
|
107
|
+
return this.data_to_process_array
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get_objects_to_process() {
|
|
111
|
+
return this.objects_to_process
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get_include_status() {
|
|
115
|
+
return this.include_status
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get_exclude_status() {
|
|
119
|
+
return this.exclude_status
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get_include_version() {
|
|
123
|
+
return this.include_version
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get_exclude_version() {
|
|
127
|
+
return this.exclude_version
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get_include_names() {
|
|
131
|
+
return this.include_names
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get_exclude_names() {
|
|
135
|
+
return this.exclude_status
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
init(props = {}) {
|
|
139
|
+
var t = this, fname = `base.init`, pr
|
|
140
|
+
try {
|
|
141
|
+
t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
|
|
142
|
+
t.status = "process"
|
|
143
|
+
t.parent.process()
|
|
144
|
+
} catch (e) {
|
|
145
|
+
e.message = `${fname} error: ${e.message})`
|
|
146
|
+
throw e
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2023-2-5
|
|
4
|
+
* bottom_one.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var base = require('./base.js')
|
|
8
|
+
|
|
9
|
+
exports = module.exports = class bottom_one extends base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props)
|
|
12
|
+
var t = this, fname = 'bottom_one.constructor'
|
|
13
|
+
try {
|
|
14
|
+
t.aname = 'bottom_one'
|
|
15
|
+
t.main_process_objects = []
|
|
16
|
+
|
|
17
|
+
if (t.appender != t.aname)
|
|
18
|
+
throw new Error(`(${t.appender}) does not equal the appender name (${t.aname}))`)
|
|
19
|
+
|
|
20
|
+
t.parent.logMsg({ msg: `${fname} objects to process count(${t.get_objects_to_process().length})`.debug, type: "debug" })
|
|
21
|
+
|
|
22
|
+
t.init = t.init.bind(t)
|
|
23
|
+
t.process = t.process.bind(t)
|
|
24
|
+
|
|
25
|
+
return t
|
|
26
|
+
} catch (e) {
|
|
27
|
+
e.message = `${fname} error: ${e.message})`
|
|
28
|
+
throw e
|
|
29
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init(props = {}) {
|
|
34
|
+
var t = this, fname = `bottom_one.init`, obj, dat, gotp
|
|
35
|
+
try {
|
|
36
|
+
t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
|
|
37
|
+
|
|
38
|
+
if (typeof t.get_objects_to_process()[0] == "undefined")
|
|
39
|
+
throw new Error(`get_objects_to_process[0] has no data`)
|
|
40
|
+
|
|
41
|
+
gotp = t.get_objects_to_process()
|
|
42
|
+
obj = gotp[gotp.length - 1]
|
|
43
|
+
dat = { props: { id: gotp.length, log: t.parent.logMsg } }
|
|
44
|
+
t.main_process_objects.push(new obj(dat.props))
|
|
45
|
+
|
|
46
|
+
super.init(props)
|
|
47
|
+
return t
|
|
48
|
+
} catch (e) {
|
|
49
|
+
e.message = `${fname} error: ${e.message})`
|
|
50
|
+
throw e
|
|
51
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
process(props = {}) {
|
|
56
|
+
var t = this, fname = `bottom_one.process`
|
|
57
|
+
try {
|
|
58
|
+
t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
|
|
59
|
+
|
|
60
|
+
super.process(props)
|
|
61
|
+
return t
|
|
62
|
+
} catch (e) {
|
|
63
|
+
e.message = `${fname} error: ${e.message})`
|
|
64
|
+
throw e
|
|
65
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2023-02-03
|
|
4
|
+
* common_code.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
exports = module.exports = class common_code {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
let t = this, fname = `common_code.constructor`
|
|
10
|
+
try {
|
|
11
|
+
t.parent = props.parent
|
|
12
|
+
t.log = props.log
|
|
13
|
+
t.log({ msg: `${fname}`.debug, type: "debug" })
|
|
14
|
+
t.include_func = props.include_func
|
|
15
|
+
t.exclude_func = props.exclude_func
|
|
16
|
+
t.by_what = props.by_what
|
|
17
|
+
return t
|
|
18
|
+
} catch (e) {
|
|
19
|
+
e.message = `${fname} error: ${e.message})`
|
|
20
|
+
t.log({ msg: `${fname}: ${e.message}`.error, type: "error" })
|
|
21
|
+
throw e
|
|
22
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init(props) {
|
|
27
|
+
let t = this, fname = `common_code.init`, obj_a, is, xis, obj, dat
|
|
28
|
+
try {
|
|
29
|
+
obj = props.obj
|
|
30
|
+
dat = props.dat
|
|
31
|
+
is = t.include_func()
|
|
32
|
+
xis = t.exclude_func()
|
|
33
|
+
t.log({ msg: `${fname} is(${JSON.stringify(is)} xis(${JSON.stringify(xis)})`.debug, type: "debug" })
|
|
34
|
+
obj_a = new obj(dat.props)
|
|
35
|
+
if (typeof is != "undefined") {
|
|
36
|
+
if (typeof obj_a != "undefined" &&
|
|
37
|
+
typeof eval(`obj_a.${t.by_what}`) != "undefined" &&
|
|
38
|
+
is.indexOf(eval(`obj_a.${t.by_what}`)) > -1) {
|
|
39
|
+
t.parent.main_process_objects.push(new obj(dat.props))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (typeof xis != "undefined") {
|
|
43
|
+
if (typeof obj_a != "undefined" &&
|
|
44
|
+
typeof eval(`obj_a.${t.by_what}`) != "undefined" &&
|
|
45
|
+
xis.indexOf(eval(`obj_a.${t.by_what}`)) < 0) {
|
|
46
|
+
t.parent.main_process_objects.push(new obj(dat.props))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return t
|
|
50
|
+
} catch (e) {
|
|
51
|
+
e.message = `${fname} error: ${e.message})`
|
|
52
|
+
t.log({ msg: `${fname}: ${e.message}`.error, type: "error" })
|
|
53
|
+
throw e
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
+
* @since 2023-2-5
|
|
4
|
+
* func_all.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var base = require('./base.js')
|
|
8
|
+
|
|
9
|
+
exports = module.exports = class func_all extends base {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props)
|
|
12
|
+
var t = this, fname = 'func_all.constructor'
|
|
13
|
+
try {
|
|
14
|
+
t.aname = 'func_all'
|
|
15
|
+
t.main_process_objects = []
|
|
16
|
+
|
|
17
|
+
if (t.appender != t.aname)
|
|
18
|
+
throw new Error(`(${t.appender}) does not equal the appender name (${t.aname}))`)
|
|
19
|
+
|
|
20
|
+
t.parent.logMsg({msg: `${fname} objects to process count(${t.get_objects_to_process().length})`.debug, type: "debug"})
|
|
21
|
+
|
|
22
|
+
t.init = t.init.bind(t)
|
|
23
|
+
t.process = t.process.bind(t)
|
|
24
|
+
t.custom_function = t.custom_function.bind(t)
|
|
25
|
+
|
|
26
|
+
return t
|
|
27
|
+
} catch (e) {
|
|
28
|
+
e.message = `${fname} error: ${e.message})`
|
|
29
|
+
throw e
|
|
30
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
init(props = {}) {
|
|
35
|
+
var t = this, fname = `func_all.init`, obj
|
|
36
|
+
try {
|
|
37
|
+
t.parent.logMsg({msg: `${fname}`.debug, type: "debug"})
|
|
38
|
+
|
|
39
|
+
if (typeof t.get_objects_to_process()[0] == "undefined")
|
|
40
|
+
throw new Error(`get_objects_to_process[0] has no data`)
|
|
41
|
+
|
|
42
|
+
t.get_objects_to_process().map((dat, i) => {
|
|
43
|
+
dat = {props: {id: (i+1), log: t.parent.logMsg}}
|
|
44
|
+
obj = t.get_objects_to_process()[i]
|
|
45
|
+
t.main_process_objects.push(new obj(dat.props))
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
super.init(props)
|
|
49
|
+
return t
|
|
50
|
+
} catch (e) {
|
|
51
|
+
e.message = `${fname} error: ${e.message})`
|
|
52
|
+
t.parent.logMsg({msg: `${fname} error: ${e.message}`.error, type: "error"})
|
|
53
|
+
throw e
|
|
54
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
custom_function(func){
|
|
59
|
+
var t = this, fname = `func_all.custom_function`
|
|
60
|
+
try {
|
|
61
|
+
t.parent.logMsg({msg: `${fname} typeof func(${typeof func}) WORK HERE`.bgBrightMagenta, type: "debug"})
|
|
62
|
+
return t
|
|
63
|
+
} catch (e) {
|
|
64
|
+
e.message = `${fname} error: ${e.message})`
|
|
65
|
+
t.parent.logMsg({msg: `${fname}`.error, type: "error"})
|
|
66
|
+
throw e
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
process(props = {}) {
|
|
71
|
+
var t = this, fname = `func_all.process`
|
|
72
|
+
try {
|
|
73
|
+
t.parent.logMsg({msg: `${fname}`.debug, type: "debug"})
|
|
74
|
+
|
|
75
|
+
super.process(props)
|
|
76
|
+
return t
|
|
77
|
+
} catch (e) {
|
|
78
|
+
e.message = `${fname} error: ${e.message})`
|
|
79
|
+
throw e
|
|
80
|
+
// t.parent.app_reject(`${fname} error: ${e.message})`)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|