Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

queueobj

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queueobj - npm Package Compare versions

Comparing version 7.2.4 to 8.0.0

lib/appenders/version.js

146

app.js

@@ -13,3 +13,4 @@ /* @author Jim Manton: jrman@risebroadband.net

sync_all = require('./lib/appenders/sync_all'),
status = require('./lib/appenders/status')
status = require('./lib/appenders/status'),
version = require('./lib/appenders/version')

@@ -28,4 +29,4 @@ class QueueObj {

t.array = null
t.sync = null
t.status = null
t.version = null
t.stats = false

@@ -52,6 +53,6 @@ t.sync_all = null

getStats (){
getStats() {
return this.stats
}
getObjectById(id) {

@@ -81,9 +82,21 @@ let t = this, i

getObjectByVersion(version) {
let t = this, i
for (i = 0; i < t.objs.length; i++) {
if (typeof t.objs[i] != 'undefined' &&
typeof t.objs[i].version != 'undefined' &&
t.objs[i].version == version) {
return t.objs[i]
}
}
return null
}
count() {
return t.objs.length
return this.objs.length
}
get(num) {
if (num < t.objs.length)
return t.objs[num]
if (num < this.objs.length)
return this.objs[num]
return false

@@ -108,3 +121,3 @@ }

t.props = props
t.stats = (typeof props.stats != 'undefined') ? props.stats : false;
t.stats = (typeof props.stats != 'undefined') ? props.stats : false;
if (typeof props != `undefined` &&

@@ -114,3 +127,3 @@ typeof props.appender != `undefined` &&

props.getParent = t.getParent
switch (props.appender) {
switch (props.appender) {
case 'all':

@@ -134,5 +147,7 @@ t.all = new all(props)

break
case 'sync':
case 'version':
t.version = new version(props)
break
case 'sync_all':
t.sync = new sync(props)
t.sync_all = new sync_all(props)
break

@@ -152,4 +167,46 @@ default:

add(obj) {
var t = this
try {
var t = this
if (t.all != null) {
obj.getType = (o) => {
return 'all'
}
}
if (t.top_one != null) {
obj.getType = (o) => {
return 'top_one'
}
}
if (t.bottom_one != null) {
t.objs = []
obj.getType = (o) => {
return 'bottom_one'
}
}
if (t.func_all != null) {
obj.getType = (o) => {
return 'func_all'
}
}
if (t.sync_all != null) {
obj.getType = (o) => {
return 'sync_all'
}
}
if (typeof obj.status != 'undefined') {
obj.getType = (o) => {
return o.status
}
}
if (typeof obj.version != 'undefined') {
obj.getType = (o) => {
return o.version
}
}
if (t.top_one != null) {
if (t.objs.length == 0) {
t.objs.push(obj)
}
return t
}
t.objs.push(obj)

@@ -159,3 +216,3 @@ return t

e.message = "queueObj app.js add error: " + e.message
console.log(e.message)
console.log(e.message.red)
throw (e)

@@ -175,36 +232,39 @@ }

try {
var t = this, pro = { items: [] }
switch (t.props.appender) {
var t = this, pro = { dat_array: [] }
switch (t.props.appender) {
case 'all':
t.objs.map((item, i) => {
pro.items.push(i)
})
pro.dat_array.push('all')
t.all.await(pro)
return t.all.process()
case 'top_one':
pro.items = [0]
pro.dat_array.push('top_one')
t.top_one.await(pro)
return t.top_one.process()
case 'bottom_one':
pro.items = [pro.items.length - 1]
pro.dat_array.push('bottom_one')
t.bottom_one.await(pro)
return t.bottom_one.process()
case 'func_all':
t.objs.map((item, i) => {
pro.items.push(i)
})
pro.dat_array.push('func_all')
t.func_all.await(pro)
return t.func_all.process()
case 'sync':
return t.sync.process()
case 'sync_all':
pro.dat_array.push('sync_all')
t.sync_all.await(pro)
return t.sync_all.process()
case 'status':
return t.status.process()
case 'sync_all':
t.objs.map((item, i) => {
pro.items.push(i)
})
t.sync.await(pro).then(res => {
console.log(`done with ${JSON.stringify(pro)}: (${res})`.green)
}, err => {
console.log(`error ${JSON.stringify(pro)}: (${err})`.red)
})
return t.sync.process()
case 'version':
return t.version.process()
// case 'sync_all':
// t.objs.map((item, i) => {
// pro.items.push(i)
// })
// t.sync.await(pro).then(res => {
// console.log(`done with ${JSON.stringify(pro)}: (${res})`.green)
// }, err => {
// console.log(`error ${JSON.stringify(pro)}: (${err})`.red)
// })
// return t.sync.process()
default:

@@ -215,3 +275,3 @@ throw new Error(`nothing to process`)

e.message = "queueObj app.js load error: " + e.message
console.log(e.message)
console.log(e.message.red)
throw (e)

@@ -222,8 +282,16 @@ }

await(props) {
var t = this, pro
try {
var t = this
if (t.sync != null)
if (t.sync != null) {
pro = { dat_array: props.items }
return t.sync.await(props)
if (t.status != null)
return t.status.await(props)
}
if (t.status != null) {
pro = { dat_array: props.status }
return t.status.await(pro)
}
if (t.version != null) {
pro = { dat_array: props.version }
return t.version.await(pro)
}
} catch (e) {

@@ -230,0 +298,0 @@ e.message = "queueObj app.js load error: " + e.message

@@ -12,8 +12,7 @@ /*

let t = this
t.props_array = []
t.await_array = []
t.resolve_array = []
t.reject_array = []
t.status_props_array = []
t.process_item = -1
t.process_array_item = -1
t.process_objs_item = 0
t.process_props_item = 0
t.any_errors = false

@@ -28,5 +27,6 @@ t.getParent = props.getParent

await(props) {
let t = this
t.props_array.push(props)
t.await_array.push(props)
return new Promise((resolve, reject) => {

@@ -40,6 +40,7 @@ t.resolve_array.push(resolve)

let t = this
t.process_item = 0
t.process_array_item = 0
t.process_objs_item = 0
t.process_props_item = 0
t.await_item = 0
t.dt_start = new Date(); // start measuring time
// t.props_array = []
// t.await_array = []
// t.resolve_array = []

@@ -50,3 +51,2 @@ // t.reject_array = []

return new Promise((resolve, reject) => {
t.props_array.push({ the: 'end' })
t.resolve_array.push(resolve)

@@ -67,92 +67,103 @@ t.reject_array.push(reject)

process_all() {
let t = this, obj, xItems = null, pro, itm, msg
t.props_array.map((props, i) => {
if (i == t.process_item) {
if (typeof props != 'undefined' && typeof props.the != 'undefined' && props.the == 'end') {
if (t.any_errors)
t.reject_array[i](`there were errors`)
else {
t.dt_end = new Date();
t.resolve_array[i](t.getStats())
}
let t = this, obj, pro, itm, msg, itm_type, props_type, datA
try {
try {
if (t.process_objs_item >= t.getParent().getObjs().length) {
t.await_item++
t.resolve_array[t.resolve_array.length - 1](t.getStats())
return
}
} catch (e) {
return
}
try {
datA = t.await_array[t.await_item].dat_array
} catch (e) {
return
}
try {
if (typeof props != 'undefined') {
if (typeof props.items != 'undefined') {
xItems = props.items
itm = 'items'
}
if (typeof props.byIds != 'undefined') {
xItems = props.byIds
itm = 'byIds'
}
if (typeof props.status != 'undefined') {
xItems = []
if (t.status_props_array.length == 0) {
t.getParent().getObjs().map((aItem, i) => {
xItems.push(i)
})
}
itm = 'status'
}
}
datA.map((dat_item, i) => {
if (i == t.process_props_item) {
if (t.process_props_item < datA.length) {
if ((t.await_item) >= t.await_array.length) {
t.resolve_array[t.resolve_array.length - 1](t.getStats())
return
}
t.getParent().getObjs().map((pItem, x) => {
if (x == t.process_objs_item) {
try {
obj = t.getParent().getItemToProcess(x)
} catch (e) {
e.message = `base error: (${e.message})`
throw e
}
if (typeof obj != 'undefined' && typeof obj.getType != 'function') {
obj.getType = (o) => { return t.aname }
}
if (obj.getType(obj) == dat_item) {
try {
pro = (typeof obj == 'function') ? obj : obj.process;
} catch (e) {
console.log(`pro error: (${e.message})`.red)
throw e
}
if (xItems != null) {
xItems.map((pItem, x) => {
if (x == t.process_array_item) {
try {
switch (itm) {
case 'status':
case 'items':
obj = t.getParent().getItemToProcess(pItem)
break
case 'byIds':
obj = t.getParent().getObjectById(pItem);
break
}
} catch (e) {
console.log(`base error: (${e.message})`.red)
}
pro = (typeof obj == 'function') ? obj : obj.process;
if (itm == 'status') {
if (typeof pro != 'undefined' &&
typeof obj.status != 'undefined' &&
props.status.indexOf(obj.status) > -1) {
//do nothing
pro((obj_props) => {
try {
if (typeof obj_props != 'undefined' &&
typeof obj_props.error != 'undefined' &&
typeof obj_props.error.msg != 'undefined' &&
typeof obj_props.error.msg == 'string') {
msg = `error: ${obj_props.error.msg}`
msg += (typeof obj.id != 'undefined') ? ` id(${obj.id})` : ``;
t.any_errors = true
t.reject_array[t.process_props_item](msg)
}
t.process_objs_item++
if (t.process_props_item < datA.length) {
t.process_all()
} else {
t.dt_end = new Date();
t.resolve_array[t.process_props_item - 1](t.getStats())
t.process_props_item = 0
t.process_objs_item = 0
}
} catch (e) {
console.log(`proessing error: (${e.message})`.red)
throw e
}
})
} else {
t.process_objs_item++
if (t.process_objs_item >= t.getParent().getObjs().length) {
t.resolve_array[t.resolve_array.length - 1](t.getStats())
}
}
} else {
t.process_array_item++
if (t.process_array_item < xItems.length)
t.process_all()
return
if (t.process_objs_item >= t.getParent().getObjs().length) {
t.process_objs_item = 0
t.process_props_item++
if (t.process_props_item >= datA.length) {
t.await_item++
t.process_props_item = 0
if (t.await_item <= t.await_array.length)
t.process_all()
}
}
}
}
pro((obj_props) => {
if (typeof obj_props != 'undefined' &&
typeof obj_props.error != 'undefined' &&
typeof obj_props.error.msg != 'undefined' &&
typeof obj_props.error.msg == 'string') {
msg = `error: ${obj_props.error.msg}`
msg += (typeof obj.id != 'undefined') ? ` id(${obj.id})` : ``;
t.any_errors = true
t.reject_array[t.process_item](msg)
}
t.process_array_item++
if (t.process_array_item < xItems.length)
t.process_all()
else {
t.dt_end = new Date();
t.resolve_array[t.process_item](t.getStats())
t.process_item++
t.process_array_item = 0
}
})
}
})
}
}
})
} catch (e) {
e.message = `await error: ${e.message}`
throw e
}
})
} catch (e) {
console.log(`process_all error: ${e.message}`.red)
}
}
}

@@ -5,3 +5,3 @@ {

},
"version": "7.2.4",
"version": "8.0.0",
"bundleDependencies": false,

@@ -8,0 +8,0 @@ "dependencies": {

@@ -10,5 +10,5 @@ # QueueObj

* bottom_one - asynchronous - process only the object in the last position of the process array.
* sync - synchronous - process array objects in various ways: by items, by Ids as well as custom functions.
* sync_all - synchronous - queue and process all objects by items as well as custom functions.
* status - synchronous - queue and process all objects by status.
* version - synchronous - queue and process all objects by version.

@@ -34,5 +34,5 @@ Installation

node test_func_all
node test_sync
node test_sync_all
node test_status
node test_version

@@ -39,0 +39,0 @@ ```

@@ -26,22 +26,8 @@ var colors = require('colors')

let qObj = new queue(), props = { appender: 'bottom_one' }
let qObj = new queue(), props = { appender: 'bottom_one', stats: true}
qObj.load(props).add(new test1()).add(new test2()).add(new test3())
qObj.process().then(res => {
console.log(`done with 3rd obj`.green)
})
qObj.process().then(res => {
console.log(`done with 2nd obj`.green)
})
qObj.process().then(res => {
console.log(`done with 1st obj`.green)
})
qObj.process().then(res => {
console.log(`done with 1st obj`.green)
qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
console.log(res)
}, err => {
console.log(err.red)
console.log(`errors with bottom item processing: (${err})`.red)
})

@@ -44,4 +44,4 @@ var colors = require('colors')

qObj.load(props).add(tst1.some_function).add(tst2.a_func).add(tst3.cool).process().then(res => {
console.log(`done`)
console.log(`success processing`.green)
})

@@ -39,5 +39,5 @@ /*

t.status = "error"
callback({error: {msg: msg}}) //this will show errors
//t.status = "done"
//callback() //this will show no errors
// callback({error: {msg: msg}}) //this will show errors
t.status = "done"
callback() //this will show no errors
}

@@ -60,8 +60,6 @@

process(callback) {
setTimeout(()=>{
console.log(`processing test3`.cyan)
console.log(`some async process`)
this.status = "done"
callback()
}, 2000)
console.log(`processing test3`.cyan)
console.log(`some async process`)
this.status = "done"
callback()
}

@@ -75,2 +73,4 @@ }

t.status = "new"
t.process = t.process.bind(t)
}

@@ -80,2 +80,3 @@

console.log(`processing test4`.cyan)
this.status = "done"
callback()

@@ -82,0 +83,0 @@ }

@@ -72,3 +72,3 @@ /*

qObj.process().then(res => {
console.log(`done with all sync processing: (${res})`.bold.italic.white)
console.log(`done with all sync processing: (${res})`.bold.italic.blue)
}, err => {

@@ -75,0 +75,0 @@ console.log(`errors with all sync processing: (${err})`.red)

@@ -26,12 +26,8 @@ var colors = require('colors')

let qObj = new queue(), props = { appender: 'top_one'}
let qObj = new queue(), props = { appender: 'top_one', stats: true}
qObj.load(props).add(new test1()).add(new test2()).add(new test3())
qObj.process().then(res => {
console.log(`done with 1st obj`.green)
qObj.load(props).add(new test1()).add(new test2(qObj)).add(new test3()).process({}).then(res => {
console.log(res)
}, err => {
console.log(`errors with top item processing: (${err})`.red)
})
qObj.process().then(res => {
console.log(`done with 2nd obj`.green)
})

@@ -9,3 +9,3 @@ const assert = require('assert'),

},
"version": "7.2.4",
"version": "8.0.0",
"bundleDependencies": false,

@@ -12,0 +12,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc