{"id":28192170,"url":"https://github.com/4i8/queuex","last_synced_at":"2025-05-16T11:12:07.892Z","repository":{"id":244589957,"uuid":"815688070","full_name":"4i8/queuex","owner":"4i8","description":"Queuex simplifies managing tasks in sequence, making it easy to handle various operations one after another. Whether you're processing data or handling requests, Queuex ensures tasks are organized and executed efficiently, streamlining your workflow.","archived":false,"fork":false,"pushed_at":"2024-06-15T20:55:30.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-09T18:05:01.950Z","etag":null,"topics":["asynchronous-task-management","commonjs","ecmascript-modules","sequential-processing","task-automation","task-queue","task-scheduling","workflow-management"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4i8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-15T20:54:59.000Z","updated_at":"2024-06-15T20:56:56.000Z","dependencies_parsed_at":"2024-06-15T21:45:58.640Z","dependency_job_id":"eea82fdb-c25b-4c7f-8140-3a8f019a72fb","html_url":"https://github.com/4i8/queuex","commit_stats":null,"previous_names":["4i8/queuex"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4i8%2Fqueuex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4i8%2Fqueuex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4i8%2Fqueuex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4i8%2Fqueuex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4i8","download_url":"https://codeload.github.com/4i8/queuex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518328,"owners_count":22084376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous-task-management","commonjs","ecmascript-modules","sequential-processing","task-automation","task-queue","task-scheduling","workflow-management"],"created_at":"2025-05-16T11:12:07.827Z","updated_at":"2025-05-16T11:12:07.886Z","avatar_url":"https://github.com/4i8.png","language":"TypeScript","readme":"# **queuex**\n\n**Queuex simplifies managing tasks in sequence, making it easy to handle various operations one after another. Whether you're processing data or handling requests, Queuex ensures tasks are organized and executed efficiently, streamlining your workflow.**\n\n\u003cdiv align=\"center\"\u003e\n  \u003cp\u003e\n \u003ca href=\"https://www.npmjs.com/package/queuex\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/queuex.svg?style=for-the-badge\" alt=\"NPM version\" /\u003e\u003c/a\u003e\n \u003ca href=\"https://www.npmjs.com/package/queuex\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/queuex.svg?maxAge=3600\u0026style=for-the-badge\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\n \u003ca href=\"https://github.com/4i8/queuex.git\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/github-black?style=for-the-badge\u0026logo=github\u0026logoColor=white\" alt=\"github\"/\u003e\n  \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Table of Contents\n\n- [Compatibility](#compatibility)\n- [Installation](#installation)\n- [Example](#example)\n  - [CommonJS](#commonjs)\n  - [ES6](#es6)\n  - [What is the use of a namespace?](#what-is-the-use-of-a-namespace)\n- [API](#api)\n  - [constructor(namespace, callback)](#constructornamespace-callback)\n  - [next()](#next)\n  - [push(task)](#pushtask)\n  - [concat(tasks)](#concattasks)\n  - [kill()](#kill)\n- [License](#license)\n\n## Compatibility\n\n- **ECMAScript Modules (ESM)**\n- **CommonJS (CJS)**\n- **Bun**\n\n# **Installation**\n\n```sh-session\nnpm install queuex\nyarn add queuex\n```\n\n# **Example**\n\n## Note\n\nEvery push() or concat() will start your queuex if it is not already running so you don't have to worry about starting it manually\n\n### CommonJS\n\nthis is just an example, you can use queuex for anything\n\n```js\nconst Queuex = require(\"queuex\");\n\nconst namespace = new Queuex(\"namespace\", (value, next, index) =\u003e {\n  // Simulate an asynchronous task using setTimeout\n  console.log(`Task ${index + 1}: ${value.message}`);\n  setTimeout(() =\u003e {\n    console.log(`Completed task ${index + 1}`);\n    next(); // when you are done, call next() to move to the next task\n  }, value.delay);\n});\n\nlet tasks = [\n  {\n    message: \"This is task 1\",\n    delay: 1000, // 1 second delay\n  },\n  {\n    message: \"This is task 2\",\n    delay: 500, // 0.5 second delay\n  },\n  {\n    message: \"This is task 3\",\n    delay: 2000, // 2 seconds delay\n  },\n];\n\n// concat is a method that adds an array of items to the namespace queue\nnamespace.concat(tasks);\n\n// push is a method that adds a single item to the namespace queue\nnamespace.push({\n  message: \"This is task 4\",\n  delay: 1500, // 1.5 seconds delay\n});\n// every push or concat will start the namespace if it is not already running\n```\n\n### ES6\n\nthis is just an example, you can use queuex for anything\n\n```js\nimport Queuex from \"queuex\";\nconst namespace = new Queuex(\"namespace\", (value, next, index) =\u003e {\n  // Simulate an asynchronous task using setTimeout\n  console.log(`Task ${index + 1}: ${value.message}`);\n  setTimeout(() =\u003e {\n    console.log(`Completed task ${index + 1}`);\n    next(); // when you are done, call next() to move to the next task\n  }, value.delay);\n});\n\nlet tasks = [\n  {\n    message: \"This is task 1\",\n    delay: 1000, // 1 second delay\n  },\n  {\n    message: \"This is task 2\",\n    delay: 500, // 0.5 second delay\n  },\n  {\n    message: \"This is task 3\",\n    delay: 2000, // 2 seconds delay\n  },\n];\n\n// concat is a method that adds an array of items to the namespace queue\nnamespace.concat(tasks);\n\n// push is a method that adds a single item to the namespace queue\nnamespace.push({\n  message: \"This is task 4\",\n  delay: 1500, // 1.5 seconds delay\n});\n// every push or concat will start the namespace if it is not already running\n```\n\n### What is the use of a namespace?\n\nTo avoid throwing errors, do not use the same namespace more than once in the same process.\n\n#### `test/index.js`\n\n```js\nconst tools = new queuex(\"tools\", async (value, next, index) =\u003e {\n  // do something...\n  console.log(value);\n  next(); //hello2\n});\ntools.push(\"hello\");\n```\n\n#### `test/inside/tools.js`\n\n**to index.js in your queuex instance named tools**\n\n```js\nconst tools = new queuex(\"tools\");\ntools.push(\"hello2\");\n//or\ntools.concat([\"hello2\", \"hello3\"]);\n```\n\n# API\n\n\u003cp\u003e\u003cstrong\u003e queuex provides the following methods:\u003c/strong\u003e\n\n\u003e ##### `constructor(namespace, callback)`\n\u003e\n\u003e Creates a new instance of the queuex class with the provided namespace and callback function.\n\n- namespace (string) - The namespace for the Queuex sequence.\n- callback (Function) - The callback function that takes a value, a next function, and an index as parameters.\n\n\u003e #### `next()`\n\u003e\n\u003e Moves the Queuex sequence to the next task and runs it.\n\n\u003e #### `push(task)`\n\u003e\n\u003e Adds a new task to the end of the Queuex sequence.\n\n- task (any) - The task to add to the Queuex sequence.\n\n\u003e #### `concat(tasks)`\n\u003e\n\u003e Adds an array of tasks to the end of the Queuex sequence.\n\n- tasks (Array) - The array of tasks to add to the Queuex sequence.\n\n\u003e #### `kill()`\n\u003e\n\u003e Stops the current Queuex sequence and prevents any remaining tasks from running.\n\n# License\n\nqueuex is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)\n\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4i8%2Fqueuex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4i8%2Fqueuex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4i8%2Fqueuex/lists"}