New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nerimity/mimiqueue

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nerimity/mimiqueue - npm Package Compare versions

Comparing version 1.2.3 to 2.0.0

example/index.mjs

2

package.json
{
"name": "@nerimity/mimiqueue",
"version": "1.2.3",
"version": "2.0.0",
"description": "NodeJS group queuing library. Requires Redis.",

@@ -5,0 +5,0 @@ "main": "dist/index.mjs",

# Mimiqueue
### Features
- Cluster Support
- Redis Required
- Group Queuing
- Throttle Support (minTime)
### Installation

@@ -12,4 +19,4 @@

```ts
import { createQueue, createQueueProcessor } from "@nerimity/mimiqueue";
import { createClient } from "redis";
import { Queue } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";

@@ -24,91 +31,37 @@

await redisClient.connect();
await redisClient.flushAll();
const main = async () => {
await redisClient.connect();
const addFriendQueue = new Queue({
redisClient,
name: "addFriend",
process: async (data) => {
await setTimeout(2000);
return { done: "lol", data };
},
});
// NOTE:
// When running in a cluster, this needs to be ran ONCE in the main thread.
await createQueueProcessor({
redisClient,
});
addFriendQueue.add({ someData: 1 }, { groupName: "1234" }).then((res) => {
console.log(res);
});
addFriendQueue.add("hello", { groupName: "1234" }).then((res) => {
console.log(res);
});
addFriendQueue.add(123).then((res) => {
console.log(res);
});
```
const queue = await createQueue({
name: "test-queue",
redisClient,
minTime: 1000,
});
## Alt Usage
queue.add(
async () => {
await setTimeout(5000);
return "done";
},
{ groupName: "someId eg ip address" }
);
```ts
import { createClient } from "redis";
import { AltQueue } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";
const status = await queue.add(
async () => {
await setTimeout(5000);
return "done";
},
{ groupName: "someId eg ip address" }
);
const redisClient = createClient({
socket: {
host: "127.0.0.1",
port: 6379,
},
});
console.log(status);
};
await redisClient.connect();
await redisClient.flushAll();
const queue = new AltQueue({
redisClient,
name: "addFriend",
});
async function doSomething(groupName) {
const done = await queue.start({ groupName });
console.log("doing something");
await setTimeout(1000);
done();
}
doSomething("123");
doSomething("123");
main();
```
## Alt 2 Usage
```ts
import { createClient } from "redis";
import { AltQueue2 } from "@nerimity/mimiqueue";
import { setTimeout } from "timers/promises";
const redisClient = createClient({
socket: {
host: "127.0.0.1",
port: 6379,
},
});
await redisClient.connect();
await redisClient.flushAll();
const queue = new AltQueue2({
redisClient,
name: "addFriend",
});
async function queueDoSomething(groupName) {
queue.add(() => doSomething(groupName), { groupName });
}
async function doSomething(groupName) {
console.log("doing something");
await setTimeout(1000);
}
queueDoSomething("123");
queueDoSomething("123");
```

@@ -1,4 +0,2 @@

export * from "./Queue";
export * from "./AltQueue";
export * from "./AltQueue2";
export * from "./Timeout";
export { createQueue } from "./createQueue";
export { createQueueProcessor } from "./createQueueProcessor";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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