{"id":21413068,"url":"https://github.com/rixrix/task-nibbler","last_synced_at":"2025-03-16T18:22:49.429Z","repository":{"id":65514705,"uuid":"95407804","full_name":"rixrix/task-nibbler","owner":"rixrix","description":"Sequentially or concurrently process an array of items, easily. your call.","archived":false,"fork":false,"pushed_at":"2017-07-15T09:52:22.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T15:39:07.659Z","etag":null,"topics":["concurrency","javascript","nodejs","queue","sequence","task"],"latest_commit_sha":null,"homepage":"","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/rixrix.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-06-26T04:13:17.000Z","updated_at":"2017-07-20T11:33:51.000Z","dependencies_parsed_at":"2023-01-26T21:05:14.155Z","dependency_job_id":null,"html_url":"https://github.com/rixrix/task-nibbler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixrix%2Ftask-nibbler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixrix%2Ftask-nibbler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixrix%2Ftask-nibbler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixrix%2Ftask-nibbler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rixrix","download_url":"https://codeload.github.com/rixrix/task-nibbler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243852431,"owners_count":20358268,"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":["concurrency","javascript","nodejs","queue","sequence","task"],"created_at":"2024-11-22T18:16:40.658Z","updated_at":"2025-03-16T18:22:49.388Z","avatar_url":"https://github.com/rixrix.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/rixrix/task-nibbler.svg?branch=master)](https://travis-ci.org/rixrix/task-nibbler)\n[![npm version](https://badge.fury.io/js/task-nibbler.svg)](https://badge.fury.io/js/task-nibbler)\n\n# Task Nibbler\nSequentially or concurrently process an array of items, easily. your call.\n\n\n## Use Case\nI have a few tasks that pulls out data from 3rd party APIs. These tasks are a mixed of:\n\n* short-lived\n* long-running tasks\n  * Some 3rd party API providers with rate limiting applied is tricky to work with. This library helps out in pulling data in burst mode - 5 concurrent downloads - or just one after the other.\n\n## Install\n\n### NPM\n\n```bash\n$\u003e npm install task-nibbler\n```\n\n### Yarn\n```bash\n$\u003e yarn add task-nibbler\n```\n\n## Usage\n\n```javascript\nvar taskNibbler = require('task-nibbler').nibbler;\nvar arrayOfThings = [\n    1, 2, 3,...., 10000\n];\n\n// This is your callback method for processing each item\n// Note that it should return a Promise so that `task-nibbler` knows\n// when to call or process the next task from the queue\nfunction myItemThingProcessor(arrayOfThingsItem) {\n    return new Promise(function(resolve, reject) {\n        // work on each item like:\n        // - query data from database\n        // - download file from AWS S3 bucket\n        // - query data from your analytics API, etc\n        resolve();\n    });\n}\n\ntaskNibbler(arrayOfThings, myItemThingProcessor)\n.then(function() {\n    // done, do your post processing\n})\n.catch(function(error) {\n    // when an error occurs\n});\n```\n\n## API\n\n### nibbler(items, [opts], callback(string))\nReturns a Promise.\n\n`items`\n\nString[], array of items to process\n\nopts - Object, optional flags for various flags\n\n`opts.concurrencyLevel` is a number for setting up the concurrency level. Default level is 1, of which, roughly equates to sequential processing of each item.\n\nDefault 1\n\n`callback`\n\nObject, required callback method wrapped in Promise. Task Nibbler calls this function once the item is in queue and passes the item value as the first.\n\n## Todo\n\n* Webpack\n* Test\n* Hook with TravisCI\n* Auto-publish to NPM, NuGet, Bower\n* ES6-ify\n* TypeScript definition file\n\n## References\n* [Async#queue](https://caolan.github.io/async/docs.html#queue)\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frixrix%2Ftask-nibbler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frixrix%2Ftask-nibbler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frixrix%2Ftask-nibbler/lists"}