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 4.3.2 to 4.4.0

lib/appenders/sync.js

34

app.js

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

top_one = require('./lib/appenders/top_one'),
bottom_one = require('./lib/appenders/bottom_one')
bottom_one = require('./lib/appenders/bottom_one'),
sync = require('./lib/appenders/sync')

@@ -22,7 +23,2 @@ class QueueObj {

t.props = {}
t.load = t.load.bind(this)
t.process = t.process.bind(this)
t.getParent = t.getParent.bind(this)
t.getObjectToProcess = t.getObjectToProcess.bind(this)
t.getObjectById = t.getObjectById.bind(this)
t.all = null

@@ -32,2 +28,3 @@ t.top_one = null

t.array = null
t.sync = null
t.func_all = null

@@ -37,2 +34,9 @@ t.objs = []

t.reject = null
t.load = t.load.bind(this)
t.process = t.process.bind(this)
t.await = t.await.bind(this)
t.getParent = t.getParent.bind(this)
t.getObjectToProcess = t.getObjectToProcess.bind(this)
t.getObjectById = t.getObjectById.bind(this)
return t

@@ -51,3 +55,3 @@ } catch (e) {

t.objs[i].id == id) {
return t.objs[i]
return t.objs[i]
}

@@ -104,2 +108,5 @@ }

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

@@ -148,2 +155,4 @@ throw new Error(`appender(${props.appender}) not found`)

return t.array.process(props)
case 'sync':
return t.sync.process(props)
default:

@@ -158,2 +167,13 @@ throw new Error(`nothing to process`)

}
await(props) {
try {
var t = this
return t.sync.add(props)
} catch (e) {
e.message = "queueObj app.js load error: " + e.message
console.log(e.message)
throw (e)
}
}
}

@@ -160,0 +180,0 @@

@@ -13,3 +13,3 @@ /*

var t = this
t.aname = 'all.js'
t.aname = 'array.js'
t.process_props = []

@@ -27,3 +27,2 @@ t.process = t.process.bind(this)

return t.process_all(pop)
}

@@ -30,0 +29,0 @@

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

},
"version": "4.3.2",
"version": "4.4.0",
"bundleDependencies": false,

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

@@ -6,7 +6,8 @@ # QueueObj

* all - process all added objects.
* func_all - process custom functions to added objects.
* top_one - process only the object in the 0(zero) position of the process array.
* bottom_one - process only the object in the last position of the process array.
* array - process object in various ways: all, by items, or by Ids.
* all - asynchronous - process all added objects.
* func_all - asynchronous - process custom functions to added objects.
* top_one - asynchronous - process only the object in the 0(zero) position of the process array.
* bottom_one - asynchronous - process only the object in the last position of the process array.
* array - asynchronous - process object in various ways: by items, or by Ids.
* sync - synchronous - process object in various ways: by items, or by Ids.

@@ -42,5 +43,9 @@ Installation

var queue = require("QueueObj");
var queue = require("./app.js");
class test1 {
constructor() {
this.id = 100
}
process(callback) {

@@ -53,3 +58,3 @@ console.log(`processing test1`.cyan)

class test2 {
constructor(){
constructor() {
this.id = 200

@@ -63,3 +68,3 @@ }

ping(){
ping() {
console.log('hello from test2'.rainbow)

@@ -70,2 +75,6 @@ }

class test3 {
constructor() {
this.id = 300
}
process(callback) {

@@ -77,34 +86,40 @@ console.log(`processing test3`.cyan)

let qObj = new queue(), props = { appender: 'array' }
let qObj = new queue(), props = { appender: 'sync' }
qObj.load(props).add(new test1()).add(new test2()).add(new test3())
qObj.process({ items: [0, 1] }).then(res => {
console.log(`done with items[0,1]`.green)
qObj.await({ items: [0, 1] }).then(res => {
console.log(`1) done with items[0,1]`.green)
})
qObj.process({ items: [1, 2] }).then(res => {
console.log(`done with items[1,2]`.green)
qObj.await({ items: [1, 2] }).then(res => {
console.log(`2) done with items[1,2]`.green)
})
qObj.process({ items: [2, 1, 2] }).then(res => {
console.log(`done with items[2,1,2]`.green)
qObj.process({ items: [2] }).then(res => {
console.log(`done with item[2]`.green)
qObj.process({ items: [6] }).then(res => {
console.log(`done with item[6]`.green)
}, err => {
console.log(err.red)
})
})
})
})
qObj.await({ items: [2, 1, 2] }).then(res => {
console.log(`3) done with items[2,1,2]`.green)
})
qObj.await({ items: [2] }).then(res => {
console.log(`4) done with item[2]`.green)
})
qObj.await({ items: [0] }).then(res => {
console.log(`5) done with item[0]`.green)
}, err => {
console.log(err.red)
})
qObj.getObjectById(200).ping()
qObj.process({ byIds: [100, 300] }).then(res => {
console.log(`done with byId: [100, 300]`.bold.italic.underline.yellow)
qObj.await({ byIds: [300, 200, 100] }).then(res => {
console.log(`6) done with byId: [300, 200, 100] (${res})`.bold.italic.underline.yellow)
})
qObj.await({ byIds: [300] }).then(res => {
console.log(`7) done with byId: [300] (${res})`.bold.italic.underline.yellow)
})
qObj.process().then(res => {
console.log(`done with all processing`.bold.italic.underline.green)
console.log(`8) done with all sync processing`.bold.italic.white)
})

@@ -111,0 +126,0 @@

@@ -0,1 +1,7 @@

/*
* @author Jim Manton: jrman@risebroadband.net
* @since 2021-03-22
* test_array.js
*/
var colors = require('colors')

@@ -6,2 +12,6 @@

class test1 {
constructor(){
this.id = 100
}
process(callback) {

@@ -29,2 +39,6 @@ console.log(`processing test1`.cyan)

class test3 {
constructor() {
this.id = 300
}
process(callback) {

@@ -50,4 +64,4 @@ console.log(`processing test3`.cyan)

console.log(`done with item[2]`.green)
qObj.process({ items: [6] }).then(res => {
console.log(`done with item[6]`.green)
qObj.process({ items: [1] }).then(res => {
console.log(`done with item[1]`.green)
}, err => {

@@ -70,2 +84,1 @@ console.log(err.red)

})

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

"dependencies": {
"chai": "^4.3.3",
"chai": "^4.4.0",
"colors": "^1.4.0",

@@ -15,0 +15,0 @@ "compare-json-difference": "^0.1.3",

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