Comments (3)
I've included a small example:
import { Queue } from 'moderndash';
const promiseToTime = (time: number, value) =>
new Promise((resolve, reject) => {
setTimeout(() => resolve(value), time);
});
(async () => {
let a;
// Create a queue that can run 3 tasks concurrently
const queue = new Queue(3);
queue.add(async () => {
a = await promiseToTime(2000, 'a');
});
queue.add(() => promiseToTime(1000, 'b'));
queue.add([
() => promiseToTime(3000, 'c').then((val) => (a = val)),
() => promiseToTime(0, 'd'),
]);
console.log(a); // undefined
await queue.magicFunction(); // waits until all the promises in the queue get resolved
console.log(a); // 'a'
})();
from moderndash.
@jupardo @chris-feist how about this? #107
from moderndash.
LGTM. Although its not clear from the docs how rejections are handled for Queue.add
and Queue.done
, so a minor suggestion would be to update that too
from moderndash.
Related Issues (20)
- T39 Decorators
- Switch to mutations instead of copy HOT 1
- `takeRightWhile` | Improve performance HOT 1
- `set` | Incorrect type if value is replaced by array
- Non-constructing `object.set`
- Shouldn't `hotscript` be in the main dependencies since it's imported in `dist/index.d.ts`? HOT 2
- Bundle hotscript types HOT 1
- Feature request - `mergeWith` HOT 3
- Feature request: debounce.pending() HOT 2
- Feature request - `deepFreeze` HOT 1
- Return the result of the last `throttle` invocation HOT 3
- Feature request - `curry`
- PlainObject not working with Interfaces HOT 3
- Feature request - `truncate` HOT 2
- Deprecate array `group` HOT 2
- Feature request - Array/concat HOT 5
- Feature request - clone HOT 3
- Feature request - cloneDeep HOT 2
- Package isn't truly zero dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moderndash.