{"id":16777046,"url":"https://github.com/fb55/simplequeue","last_synced_at":"2025-03-17T02:31:37.332Z","repository":{"id":1960969,"uuid":"2891493","full_name":"fb55/SimpleQueue","owner":"fb55","description":"A simple FIFO queue","archived":false,"fork":false,"pushed_at":"2024-12-05T06:59:02.000Z","size":988,"stargazers_count":9,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-06T18:32:14.969Z","etag":null,"topics":["fifo","fifo-queue","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fb55.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["fb55"]}},"created_at":"2011-12-01T14:13:57.000Z","updated_at":"2024-12-05T06:57:53.000Z","dependencies_parsed_at":"2023-07-05T21:01:55.250Z","dependency_job_id":"a2cf78f2-92ea-4d25-ab0b-76f2c84bd9fb","html_url":"https://github.com/fb55/SimpleQueue","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FSimpleQueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FSimpleQueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FSimpleQueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FSimpleQueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fb55","download_url":"https://codeload.github.com/fb55/SimpleQueue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841125,"owners_count":20356440,"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","fifo-queue","hacktoberfest"],"created_at":"2024-10-13T07:11:50.383Z","updated_at":"2025-03-17T02:31:36.895Z","avatar_url":"https://github.com/fb55.png","language":"TypeScript","readme":"# SimpleQueue\n\n[![NPM version](http://img.shields.io/npm/v/SimpleQueue.svg?style=flat)](https://npmjs.org/package/SimpleQueue)\n[![Node.js CI](https://github.com/fb55/SimpleQueue/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/fb55/SimpleQueue/actions/workflows/nodejs-test.yml)\n[![Coverage](http://img.shields.io/coveralls/fb55/SimpleQueue.svg?style=flat)](https://coveralls.io/r/fb55/SimpleQueue)\n\nA simple FIFO queue\n\n    npm install SimpleQueue\n\n## What is this?\n\nThere are plenty queues for node, but even those branded as FIFO (first in first out) usually destroy the order.\nEg. when mapping over an RSS feeds \u0026 doing something with all of the pages,\nyou need to know what element had what position - so I created this little helper.\n\n## API\n\n### Class: SimpleQueue\\\u003cT, R\u003e\n\nA simple FIFO queue, delivering items in order.\n\n#### Type parameters\n\n| Name | Default | Description                              |\n| ---- | ------- | ---------------------------------------- |\n| `T`  | -       | Type that is pushed onto the stack.      |\n| `R`  | void    | Type that the passed `callback` maps to. |\n\n### Constructors\n\n#### constructor\n\n\\+ **new SimpleQueue**(`worker`: (element: T, callback: (error: Error \\| null, result: R) =\u003e void) =\u003e void, `callback`: (error: Error \\| null, result: R, element: T) =\u003e void, `done?`: undefined \\| () =\u003e void, `concurrent?`: number): `SimpleQueue`\n\n_Defined in [index.ts:16](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L16)_\n\nCreates a new FIFO queue.\n\n##### Parameters:\n\n| Name         | Type                                                                      | Default value | Description                                                |\n| ------------ | ------------------------------------------------------------------------- | ------------- | ---------------------------------------------------------- |\n| `worker`     | (element: T, callback: (error: Error \\| null, result: R) =\u003e void) =\u003e void | -             | Method to call for each child. Args:                       |\n| `callback`   | (error: Error \\| null, result: R, element: T) =\u003e void                     | -             | Method to call when an element was processed.              |\n| `done?`      | undefined \\| () =\u003e void                                                   | -             | Method to call once the stack is cleared.                  |\n| `concurrent` | number                                                                    | 20            | Number of elements to process in parallel. Defaults to 20. |\n\n**Returns:** `SimpleQueue`\n\n### Properties\n\n#### paused\n\n• **paused**: boolean = false\n\n_Defined in [index.ts:16](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L16)_\n\n### Methods\n\n#### abort\n\n▸ **abort**(): void\n\n_Defined in [index.ts:48](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L48)_\n\nClears the queue (can't stop running processes).\n\n**Returns:** void\n\n---\n\n#### pause\n\n▸ **pause**(): void\n\n_Defined in [index.ts:57](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L57)_\n\nPause the queue execution.\nWill not stop already in-flight items.\n\n**Returns:** void\n\n---\n\n#### push\n\n▸ **push**(`props`: T): void\n\n_Defined in [index.ts:41](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L41)_\n\nAdds an element to the queue.\n\n##### Parameters:\n\n| Name    | Type |\n| ------- | ---- |\n| `props` | T    |\n\n**Returns:** void\n\n---\n\n#### resume\n\n▸ **resume**(): void\n\n_Defined in [index.ts:64](https://github.com/fb55/SimpleQueue/blob/master/src/index.ts#L64)_\n\nResume the queue execution,\nand catch up with remaining items.\n\n**Returns:** void\n\n## Example\n\n```js\nimport SimpleQueue from \"SimpleQueue\";\n\nconst queue = new SimpleQueue(\n    (element, callback) =\u003e {\n        // Set\n        setTimeout(() =\u003e callback(null, element / 1000), element);\n    },\n    (err, result, element) =\u003e {\n        console.log(result);\n    },\n    () =\u003e {\n        console.log(\"done\");\n    },\n    4,\n);\n\nqueue.push(1000);\nqueue.push(5000);\nqueue.push(3000);\nqueue.push(4000);\nqueue.push(8000);\nqueue.push(2000);\nqueue.push(0);\n```\n\nOutput:\n\n    1, 5, 3, 4, 8, 2, 0, \"done\"\n\nThis takes 9 seconds to run.\n","funding_links":["https://github.com/sponsors/fb55"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fsimplequeue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffb55%2Fsimplequeue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fsimplequeue/lists"}