base-queue 1.0.7 → 2.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.
@@ -78,3 +78,4 @@ jobs:
78
78
 
79
79
  - run: npm run build --if-present
80
80
  - run: npm run test_base
81
+ - run: npm run json_base
@@ -36,7 +36,7 @@ exports = module.exports = class common_code {
36
36
  if (typeof obj_a != "undefined" &&
37
37
  typeof eval(`obj_a.${t.by_what}`) != "undefined" &&
38
38
  is.indexOf(eval(`obj_a.${t.by_what}`)) > -1) {
39
- t.parent.main_process_objects.push(new obj(dat.props))
39
+ t.parent.main_process_objects.push(new obj(dat.props))
40
40
  }
41
41
  }
42
42
  if (typeof xis != "undefined") {
@@ -19,7 +19,7 @@ exports = module.exports = class json_name extends base {
19
19
  log: t.parent.logMsg,
20
20
  include_func: t.get_include_names,
21
21
  exclude_func: t.get_exclude_names,
22
- by_what: t.aname
22
+ by_what: "name"
23
23
  })
24
24
 
25
25
  if (typeof props.data_to_process_array == 'undefined')
@@ -57,13 +57,7 @@ exports = module.exports = class json_name extends base {
57
57
  dat.props.log = t.parent.logMsg
58
58
  dat.props.relative_path = t.relative_path
59
59
  obj = t.get_objects_to_process()[0]
60
- is = t.get_include_names()
61
- obj_a = new obj(dat.props)
62
- if (typeof obj_a != "undefined" &&
63
- typeof obj_a.name != "undefined" &&
64
- is.indexOf(obj_a.name) > -1) {
65
- t.main_process_objects.push(new obj(dat.props))
66
- }
60
+ t.common_code.init({ obj: obj, dat: dat })
67
61
  })
68
62
  } catch (e) {
69
63
  e.message = `${fname} error: ${e.message}`
@@ -4,7 +4,8 @@
4
4
  * json_status.js
5
5
  */
6
6
 
7
- var base = require('./base.js')
7
+ var base = require('./base.js'),
8
+ common_code = require('./common_code.js')
8
9
 
9
10
  exports = module.exports = class json_status extends base {
10
11
  constructor(props) {
@@ -18,7 +19,7 @@ exports = module.exports = class json_status extends base {
18
19
  log: t.parent.logMsg,
19
20
  include_func: t.get_include_status,
20
21
  exclude_func: t.get_exclude_status,
21
- by_what: t.aname
22
+ by_what: "status"
22
23
  })
23
24
 
24
25
  if (typeof props.data_to_process_array == 'undefined')
@@ -42,7 +43,8 @@ exports = module.exports = class json_status extends base {
42
43
 
43
44
  init(props = {}) {
44
45
  var t = this, fname = `json_status.init`, obj, is, obj_a
45
- try {``
46
+ try {
47
+ ``
46
48
  t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
47
49
 
48
50
  if (typeof t.get_objects_to_process()[0] == "undefined")
@@ -54,17 +56,11 @@ exports = module.exports = class json_status extends base {
54
56
  dat.props.log = t.parent.logMsg
55
57
  dat.props.relative_path = t.relative_path
56
58
  obj = t.get_objects_to_process()[0]
57
- is = t.get_include_status()
58
- obj_a = new obj(dat.props)
59
- if (typeof obj_a != "undefined" &&
60
- typeof obj_a.status != "undefined" &&
61
- is.indexOf(obj_a.status) > -1) {
62
- t.main_process_objects.push(new obj(dat.props))
63
- }
59
+ t.common_code.init({ obj: obj, dat: dat })
64
60
  })
65
61
  } catch (e) {
66
62
  e.message = `${fname} error: ${e.message}`
67
- t.parent.logMsg({msg: e.message.error, type: "error"})
63
+ t.parent.logMsg({ msg: e.message.error, type: "error" })
68
64
  throw e
69
65
  }
70
66
 
@@ -80,7 +76,7 @@ exports = module.exports = class json_status extends base {
80
76
  process(props = {}) {
81
77
  var t = this, fname = `json_status.process`
82
78
  try {
83
- t.parent.logMsg({msg: `${fname} length(${t.main_process_objects.length})`.debug, type: "debug"})
79
+ t.parent.logMsg({ msg: `${fname} length(${t.main_process_objects.length})`.debug, type: "debug" })
84
80
 
85
81
  super.process(props)
86
82
  return t
@@ -4,7 +4,8 @@
4
4
  * json_version.js
5
5
  */
6
6
 
7
- var base = require('./base.js')
7
+ var base = require('./base.js'),
8
+ common_code = require('./common_code.js')
8
9
 
9
10
  exports = module.exports = class json_version extends base {
10
11
  constructor(props) {
@@ -18,9 +19,9 @@ exports = module.exports = class json_version extends base {
18
19
  log: t.parent.logMsg,
19
20
  include_func: t.get_include_version,
20
21
  exclude_func: t.get_exclude_version,
21
- by_what: t.aname
22
+ by_what: "version"
22
23
  })
23
-
24
+
24
25
  if (typeof props.data_to_process_array == 'undefined')
25
26
  throw new Error(`props.data_to_process_array not defined`)
26
27
 
@@ -42,7 +43,8 @@ exports = module.exports = class json_version extends base {
42
43
 
43
44
  init(props = {}) {
44
45
  var t = this, fname = `json_version.init`, obj, is, obj_a
45
- try {``
46
+ try {
47
+ ``
46
48
  t.parent.logMsg({ msg: `${fname}`.debug, type: "debug" })
47
49
 
48
50
  if (typeof t.get_objects_to_process()[0] == "undefined")
@@ -54,17 +56,11 @@ exports = module.exports = class json_version extends base {
54
56
  dat.props.log = t.parent.logMsg
55
57
  dat.props.relative_path = t.relative_path
56
58
  obj = t.get_objects_to_process()[0]
57
- is = t.get_include_version()
58
- obj_a = new obj(dat.props)
59
- if (typeof obj_a != "undefined" &&
60
- typeof obj_a.version != "undefined" &&
61
- is.indexOf(obj_a.version) > -1) {
62
- t.main_process_objects.push(new obj(dat.props))
63
- }
59
+ t.common_code.init({ obj: obj, dat: dat })
64
60
  })
65
61
  } catch (e) {
66
62
  e.message = `${fname} error: ${e.message}`
67
- t.parent.logMsg({msg: e.message.error, type: "error"})
63
+ t.parent.logMsg({ msg: e.message.error, type: "error" })
68
64
  throw e
69
65
  }
70
66
 
@@ -80,7 +76,7 @@ exports = module.exports = class json_version extends base {
80
76
  process(props = {}) {
81
77
  var t = this, fname = `json_version.process`
82
78
  try {
83
- t.parent.logMsg({msg: `${fname} length(${t.main_process_objects.length})`.debug, type: "debug"})
79
+ t.parent.logMsg({ msg: `${fname} length(${t.main_process_objects.length})`.debug, type: "debug" })
84
80
 
85
81
  super.process(props)
86
82
  return t
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": {
3
3
  "name": "Jim Manton"
4
4
  },
5
- "version": "1.0.7",
5
+ "version": "2.0.0",
6
6
  "bundleDependencies": [],
7
7
  "dependencies": {
8
8
  "chai": "^4.3.7",
@@ -18,7 +18,13 @@
18
18
  "test": "mocha",
19
19
  "ditched": "ditched -a",
20
20
  "test_base": "node ./tests/base",
21
- "json_base": "node ./tests/json"
21
+ "json_base": "node ./tests/json",
22
+ "json_version_matching": "node ./tests/json_version",
23
+ "json_version_non_matching": "node ./tests/json_version_non_matching",
24
+ "json_name_matching": "node ./tests/json_name",
25
+ "json_name_non_matching": "node ./tests/json_name_non_matching",
26
+ "json_status_matching": "node ./tests/json_status",
27
+ "json_status_non_matching": "node ./tests/json_status_non_matching"
22
28
  },
23
29
  "keywords": [
24
30
  "queue",
package/test/package.js CHANGED
@@ -6,7 +6,7 @@ const packageMock = {
6
6
  "author": {
7
7
  "name": "Jim Manton"
8
8
  },
9
- "version": "1.0.7",
9
+ "version": "2.0.0",
10
10
  "bundleDependencies": [],
11
11
  "dependencies": {
12
12
  "chai": "^4.3.7",
@@ -22,7 +22,13 @@ const packageMock = {
22
22
  "test": "mocha",
23
23
  "ditched": "ditched -a",
24
24
  "test_base": "node ./tests/base",
25
- "json_base": "node ./tests/json"
25
+ "json_base": "node ./tests/json",
26
+ "json_version_matching": "node ./tests/json_version",
27
+ "json_version_non_matching": "node ./tests/json_version_non_matching",
28
+ "json_name_matching": "node ./tests/json_name",
29
+ "json_name_non_matching": "node ./tests/json_name_non_matching",
30
+ "json_status_matching": "node ./tests/json_status",
31
+ "json_status_non_matching": "node ./tests/json_status_non_matching"
26
32
  },
27
33
  "keywords": [
28
34
  "queue",
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.status = props.status
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_name",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ include_names: ["all", "bottom_one", "func_all"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.status = props.status
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_name",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ exclude_names: ["all", "bottom_one", "func_all"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.status = props.status
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_status",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ include_status: ["done", "delete"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.status = props.status
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_status",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ exclude_status: ["done", "delete"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", version: "1.00", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", version: "2.00", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", version: "1.00", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", version: "3.00", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", version: "4.00", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", version: "5.00", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", version: "2.00", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", version: "3.00", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.version = props.version
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) version(${t.version})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_version",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ include_version: ["2.00", "5.00"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+
@@ -0,0 +1,85 @@
1
+
2
+ var file_data = [
3
+ { props: { id: 100, name: "all", version: "1.00", absolute_path: __filename, check: true } },
4
+ { props: { id: 101, name: "func_all", version: "2.00", absolute_path: __filename, check: true } },
5
+ { props: { id: 102, name: "top_one", version: "1.00", absolute_path: __filename, check: true } },
6
+ { props: { id: 103, name: "bottom_one", version: "3.00", absolute_path: __filename, check: true } },
7
+ { props: { id: 104, name: "sync_all", version: "4.00", absolute_path: __filename, check: true } },
8
+ { props: { id: 105, name: "status", version: "5.00", absolute_path: __filename, check: true } },
9
+ { props: { id: 106, name: "name", version: "2.00", absolute_path: __filename, check: true } },
10
+ { props: { id: 107, name: "version", version: "3.00", absolute_path: __filename, check: true } }
11
+ ]
12
+
13
+ var file_object = class file_obj {
14
+ constructor(props) {
15
+ let t = this, fname = "file_obj.constructor"
16
+ try {
17
+ t.id = props.id
18
+ t.log = props.log
19
+ t.name = props.name
20
+ t.version = props.version
21
+ t.path = props.relative_path
22
+ t.absolute_path = props.absolute_path
23
+ t.errors = false
24
+ t.error_msg = 'none'
25
+
26
+ // if (t.id == 104) {
27
+ // t.errors = true
28
+ // t.error_msg = `some sort of error here`
29
+ // }
30
+
31
+ t.process = t.process.bind(t)
32
+ } catch (e) {
33
+ e.message = `${fname} error: ${e.message}`
34
+ throw e
35
+ }
36
+
37
+ return t
38
+ }
39
+
40
+ process(callback) {
41
+ let t = this
42
+ t.log({ msg: `processing object id ${t.id}. Do a bunch of stuff here.`.silly, type: "silly" })
43
+ if (t.errors)
44
+ callback({ error: { msg: t.error_msg } })
45
+ else
46
+ callback({ success: { msg: `id = ${t.id} name(${t.name}) version(${t.version})` } })
47
+ }
48
+ }
49
+
50
+ var lq = require("log-queue"),
51
+ log = new lq({
52
+ exclude_logMsg: ["debug"], /* example ["debug", "info"] */
53
+ }).init({appender: "console"}),
54
+ a_resolve, a_reject,
55
+ promise = new Promise((resolve, reject) => {
56
+ a_resolve = resolve
57
+ a_reject = reject
58
+ }),
59
+ bb = require("../app.js"),
60
+ base_queue = new bb({
61
+ parent: null,
62
+ relative_path: "./appenders/",
63
+ logMsg: log.logMsg,
64
+ resolve: a_resolve,
65
+ reject: a_reject
66
+ }).load({
67
+ appender: "json_version",
68
+ exclude_logMsg: [], /* default [] */
69
+ process_objects: [file_object],
70
+ exclude_version: ["2.00", "5.00"],
71
+ data_to_process_array: file_data
72
+ }).process()
73
+
74
+ promise.then((success) => {
75
+ log.logMsg({ msg: `Json all object processed successfully`.success.italic.bold, type: "success" })
76
+ }, (error) => {
77
+ if (typeof error == "string") {
78
+ log.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
79
+ } else {
80
+ let add_s = (error.error_count > 1) ? 's' : ''
81
+ log.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
82
+ }
83
+ })
84
+
85
+