file-obj-queue 2.0.4 → 3.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.
Files changed (50) hide show
  1. package/.github/workflows/{github-actions-demo.yml → github-actions.yml} +1 -1
  2. package/.github/workflows/node.js.yml +1 -0
  3. package/LICENSE +1 -1
  4. package/README.md +132 -7
  5. package/app.js +155 -40
  6. package/lib/appenders/all.js +17 -0
  7. package/lib/appenders/base.js +189 -0
  8. package/lib/appenders/bottom_one.js +17 -0
  9. package/lib/appenders/func_all.js +17 -0
  10. package/lib/appenders/name.js +17 -0
  11. package/lib/appenders/status.js +17 -0
  12. package/lib/appenders/sync.js +17 -0
  13. package/lib/appenders/sync_all.js +17 -0
  14. package/lib/appenders/top_one.js +17 -0
  15. package/lib/appenders/version.js +17 -0
  16. package/package.json +24 -3
  17. package/test/app.js +5 -1
  18. package/test/package.js +25 -3
  19. package/tests/all.js +85 -0
  20. package/tests/appenders/all.js +1 -1
  21. package/tests/appenders/base.js +1 -1
  22. package/tests/appenders/bottom_one.js +1 -1
  23. package/tests/appenders/func_all.js +1 -1
  24. package/tests/appenders/sync.js +1 -1
  25. package/tests/appenders/sync_all.js +1 -1
  26. package/tests/appenders/top_one.js +1 -1
  27. package/tests/appenders/version.js +1 -1
  28. package/tests/bottom_one.js +86 -0
  29. package/tests/files.js +50 -32
  30. package/tests/func_all.js +94 -0
  31. package/tests/json_all.js +107 -0
  32. package/tests/json_bottom_one.js +108 -0
  33. package/tests/json_func_all.js +109 -0
  34. package/tests/json_name_matching.js +109 -0
  35. package/tests/json_name_non_matching.js +109 -0
  36. package/tests/json_status_matching.js +110 -0
  37. package/tests/json_status_non_matching.js +110 -0
  38. package/tests/json_top_one.js +108 -0
  39. package/tests/json_version_matching.js +110 -0
  40. package/tests/json_version_non_matching.js +110 -0
  41. package/tests/name_matching.js +90 -0
  42. package/tests/name_non_matching.js +90 -0
  43. package/tests/status_matching.js +90 -0
  44. package/tests/status_non_matching.js +90 -0
  45. package/tests/top_one.js +85 -0
  46. package/tests/version_matching.js +90 -0
  47. package/tests/version_non_matching.js +90 -0
  48. package/base_queue/app.js +0 -146
  49. package/base_queue/appenders/base.js +0 -77
  50. package/base_queue/appenders/json_all.js +0 -70
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @author Jim Manton: jrman@risebroadband.net
3
+ * @since 2023-2-5
4
+ * lib/appenders/sync.js
5
+ */
6
+
7
+ var base = require('./base.js')
8
+
9
+ exports = module.exports = class sync extends base {
10
+ constructor(props) {
11
+ super(props)
12
+ var t = this
13
+ t.aname = 'sync'
14
+ t.pro_types = ['items', 'byIds']
15
+ return t
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @author Jim Manton: jrman@risebroadband.net
3
+ * @since 2023-2-5
4
+ * lib/appenders/sync_all.js
5
+ */
6
+
7
+ var base = require('./base.js')
8
+
9
+ exports = module.exports = class sync_all extends base {
10
+ constructor(props) {
11
+ super(props)
12
+ var t = this
13
+ t.aname = 'sync_all'
14
+ t.pro_types = ['items']
15
+ return t
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @author Jim Manton: jrman@risebroadband.net
3
+ * @since 2023-2-5
4
+ * lib/appenders/top_one.js
5
+ */
6
+
7
+ var base = require('./base.js')
8
+
9
+ exports = module.exports = class top_one extends base{
10
+ constructor(props) {
11
+ super(props)
12
+ var t = this
13
+ t.aname = 'top_one'
14
+ t.pro_types = ['items']
15
+ return t
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @author Jim Manton: jrman@risebroadband.net
3
+ * @since 2023-2-5
4
+ * lib/appenders/status.js
5
+ */
6
+
7
+ var base = require('./base.js')
8
+
9
+ exports = module.exports = class version extends base {
10
+ constructor(props) {
11
+ super(props)
12
+ var t = this
13
+ t.aname = 'version'
14
+ t.pro_types = ['version']
15
+ return t
16
+ }
17
+ }
package/package.json CHANGED
@@ -2,24 +2,45 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "2.0.4",
5
+ "version": "3.0.0",
6
6
  "bundleDependencies": [],
7
7
  "dependencies": {
8
8
  "@types/node": "^18.11.19",
9
+ "base-queue": "^1.0.0",
9
10
  "chai": "^4.3.7",
10
11
  "colors": "^1.4.0",
11
12
  "diffler": "^2.0.4",
12
13
  "fs": "^0.0.1-security",
14
+ "log-queue": "^1.0.0",
13
15
  "mocha": "^10.2.0",
14
16
  "queuejson": "^9.0.11",
15
- "typescript": "^4.9.5",
16
17
  "valid-path": "^2.1.0"
17
18
  },
18
19
  "scripts": {
19
20
  "start": "node app.ts",
20
21
  "test": "mocha",
21
22
  "ditched": "ditched -a",
22
- "test_files": "node ./tests/files"
23
+ "test_files": "node ./tests/files",
24
+ "test_all": "node ./tests/all",
25
+ "test_top_one": "node ./tests/top_one",
26
+ "test_bottom_one": "node ./tests/bottom_one",
27
+ "test_func_all": "node ./tests/func_all",
28
+ "test_status_matching": "node ./tests/status_matching",
29
+ "test_status_non_matching": "node ./tests/status_non_matching",
30
+ "test_name_matching": "node ./tests/name_matching",
31
+ "test_name_non_matching": "node ./tests/name_non_matching",
32
+ "test_version_matching": "node ./tests/version_matching",
33
+ "test_version_non_matching": "node ./tests/version_non_matching",
34
+ "test_json_all": "node ./tests/json_all",
35
+ "test_json_top_one": "node ./tests/json_top_one",
36
+ "test_json_bottom_one": "node ./tests/json_bottom_one",
37
+ "test_json_func_all": "node ./tests/json_func_all",
38
+ "test_json_status_matching": "node ./tests/json_status_matching",
39
+ "test_json_status_non_matching": "node ./tests/json_status_non_matching",
40
+ "test_json_version_matching": "node ./tests/json_version_matching",
41
+ "test_json_version_non_matching": "node ./tests/json_version_non_matching",
42
+ "test_json_name_matching": "node ./tests/json_name_matching",
43
+ "test_json_name_non_matching": "node ./tests/json_name_non_matching"
23
44
  },
24
45
  "keywords": [
25
46
  "queue",
package/test/app.js CHANGED
@@ -24,7 +24,7 @@ describe('require', function () {
24
24
  })
25
25
 
26
26
  it('base_queue', function () {
27
- assert(require('../base_queue/app'))
27
+ assert(require('base-queue'))
28
28
  })
29
29
 
30
30
  it('fs', function () {
@@ -34,4 +34,8 @@ describe('require', function () {
34
34
  it('valid-path', function () {
35
35
  assert(require('valid-path'))
36
36
  })
37
+
38
+ it('valid-path', function () {
39
+ assert(require('log-queue'))
40
+ })
37
41
  })
package/test/package.js CHANGED
@@ -6,24 +6,45 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "2.0.4",
9
+ "version": "3.0.0",
10
10
  "bundleDependencies": [],
11
11
  "dependencies": {
12
12
  "@types/node": "^18.11.19",
13
+ "base-queue": "^1.0.0",
13
14
  "chai": "^4.3.7",
14
15
  "colors": "^1.4.0",
15
16
  "diffler": "^2.0.4",
16
17
  "fs": "^0.0.1-security",
18
+ "log-queue": "^1.0.0",
17
19
  "mocha": "^10.2.0",
18
20
  "queuejson": "^9.0.11",
19
- "typescript": "^4.9.5",
20
21
  "valid-path": "^2.1.0"
21
22
  },
22
23
  "scripts": {
23
24
  "start": "node app.ts",
24
25
  "test": "mocha",
25
26
  "ditched": "ditched -a",
26
- "test_files": "node ./tests/files"
27
+ "test_files": "node ./tests/files",
28
+ "test_all": "node ./tests/all",
29
+ "test_top_one": "node ./tests/top_one",
30
+ "test_bottom_one": "node ./tests/bottom_one",
31
+ "test_func_all": "node ./tests/func_all",
32
+ "test_status_matching": "node ./tests/status_matching",
33
+ "test_status_non_matching": "node ./tests/status_non_matching",
34
+ "test_name_matching": "node ./tests/name_matching",
35
+ "test_name_non_matching": "node ./tests/name_non_matching",
36
+ "test_version_matching": "node ./tests/version_matching",
37
+ "test_version_non_matching": "node ./tests/version_non_matching",
38
+ "test_json_all": "node ./tests/json_all",
39
+ "test_json_top_one": "node ./tests/json_top_one",
40
+ "test_json_bottom_one": "node ./tests/json_bottom_one",
41
+ "test_json_func_all": "node ./tests/json_func_all",
42
+ "test_json_status_matching": "node ./tests/json_status_matching",
43
+ "test_json_status_non_matching": "node ./tests/json_status_non_matching",
44
+ "test_json_version_matching": "node ./tests/json_version_matching",
45
+ "test_json_version_non_matching": "node ./tests/json_version_non_matching",
46
+ "test_json_name_matching": "node ./tests/json_name_matching",
47
+ "test_json_name_non_matching": "node ./tests/json_name_non_matching"
27
48
  },
28
49
  "keywords": [
29
50
  "queue",
@@ -49,6 +70,7 @@ const packageMock = {
49
70
  "start": "node app.js"
50
71
  }
51
72
 
73
+
52
74
  describe('package.json', function () {
53
75
  it('should pass', function () {
54
76
  const difference = jsonHasDifferences(packagejson, packageMock)
package/tests/all.js ADDED
@@ -0,0 +1,85 @@
1
+ var queue = require("../app.js")
2
+
3
+ var tst1 = class test1 {
4
+ constructor(props) {
5
+ let t = this, fname = "test_all.test1.constructor"
6
+ t.log = props.log
7
+ t.id = props.id
8
+
9
+ t.process = t.process.bind(t)
10
+ }
11
+
12
+ process(callback) {
13
+ let t = this, fname = "test_all.test1.process"
14
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
15
+ callback({ success: { msg: `processing all test1` } })
16
+ }
17
+ }
18
+
19
+ var tst2 = class test2 {
20
+ constructor(props) {
21
+ let t = this, fname = "test_all.test2.constructor"
22
+ t.log = props.log
23
+ t.id = props.id
24
+
25
+ t.process = t.process.bind(t)
26
+ }
27
+
28
+ process(callback) {
29
+ let t = this, fname = "test_all.test2.process"
30
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
31
+ setTimeout(() => {
32
+ callback({ success: { msg: `processing all test2` } })
33
+ }, 4000)
34
+ }
35
+ }
36
+
37
+ var tst3 = class test3 {
38
+ constructor(props) {
39
+ let t = this, fname = "test_all.test3.constructor"
40
+ t.log = props.log
41
+ t.id = props.id
42
+
43
+ t.process = t.process.bind(t)
44
+ }
45
+
46
+ process(callback) {
47
+ let t = this, fname = "test_all.test3.process"
48
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
49
+ // callback({success: { msg: `processing all test3` }})
50
+ callback({ error: { msg: `there is some problem thrown here on test3` } })
51
+ }
52
+ }
53
+
54
+ var tst4 = class test4 {
55
+ constructor(props) {
56
+ let t = this, fname = "test_all.test4.constructor"
57
+ t.log = props.log
58
+ t.id = props.id
59
+
60
+ t.process = t.process.bind(t)
61
+ }
62
+
63
+ process(callback) {
64
+ let t = this, fname = "test_all.test4.process"
65
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
66
+ callback({ success: { msg: `processing all test4` } })
67
+ }
68
+ }
69
+
70
+ var qObj = new queue()
71
+
72
+ qObj.init().process({
73
+ appender: "all",
74
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
75
+ process_objects: [tst1, tst2, tst3, tst4]
76
+ }).then((success) => {
77
+ qObj.logMsg({ msg: `test success: {msg: "all objects processed with no errors"}`.success.italic.bold, type: "success" })
78
+ }, (error) => {
79
+ if (typeof error == "string") {
80
+ qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
81
+ } else {
82
+ let add_s = (error.error_count > 1) ? 's' : ''
83
+ qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
84
+ }
85
+ })
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22l
3
+ * @since 2023-2-5l
4
4
  * lib/appenders/all.js
5
5
  */
6
6
 
@@ -73,7 +73,7 @@ class process_object {
73
73
  t.parent.results_array.push(obj_props)
74
74
  t.continueProcessing()
75
75
  } catch (e) {
76
- t.parent.getParent().logMsg(`pro obj error: (${e.message})`.red)
76
+ t.parent.getParent().logMsg({msg: `pro obj error: (${e.message})`.error, type: "error"})
77
77
  throw e
78
78
  }
79
79
  })
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/bottom_one.js
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/func_all.js
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/sync.js
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/sync_all.js
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/top_one.js
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * @author Jim Manton: jrman@risebroadband.net
3
- * @since 2021-03-22
3
+ * @since 2023-2-5
4
4
  * lib/appenders/status.js
5
5
  */
6
6
 
@@ -0,0 +1,86 @@
1
+ var queue = require("../app.js")
2
+
3
+ var tst1 = class test1 {
4
+ constructor(props) {
5
+ let t = this, fname = "test_bottom_one.test1.constructor"
6
+ t.log = props.log
7
+ t.id = props.id
8
+
9
+ t.process = t.process.bind(t)
10
+ }
11
+
12
+ process(callback) {
13
+ let t = this, fname = "test_bottom_one.test1.process"
14
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
15
+ callback({ success: { msg: `processing all test1` } })
16
+ }
17
+ }
18
+
19
+ var tst2 = class test2 {
20
+ constructor(props) {
21
+ let t = this, fname = "test_bottom_one.test2.constructor"
22
+ t.log = props.log
23
+ t.id = props.id
24
+
25
+ t.process = t.process.bind(t)
26
+ }
27
+
28
+ process(callback) {
29
+ let t = this, fname = "test_bottom_one.test2.process"
30
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
31
+ setTimeout(() => {
32
+ callback({ success: { msg: `processing all test2` } })
33
+ }, 4000)
34
+ }
35
+ }
36
+
37
+ var tst3 = class test3 {
38
+ constructor(props) {
39
+ let t = this, fname = "test_bottom_one.test3.constructor"
40
+ t.log = props.log
41
+ t.id = props.id
42
+
43
+ t.process = t.process.bind(t)
44
+ }
45
+
46
+ process(callback) {
47
+ let t = this, fname = "test_bottom_one.test3.process"
48
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
49
+ // callback({success: { msg: `processing all test3` }})
50
+ callback({ error: { msg: `there is some problem thrown here on test3` } })
51
+ }
52
+ }
53
+
54
+ var tst4 = class test4 {
55
+ constructor(props) {
56
+ let t = this, fname = "test_bottom_one.test4.constructor"
57
+ t.log = props.log
58
+ t.id = props.id
59
+
60
+ t.process = t.process.bind(t)
61
+
62
+ }
63
+
64
+ process(callback) {
65
+ let t = this, fname = "test_bottom_one.test4.process"
66
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
67
+ callback({ success: { msg: `processing all test4` } })
68
+ }
69
+ }
70
+
71
+ var qObj = new queue()
72
+
73
+ qObj.init().process({
74
+ appender: "bottom_one",
75
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
76
+ process_objects: [tst1, tst2, tst3, tst4]
77
+ }).then((success) => {
78
+ qObj.logMsg({ msg: `test success: {msg: "bottom_one object processed with no errors"}`.success.italic.bold, type: "success" })
79
+ }, (error) => {
80
+ if (typeof error == "string") {
81
+ qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
82
+ } else {
83
+ let add_s = (error.error_count > 1) ? 's' : ''
84
+ qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
85
+ }
86
+ })
package/tests/files.js CHANGED
@@ -1,37 +1,45 @@
1
- var colors = require('colors'),
2
- file_queue = require("../app.js"),
1
+ var file_queue = require("../app.js"),
3
2
  fs = require('fs'),
4
3
  validPath = require('valid-path')
5
4
 
6
5
  var file_data = [
7
- { props: { id: 100, name: "all", path: "./appenders/all.js", absolute_path: __filename, check: true } },
8
- { props: { id: 101, name: "func_all", path: "./appenders/func_all.js", absolute_path: __filename, check: true } },
9
- { props: { id: 102, name: "top_one", path: "./appenders/top_one.js", absolute_path: __filename, check: true } },
10
- { props: { id: 103, name: "bottom_one", path: "./appenders/bottom_one.js", absolute_path: __filename, check: true } },
11
- { props: { id: 104, name: "sync_all", path: "./appenders/sync_all.js", absolute_path: __filename, check: true } },
12
- { props: { id: 105, name: "status", path: "./appenders/status.js", absolute_path: __filename, check: true } },
13
- { props: { id: 106, name: "name", path: "./appenders/name.js", absolute_path: __filename, check: true } },
14
- { props: { id: 107, name: "version", path: "./appenders/version.js", absolute_path: __filename, check: true } }
6
+ { props: { id: 100, name: "all.js", absolute_path: __filename, check: true } },
7
+ { props: { id: 101, name: "func_all.js", absolute_path: __filename, check: true } },
8
+ { props: { id: 102, name: "top_one.js", absolute_path: __filename, check: true } },
9
+ { props: { id: 103, name: "bottom_one.js", absolute_path: __filename, check: true } },
10
+ { props: { id: 104, name: "sync_all.js", absolute_path: __filename, check: true } },
11
+ { props: { id: 105, name: "status.js", absolute_path: __filename, check: true } },
12
+ { props: { id: 106, name: "name.js", absolute_path: __filename, check: true } },
13
+ { props: { id: 107, name: "version.js", absolute_path: __filename, check: true } }
15
14
  ]
16
15
 
17
-
18
16
  var file_object = class file_obj {
19
17
  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.path
25
- t.absolute_path = props.absolute_path
26
- t.status = 'init'
27
- t.errors = false
28
- t.error_msg = 'none'
18
+ let t = this, fname = "file_obj.constructor"
19
+ try {
20
+ t.id = props.id
21
+ t.log = props.log
22
+ t.name = props.name
23
+ t.path = props.relative_path
24
+ t.absolute_path = props.absolute_path
25
+ t.status = 'init'
26
+ t.errors = false
27
+ t.error_msg = 'none'
28
+
29
+ // if (t.id == 104) {
30
+ // t.errors = true
31
+ // t.error_msg = `some sort of error here`
32
+ // }
29
33
 
30
- t.process = t.process.bind(t)
31
- t.do_checks = t.do_checks.bind(t)
34
+ t.process = t.process.bind(t)
35
+ t.do_checks = t.do_checks.bind(t)
32
36
 
33
- if (props.check) {
34
- t.do_checks()
37
+ if (props.check) {
38
+ t.do_checks()
39
+ }
40
+ } catch (e) {
41
+ e.message = `${fname} error: ${e.message}`
42
+ throw e
35
43
  }
36
44
 
37
45
  return t
@@ -40,6 +48,7 @@ var file_object = class file_obj {
40
48
  do_checks() {
41
49
  let t = this, path_to_check,
42
50
  last_item = t.absolute_path.split("\\").pop(),
51
+ fname = `file_obj.do_checks`,
43
52
  check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
44
53
 
45
54
  check_file = check_file.replace(/\\/g, "/");
@@ -56,11 +65,12 @@ var file_object = class file_obj {
56
65
  check_file += dat + '/'
57
66
  }
58
67
  })
59
- check_file = check_file.slice(0, -1)
68
+ check_file += `${t.name}`
60
69
  try {
61
70
  if (!fs.existsSync(check_file)) {
62
71
  t.errors = true
63
72
  t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
73
+ t.log({ msg: t.error_msg.error, type: "error" })
64
74
  }
65
75
  } catch (e) {
66
76
  e.message = "file_obj do_checks error: " + e.message
@@ -70,6 +80,7 @@ var file_object = class file_obj {
70
80
 
71
81
  process(callback) {
72
82
  let t = this
83
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
73
84
  if (t.errors)
74
85
  callback({ error: { msg: t.error_msg } })
75
86
  else
@@ -79,12 +90,19 @@ var file_object = class file_obj {
79
90
 
80
91
  var qRequire = new file_queue()
81
92
 
82
- qRequire.process({ appender: "json_all",
83
- process_objects: [file_object],
84
- data_to_process_array: file_data }).then((success)=>{
85
- qRequire.logMsg(`test success: all file objects processed with no errors`.success)
86
- },(error)=>{
87
- let add_s = (error.error_count > 1) ? 's' : ''
88
- qRequire.logMsg(`${error.error_count} error${add_s} detected`.error)
93
+ qRequire.init().process({
94
+ appender: "json_all",
95
+ exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
+ process_objects: [file_object],
97
+ data_to_process_array: file_data
98
+ }).then((success) => {
99
+ qRequire.logMsg({ msg: `test success: file objects processed with no errors`.success.italic.bold, type: "success" })
100
+ }, (error) => {
101
+ if (typeof error == "string") {
102
+ qRequire.logMsg({msg: `error: ${error}`.error.italic.bold, type: "error"})
103
+ } else {
104
+ let add_s = (error.error_count > 1) ? 's' : ''
105
+ qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
106
+ }
89
107
  })
90
108
 
@@ -0,0 +1,94 @@
1
+ var queue = require("../app.js")
2
+
3
+ var tst1 = class test1 {
4
+ constructor(props) {
5
+ let t = this, fname = "test_all.test1.constructor"
6
+ t.log = props.log
7
+ t.id = props.id
8
+ t.base_queue_process_function = t.custom_function
9
+
10
+ t.custom_function = t.custom_function.bind(t)
11
+ t.base_queue_process_function = t.base_queue_process_function.bind(t)
12
+ }
13
+
14
+ custom_function(callback) {
15
+ let t = this, fname = "test_all.test1.custom_function"
16
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
17
+ callback({ success: { msg: `processing all test1` } })
18
+ }
19
+ }
20
+
21
+ var tst2 = class test2 {
22
+ constructor(props) {
23
+ let t = this, fname = "test_all.test2.constructor"
24
+ t.log = props.log
25
+ t.id = props.id
26
+ t.base_queue_process_function = t.another_function
27
+
28
+ t.another_function = t.another_function.bind(t)
29
+ t.base_queue_process_function = t.base_queue_process_function.bind(t)
30
+ }
31
+
32
+ another_function(callback) {
33
+ let t = this, fname = "test_all.test2.another_function"
34
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
35
+ // callback({ success: { msg: `processing all test2` } })
36
+ setTimeout(() => {
37
+ callback({ success: { msg: `processing all test2` } })
38
+ }, 4000)
39
+ }
40
+ }
41
+
42
+ var tst3 = class test3 {
43
+ constructor(props) {
44
+ let t = this, fname = "test_all.test3.constructor"
45
+ t.log = props.log
46
+ t.id = props.id
47
+ t.base_queue_process_function = t.third_test
48
+
49
+ t.third_test = t.third_test.bind(t)
50
+ t.base_queue_process_function = t.base_queue_process_function.bind(t)
51
+ }
52
+
53
+ third_test(callback) {
54
+ let t = this, fname = "test_all.test3.third_test"
55
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
56
+ // callback({success: { msg: `processing all test3` }})
57
+ callback({ error: { msg: `there is some problem thrown here on test3` } })
58
+ }
59
+ }
60
+
61
+ var tst4 = class test4 {
62
+ constructor(props) {
63
+ let t = this, fname = "test_all.test4.constructor"
64
+ t.log = props.log
65
+ t.id = props.id
66
+ t.base_queue_process_function = t.last_shot
67
+
68
+ t.last_shot = t.last_shot.bind(t)
69
+ t.base_queue_process_function = t.base_queue_process_function.bind(t)
70
+ }
71
+
72
+ last_shot(callback) {
73
+ let t = this, fname = "test_all.test4.process"
74
+ t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
75
+ callback({ success: { msg: `processing all test4` } })
76
+ }
77
+ }
78
+
79
+ var qObj = new queue()
80
+
81
+ qObj.init().process({
82
+ appender: "func_all",
83
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
84
+ process_objects: [tst1, tst2, tst3, tst4],
85
+ }).then((success) => {
86
+ qObj.logMsg({ msg: `test success: {msg: "func_all objects processed with no errors"}`.success.italic.bold, type: "success" })
87
+ }, (error) => {
88
+ if (typeof error == "string") {
89
+ qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
90
+ } else {
91
+ let add_s = (error.error_count > 1) ? 's' : ''
92
+ qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
93
+ }
94
+ })