Comparing version 0.2.0 to 0.2.1
{ | ||
"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', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
19612
470