{"id":17256142,"url":"https://github.com/jalal246/queue-pool","last_synced_at":"2025-04-14T05:42:23.363Z","repository":{"id":38010471,"uuid":"102737768","full_name":"jalal246/queue-pool","owner":"jalal246","description":"Pool works as a queue or stack","archived":false,"fork":false,"pushed_at":"2023-09-12T20:47:33.000Z","size":137,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T19:40:16.822Z","etag":null,"topics":["array-manipulations","array-methods","flush","flush-cache","pool","push","queue","stack","stacks","text-processing","unshift"],"latest_commit_sha":null,"homepage":"https://jalal246.github.io/queue-pool/","language":"JavaScript","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/jalal246.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}},"created_at":"2017-09-07T13:04:25.000Z","updated_at":"2023-03-04T05:33:39.000Z","dependencies_parsed_at":"2023-01-17T17:49:35.152Z","dependency_job_id":null,"html_url":"https://github.com/jalal246/queue-pool","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fqueue-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fqueue-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fqueue-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fqueue-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jalal246","download_url":"https://codeload.github.com/jalal246/queue-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830420,"owners_count":21168272,"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":["array-manipulations","array-methods","flush","flush-cache","pool","push","queue","stack","stacks","text-processing","unshift"],"created_at":"2024-10-15T07:13:43.099Z","updated_at":"2025-04-14T05:42:23.344Z","avatar_url":"https://github.com/jalal246.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Queue-Pool\n\n\u003e Pool works as queue or stack.\n\n`Queue-Pool` Is pool of elements, implements major Array methods. With ability to auto-adjust length.\n\n## Why?\n\nIf you handle a group of incoming streams of chunks, process them in a pool, there is a need to release them in\n\u003ca href=\"https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\"\u003estack\u003c/a\u003e or \u003ca href=\"https://en.wikipedia.org/wiki/Queue_(abstract_data_type)\"\u003equeue\u003c/a\u003e order.\n\n## Getting Started\n\n```sh\nnpm install queue-pool\n```\n\n## Usage\n\n```js\nimport QPool from \"queue-pool\";\n\nconst qpool = new QPool(options);\n```\n\n`options`\n\n- `init` for custom initialize, instead of empty string as default.\n- `maxIn` a number, for max size allowed in pool. `Default` is 2.\n\n`Methods`\n\n- `get`\n- `length`\n- `elementsSize` an array contains size of each element in the pool.\n- `elementsLength` a number of elements in.\n- `flush`\n- `unshift`\n- `push`\n- `shift`\n- `pop`\n- `process` push and adjust the size.\n\n  `process(input, type, cb)`\n\n  - type: stack or queue. `Default` is queue.\n  - cb(get): optional.\n\n  \u003e In case you made several `push` calls passing the allowed number set in `maxIn`.\n  \u003e It auto `shift` in case of queue/ `pop` in case of stack over elements and then `push` the new one.\n  \u003e Using this method you guarantee that you are not passing the number of elements you set.\n\n## Example\n\n```js\nconst qpool = new QPool();\nqpool.push(\"pigs, \"); // pigs,\nqpool.push(\"goats, \"); // pigs, goats,\nqpool.push(\"sheep.\"); // pigs, goats, sheep.\nqpool.shift(); // goats, sheep.\nqpool.pop(); // goats,\nqpool.unshift(\"sheep, \"); // sheep, goats,\nqpool.elementsLength(); // 2\nqpool.elementsSize(); // [7 , 7]\nqpool.length(); // 14\n```\n\n### with queue\n\n```js\nconst qpool = new QPool({ maxIn: 5 });\nfor (let i = 0; i \u003c 10; i++) qpool.push(`${i} `);\nqpool.get(); // 0 1 2 3 4 5 6 7 8 9\nqpool.process(\"last-element\");\nqpool.get(); // 6 7 8 9 last-element\n```\n\n### with stack and callback\n\n```js\nconst qpool = new QPool({ maxIn: 5 });\nfor (let i = 0; i \u003c 10; i++) qpool.push(`${i} `);\nqpool.get(); // 0 1 2 3 4 5 6 7 8 9\nqpool.process(\"last-element\", \"stack\", (get) =\u003e {\n  console.log(get); //  0, 1, 2, 3 last-element\n});\n```\n\n## Tests\n\n```sh\ntest\n```\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/jalal246/queue-pool/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Fqueue-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjalal246%2Fqueue-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Fqueue-pool/lists"}