{"id":19432690,"url":"https://github.com/brightspace/superagent-d2l-queue","last_synced_at":"2025-04-24T20:31:00.836Z","repository":{"id":57342129,"uuid":"43303246","full_name":"Brightspace/superagent-d2l-queue","owner":"Brightspace","description":"Request queue using superagent and Q promise library","archived":false,"fork":false,"pushed_at":"2020-07-07T17:54:00.000Z","size":1402,"stargazers_count":2,"open_issues_count":2,"forks_count":3,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-05T02:17:53.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Brightspace.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-28T13:40:59.000Z","updated_at":"2021-11-02T17:18:27.000Z","dependencies_parsed_at":"2022-09-16T02:50:26.531Z","dependency_job_id":null,"html_url":"https://github.com/Brightspace/superagent-d2l-queue","commit_stats":null,"previous_names":["brightspace/superagent-d2l-promise-queue"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brightspace%2Fsuperagent-d2l-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brightspace%2Fsuperagent-d2l-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brightspace%2Fsuperagent-d2l-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brightspace%2Fsuperagent-d2l-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Brightspace","download_url":"https://codeload.github.com/Brightspace/superagent-d2l-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223967170,"owners_count":17233340,"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":[],"created_at":"2024-11-10T14:36:42.588Z","updated_at":"2024-11-10T14:36:43.304Z","avatar_url":"https://github.com/Brightspace.png","language":"JavaScript","readme":"#Request Queue\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][ci-image]][ci-url]\n[![Coverage Status][coverage-image]][coverage-url]\n[![Dependency Status][dependencies-image]][dependencies-url]\n\nExtends [Superagent](https://github.com/visionmedia/superagent) by adding the ability to queue up requests and retry failed requests due to timeouts.\n\n## Installation\n\nInstall from NPM:\n\n```shell\nnpm install superagent-d2l-queue --save\n```\n\n## Usage\n\n### `superagentQueue(options)`\n\n```js\nconst request = require( 'superagent' );\nconst superagentQueue = require('superagent-d2l-queue');\n\n// ...\n\nrequest\n    .get( ... )\n    .use( superagentQueue( ... ) )\n    .end( function( err, res ) {\n        // ...\n    });\n```\n\n__Options (defaults):__\n\nAll parameters are optional. The backoff parameter does need to include all parameters. Custom parameters will\nbe merged with default parameters.\n```js\n{\n    queue: undefined, // use `superagentQueue.makeQueue()``\n    backoff: {\n        initialTimeout: 2000, // Initial retry timeout\n        maxTimeout: undefined, // Max retry timeout\n        expFactor: 1.4 // Exponental backoff factor  (1.4 ^ retryCount)\n        retries: 5, // Number of retries, can be null to have infinite retries\n        override: function( retryCount ) { // Compute the time between each retry interval.\n            return Math.round( initialTimeout *\n                Math.pow( backoff.exp.factor, retryCount ) );\n        }\n    },\n    // Enable request retry when a request has timed out.\n    retryEnabled: false,\n    // Callback function that will be called when a request has timedout and will be retried. This function\n    // will not be called if retry is disabled\n    retryNotifier: undefined\n}\n```\n\n### `superagentQueue( { queue: superagentQueue.makeQueue() } )`\nSpecify an Array that will be used as a queue to chain multiple Superagent requests. Only one request will execute at a time. This is similar to what can be done with libraries such as [Q](https://github.com/kriskowal/q).\n\n```js\nconst request = require( 'superagent' );\nconst superagentQueue = require('superagent-d2l-queue');\n\n// ...\n\nconst queue = superagentQueue.makeQueue();\n\nconst first = request\n    .get( ... )\n    .use( superagentQueue( { queue } ) )\n    .end( function( err, res ) {\n        // ...\n    });\n\nconst second = request\n    .get( ... )\n    .use( superagentQueue( { queue } ) )\n    .end( function( err, res ) {\n        // ...\n    });\n\nconst third = request\n    .get( ... )\n    .use( superagentQueue( { queue } ) )\n    .end( function( err, res ) {\n        // ...\n    });\n\n// etc...\n```\n\n## Contributing\n\n1. **Fork** the repository. Committing directly against this repository is\n   highly discouraged.\n\n   2. Make your modifications in a branch, updating and writing new unit tests\n      as necessary in the `spec` directory.\n\n      3. Ensure that all tests pass with `npm test`\n\n      4. Submit a pull request to this repository. Wait for tests to run and someone\n         to chime in.\n\n### Code Style\n\nThis repository is configured with [EditorConfig][EditorConfig] and [ESLint][ESLint] rules.\n\n[npm-url]: https://npmjs.org/package/superagent-d2l-queue\n[npm-image]: https://img.shields.io/npm/v/superagent-d2l-queue.png\n[ci-url]: https://travis-ci.org/Brightspace/superagent-d2l-queue\n[ci-image]: https://img.shields.io/travis-ci/Brightspace/superagent-d2l-queue.svg\n[coverage-url]: https://coveralls.io/r/Brightspace/superagent-d2l-queue?branch=master\n[coverage-image]: https://img.shields.io/coveralls/Brightspace/superagent-d2l-queue.svg\n[dependencies-url]: https://david-dm.org/brightspace/superagent-d2l-queue\n[dependencies-image]: https://img.shields.io/david/Brightspace/superagent-d2l-queue.svg\n[EditorConfig]: http://editorconfig.org/\n[ESLint]: https://github.com/eslint/eslint","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightspace%2Fsuperagent-d2l-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightspace%2Fsuperagent-d2l-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightspace%2Fsuperagent-d2l-queue/lists"}