queueobj 9.0.0 → 9.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/README.md +19 -61
- package/package.json +1 -1
- package/test/package.js +1 -1
package/README.md
CHANGED
|
@@ -46,24 +46,28 @@ var queue = require("queueobj");
|
|
|
46
46
|
class test1 {
|
|
47
47
|
constructor() {
|
|
48
48
|
this.id = 100
|
|
49
|
+
this.process = this.process.bind(this)
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
process(callback) {
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
console.log(`processing test1`.cyan)
|
|
55
|
+
console.log(`some async process`)
|
|
56
|
+
callback({success: {msg: `processing all (${this.id})`}})
|
|
57
|
+
}, 3000)
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
class test2 {
|
|
58
62
|
constructor() {
|
|
59
63
|
this.id = 200
|
|
64
|
+
this.process = this.process.bind(this)
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
process(callback) {
|
|
63
|
-
let msg = `some kinda problem here`
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
callback() //this will show no errors
|
|
68
|
+
let msg = `some kinda problem here in id(${this.id})`
|
|
69
|
+
// callback({error: {msg: msg}}) //this will show errors
|
|
70
|
+
callback({success: {msg: `processing all (${this.id})}`}}) //this will show no errors
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
ping() {
|
|
@@ -74,14 +78,11 @@ class test2 {
|
|
|
74
78
|
class test3 {
|
|
75
79
|
constructor() {
|
|
76
80
|
this.id = 300
|
|
81
|
+
this.process = this.process.bind(this)
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
process(callback) {
|
|
80
|
-
|
|
81
|
-
console.log(`processing test3`.cyan)
|
|
82
|
-
console.log(`some async process`)
|
|
83
|
-
callback()
|
|
84
|
-
}, 2000)
|
|
85
|
+
callback({success: {msg: `processing all (${this.id})}`}})
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -94,64 +95,21 @@ class test4 {
|
|
|
94
95
|
|
|
95
96
|
custom_function(callback) {
|
|
96
97
|
let msg = `custom func problem here id(${this.id})`
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
// callback({error: {msg: msg}}) //this will show errors
|
|
100
|
+
callback({success: {msg: `processing all (${this.id})}`}}) //this will show no errors
|
|
101
|
+
}, 3000)
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
let tst4 = new test4()
|
|
103
|
-
let qObj = new queue(), props = { appender: '
|
|
105
|
+
let qObj = new queue(), props = { appender: 'sync_all' }
|
|
104
106
|
|
|
105
107
|
qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(tst4.custom_function)
|
|
106
108
|
|
|
107
|
-
qObj.await({ items: [0, 1] }).then(res => {
|
|
108
|
-
console.log(`1) done with items[0,1]: (${res})`.green)
|
|
109
|
-
}, err => {
|
|
110
|
-
console.log(`1) error[0, 1]: (${err})`.red)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
qObj.await({ items: [1, 2] }).then(res => {
|
|
114
|
-
console.log(`2) done with items[1,2]: (${res})`.green)
|
|
115
|
-
}, err => {
|
|
116
|
-
console.log(`2) error[1,2]: (${err})`.red)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
qObj.await({ items: [2, 1, 2] }).then(res => {
|
|
120
|
-
console.log(`3) done with items[2,1,2]: (${res})`.green)
|
|
121
|
-
}, err => {
|
|
122
|
-
console.log(`3) error[2, 1, 2]: (${err})`.red)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
qObj.await({ items: [2, 3] }).then(res => {
|
|
126
|
-
console.log(`4) done with item[2, 3]: (${res})`.green)
|
|
127
|
-
}, err => {
|
|
128
|
-
console.log(`4) error[2, 3]: (${err})`.red)
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
qObj.await({ items: [0] }).then(res => {
|
|
132
|
-
console.log(`5) done with item[0]: (${res})`.green)
|
|
133
|
-
}, err => {
|
|
134
|
-
console.log(err.red)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
qObj.getObjectById(200).ping()
|
|
138
|
-
|
|
139
|
-
qObj.await({ byIds: [300, 200, 100] }).then(res => {
|
|
140
|
-
console.log(`6) done with byId: [300, 200, 100] (${res})`.bold.italic.underline.yellow)
|
|
141
|
-
}, err => {
|
|
142
|
-
console.log(`6) error[300, 200, 100]: (${err})`.red)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
qObj.await({ byIds: [100, 300] }).then(res => {
|
|
146
|
-
console.log(`7) done with byId: [100, 300] (${res})`.bold.italic.underline.yellow)
|
|
147
|
-
}, err => {
|
|
148
|
-
console.log(`7) error[100, 300]: (${err})`.red)
|
|
149
|
-
})
|
|
150
|
-
|
|
151
109
|
qObj.process().then(res => {
|
|
152
|
-
console.log(`
|
|
110
|
+
console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
|
|
153
111
|
}, err => {
|
|
154
|
-
console.log(`
|
|
112
|
+
console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
|
|
155
113
|
})
|
|
156
114
|
|
|
157
115
|
```
|
package/package.json
CHANGED