
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
Promise queue for concurrency control
$ npm i enqueu
or
<script src="https://unpkg.com/enqueu@1.0.0/dist/index.js"></script>
In this case you will get "hey, my name is yoann, how are you ?, bye" and without Enqueu "my name is yoann, bye, how are you ?, hey".
import Enqueu from "enqueu";
const queu = new Enqueu();
queu
.add(() => new Promise((r) => setTimeout(r, 3000)))
.then((_) => console.log("hey"));
queu
.add(() => new Promise((r) => setTimeout(r, 2000)))
.then((_) => console.log("how are you ?"));
queu
.add(() => new Promise((r) => setTimeout(r, 1000)))
.then((_) => console.log("bye"));
queu
.add(() => new Promise((r) => setTimeout(r, 500)), { priority: 1 }) //from 1 to Infinity
.then((_) => console.log("my name is Yoann"));
For example in this case if you click 4 times at once on the button you will get "10, 5, 2.5". But without Enqueu you will get "1.25, 1.25, 1.25, 1.25".
const queu = new Enqueu({ maxSize: 3 }); //the maximum size of the queu is 3 (other will be throwed off)
let count = 20;
document.querySelector("button").addEventListener(
"click",
queu.createFn(function () {
count = count / 2;
return new Promise((r) =>
setTimeout(function () {
r(count);
}, count * 1000)
);
})
);
maxSize Max size of the queumaxConcurrency Max promise as the same timeisPaused Return a boolean to see if the queu is paused or notpending Return the number of pending functionsqueu Return the queuadd(fn: Function, options: Options = {}): Function Add the function to the queucreateFn(fn: Function, options: Options = {}): Function Create a function that will add "fn" to the queu on call (useful for addEventListener for example)pause() Pause the queustart() Start the queu after a pauseonEmpty(fn: Function) Call the function passed as argument when the queu is emptyonQueuElementExecuted(fn: Function) Call the function passed as argument when the a new queu function is startedonQueuElementFinishExecution(fn: Function) Call the function passed as argument when the a new queu function which started is finishedclear() Clear the queuremove(fn: Function) Remove a function from the queuremoveFromIndex(index: number) Remove a specified indexed element in the queuFAQs
Promise queue for concurrency control
The npm package enqueu receives a total of 3 weekly downloads. As such, enqueu popularity was classified as not popular.
We found that enqueu demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.