{"id":20741100,"url":"https://github.com/robtimus/fifo-process-queue","last_synced_at":"2025-04-24T02:53:54.666Z","repository":{"id":57157241,"uuid":"115534999","full_name":"robtimus/fifo-process-queue","owner":"robtimus","description":"A queue for processing data in FIFO order","archived":false,"fork":false,"pushed_at":"2025-01-04T14:20:47.000Z","size":283,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T02:53:47.995Z","etag":null,"topics":["fifo","javascript","queue"],"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/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-12-27T15:40:41.000Z","updated_at":"2025-01-04T14:20:50.000Z","dependencies_parsed_at":"2023-02-15T23:10:16.635Z","dependency_job_id":"8f5baba4-58f4-4a4e-8de0-1344224c655b","html_url":"https://github.com/robtimus/fifo-process-queue","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Ffifo-process-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Ffifo-process-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Ffifo-process-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Ffifo-process-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/fifo-process-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250552038,"owners_count":21449162,"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":["fifo","javascript","queue"],"created_at":"2024-11-17T06:33:47.342Z","updated_at":"2025-04-24T02:53:54.651Z","avatar_url":"https://github.com/robtimus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fifo-process-queue\n[![npm](https://img.shields.io/npm/v/fifo-process-queue)](https://www.npmjs.com/package/fifo-process-queue)\n[![Build Status](https://github.com/robtimus/fifo-process-queue/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/fifo-process-queue/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=robtimus%3Afifo-process-queue\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=robtimus%3Afifo-process-queue)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=robtimus%3Afifo-process-queue\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=robtimus%3Afifo-process-queue)\n[![Known Vulnerabilities](https://snyk.io/test/github/robtimus/fifo-process-queue/badge.svg)](https://snyk.io/test/github/robtimus/fifo-process-queue)\n\nA queue for processing data in FIFO order.\n\nProcess queues can run in one of two modes:\n\n### FIFO processing mode\n\nIn _FIFO processing_ mode, pieces of data are processed one at a time. Only when the previous piece of data has been processed will the next piece of data be processed.\n\nTo create a queue in FIFO processing mode, provide only a _processor_ function. This function must take two arguments:\n* The data to process. This is the data that was pushed onto the queue.\n* A callback function. When the processing is done, this non-argument callback _must_ be called.\n\nExample:\n```js\nvar FIFOProcessQueue = require('fifo-process-queue');\n\nvar queue = FIFOProcessQueue(function (data, callback) {\n    console.log('Processing', data);\n\n    setTimeout(function () {\n        console.log('Finished', data);\n        callback();\n    }, 100);\n});\n\nqueue.push(1);\nqueue.push(2);\nqueue.pushAll([3, 4, 5]);\n```\n\n### FIFO post-processing mode\n\nIn _FIFO post-processing_ mode, pieces of data may be processed in parallel. However, after a piece of data has been processed, a _post-processor_ function is called for the piece of data. Invocations of this post-processor function are performed in FIFO order.\n\nTo create a queue in FIFO post-processing mode, provide not only a processor function (see above), but also a post-processor function. This function must take one argument:\n* The data to process. This is the data that was pushed onto the queue.\n\nIn addition, the maximum number of concurrenty processed pieces of data can be given (at least 1). If this is omitted the queue will not impose any limits.\n\nExample:\n```js\nvar FIFOProcessQueue = require('fifo-process-queue');\n\nvar queue = FIFOProcessQueue(function (data, callback) {\n    console.log('Processing', data);\n\n    setTimeout(function () {\n        console.log('Finished', data);\n        callback();\n    }, 100);\n}, function (data) {\n    console.log('Post-processing', data);\n}, 10); // maximum 10 pieces of data processed concurrently; optional value\n\nqueue.push(1);\nqueue.push(2);\nqueue.pushAll([3, 4, 5]);\n```\n\n## Using in browsers\n\nBesides using tools like [Browserify](http://browserify.org/), you can also simply include file `index.js` in a script tag. This will register a global function `FIFOProcessQueue` which can be used to create process queues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Ffifo-process-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Ffifo-process-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Ffifo-process-queue/lists"}