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

qyu

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qyu - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

2

package.json
{
"name": "qyu",
"version": "0.2.1",
"version": "0.3.0",
"description": "A general-purpose asynchronous job queue for Node.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -17,13 +17,17 @@ const

const makeQyuProxy = inst => {
const makeQyuProxy = q => {
return new Proxy(
function() {
return inst.add(...arguments);
if (arguments[0] instanceof Array) {
return q.map(arguments[0], arguments[1], arguments[2]);
} else {
return q.add(arguments[0], arguments[1]);
}
},
{
get: (target, prop, receiver) => {
return inst[prop];
return q[prop];
},
set: (obj, prop, value) => {
inst[prop] = value;
q[prop] = value;
return true;

@@ -35,3 +39,2 @@ }

class Qyu {

@@ -207,8 +210,11 @@ constructor(opts={}, job=null, jobOpts={}) {

map(arr, fn) {
return Promise.all(
arr.map((v, k) => {
return this.add(() => fn(v, k));
})
);
map(iterator, fn) {
let counter = 0;
let promises = [];
for (let item of iterator) {
promises.push(
this.add(() => fn(item, counter++))
);
}
return Promise.all(promises);
}

@@ -215,0 +221,0 @@

@@ -14,3 +14,2 @@ const { Qyu, QyuError } = require('../index');

describe('When A Qyu instance is invoked as a function', () => {

@@ -20,2 +19,15 @@ it("should behave exactly like calling it's `add` method", () => {

});
// it('...', () => {
// let q = new Qyu({concurrency: 2});
//
// let job1 = jest.fn(mockAsync);
// let job2 = jest.fn(mockAsync);
//
// q(job1);
// q(job2);
//
// expect(job1).toHaveBeenCalled();
// expect(job2).toHaveBeenCalled();
// });
});

@@ -148,2 +160,12 @@

});
// it('...', () => {
// let q = new Qyu({concurrency: 3});
//
// q.map(['a', 'b', 'c'], async (v, k) => {
// console.log('START', k, JSON.stringify(v), Date.now());
// await mockAsync(null, 1000);
// console.log('END', k, JSON.stringify(v), Date.now());
// });
// });
});

@@ -150,0 +172,0 @@

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