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.0 to 0.2.1

2

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

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

@@ -205,28 +205,6 @@ const

// async map(iterator, fn, opts={}) {
// let k = 0;
// let promises = [];
// for (let v of iterator) {
// promises.push(
// this.add(opts, () => fn(v, k))
// );
// ++k;
// }
// return Promise.all(promises);
// }
// async map(arr, fn, opts={}) {
// let promises = [];
// for (let i=0; i<arr.length; ++i) {
// promises.push(
// this.add(opts, fn(arr[i], i))
// );
// }
// return Promise.all(promises);
// }
async map(arr, fn, opts={}) {
map(arr, fn) {
return Promise.all(
arr.map((v, k) => {
return this.add(opts, () => fn(v, k));
return this.add(() => fn(v, k));
})

@@ -233,0 +211,0 @@ );

@@ -15,28 +15,7 @@ const { Qyu, QyuError } = require('../index');

// describe('...', () => {
// it('...', () => {
// let qyu = new Qyu({concurrency: 2});
//
// let job1 = jest.fn(mockAsync);
// let job2 = jest.fn(mockAsync);
//
// qyu(job1);
// qyu(job2);
//
// expect(job1).toHaveBeenCalled();
// expect(job2).toHaveBeenCalled();
// });
//
// it('...', () => {
// let qyu = new Qyu({concurrency: 3});
//
// // let job1 = jest.fn(mockAsync);
// // let job2 = jest.fn(mockAsync);
//
// qyu.map(['a', 'b', 'c'], async (v, k) => {
// await mockAsync();
// console.log('v, k', v, k);
// });
// });
// });
describe('When A Qyu instance is invoked as a function', () => {
it("should behave exactly like calling it's `add` method", () => {
// ...
});
});

@@ -61,3 +40,3 @@ describe('`add` method', () => {

q.add(() => mockAsync());
q.add(mockAsync);
q.add(job);

@@ -157,2 +136,16 @@

describe('`map` method', () => {
// it("invokes the second argument for each item in the first argument with two arguments in itself: the item and it's index", () => {
it("...", () => {
let q = new Qyu({concurrency: 3});
let items = ['A', 'B', 'C'];
let fn = jest.fn();
q.map(items, fn);
expect(fn).toHaveBeenCalledTimes(3);
expect(fn).toHaveBeenCalledWith('C', 2);
});
});
describe('`whenEmpty` method', () => {

@@ -159,0 +152,0 @@ it('should return a promise', () => {

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