{"_id":"paged-request","_rev":"222231","name":"paged-request","description":"Simplified requests for paged (paginated) content.","dist-tags":{"latest":"2.0.2"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T15:40:41.000Z","created":"2018-01-31T09:08:06.107Z","2.0.2":"2021-01-20T15:18:36.665Z","2.0.1":"2018-05-29T05:36:32.728Z","2.0.0":"2018-05-29T05:09:14.368Z","1.0.2":"2018-01-31T21:50:30.268Z","1.0.1":"2018-01-31T09:17:56.080Z","1.0.0":"2018-01-31T09:08:06.107Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"versions":{"2.0.2":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"2.0.2","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^5.2.0"},"keywords":["get","paged","paginated","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["gists","github-base","repos"]},"lint":{"reflinks":true},"reflinks":["axios","needle"]},"dependencies":{"axios":"^0.21.1"},"gitHead":"da6a6dfaf4ba11832f1193ea2061bc3446c40520","_id":"paged-request@2.0.2","_nodeVersion":"15.5.1","_npmVersion":"7.3.0","dist":{"shasum":"4d621a08b8d6bee4440a0a92112354eeece5b5b0","size":3641,"noattachment":false,"key":"/paged-request/-/paged-request-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-2.0.2.tgz"},"_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"directories":{},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request_2.0.2_1611155916520_0.5068753770369023"},"_hasShrinkwrap":false,"publish_time":1611155916665,"_cnpm_publish_time":1611155916665},"2.0.1":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"2.0.1","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^5.2.0"},"keywords":["get","paged","paginated","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["gists","github-base","repos"]},"lint":{"reflinks":true},"reflinks":["axios","needle"]},"dependencies":{"axios":"^0.18.0"},"gitHead":"ac117f3ad7ab7a9c0c27d36d39ad355b4c816033","_id":"paged-request@2.0.1","_npmVersion":"6.0.1","_nodeVersion":"10.0.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"91164f042231feb68643542d2530476a518ff4de","size":3550,"noattachment":false,"key":"/paged-request/-/paged-request-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-2.0.1.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request_2.0.1_1527572192679_0.7619498029219356"},"_hasShrinkwrap":false,"publish_time":1527572192728,"_cnpm_publish_time":1527572192728},"2.0.0":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"2.0.0","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^5.2.0"},"keywords":["get","paged","paginated","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["gists","github-base","repos"]},"lint":{"reflinks":true},"reflinks":["axios","needle"]},"dependencies":{"axios":"^0.18.0"},"gitHead":"a26036502bfec60c6d78173d7aae84d68d04664f","_id":"paged-request@2.0.0","_npmVersion":"6.0.1","_nodeVersion":"10.0.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"6512aa55d100a72b6831a3d2287a4679de4dd2b7","size":3545,"noattachment":false,"key":"/paged-request/-/paged-request-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-2.0.0.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request_2.0.0_1527570554299_0.8064952091173685"},"_hasShrinkwrap":false,"publish_time":1527570554368,"_cnpm_publish_time":1527570554368},"1.0.2":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"1.0.2","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"dependencies":{"needle":"^2.1.1"},"devDependencies":{"gulp-format-md":"^1.0.0","is-number":"^5.0.0","mocha":"^3.5.3"},"keywords":["get","paged","paginated","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["gists","github-base","repos"]},"lint":{"reflinks":true}},"gitHead":"ed5a0b5f81aab3b7a72541908bf373c37da43f9a","_id":"paged-request@1.0.2","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"c55479e4482cd02495b84bd53b59a4059579ecae","size":3387,"noattachment":false,"key":"/paged-request/-/paged-request-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-1.0.2.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request-1.0.2.tgz_1517435429516_0.27410654607228935"},"directories":{},"publish_time":1517435430268,"_hasShrinkwrap":false,"_cnpm_publish_time":1517435430268},"1.0.1":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"1.0.1","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"dependencies":{"needle":"^2.1.1"},"devDependencies":{"gulp-format-md":"^1.0.0","is-number":"^5.0.0","mocha":"^3.5.3"},"keywords":["get","paged","paginated","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["gists","github-base","repos"]},"lint":{"reflinks":true}},"gitHead":"68e28882c781b23f6efba3246f0506bd588ffdb3","_id":"paged-request@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.1.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"8b86f82d95b16abec141baed477329ef2e60ce87","size":3396,"noattachment":false,"key":"/paged-request/-/paged-request-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-1.0.1.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request-1.0.1.tgz_1517390275945_0.9622970288619399"},"directories":{},"publish_time":1517390276080,"_hasShrinkwrap":false,"_cnpm_publish_time":1517390276080},"1.0.0":{"name":"paged-request","description":"Simplified requests for paged (paginated) content.","version":"1.0.0","homepage":"https://github.com/jonschlinkert/paged-request","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/paged-request.git"},"bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"dependencies":{"needle":"^2.1.1"},"devDependencies":{"gulp-format-md":"^1.0.0","is-number":"^5.0.0","mocha":"^3.5.3"},"keywords":["get","paginated","paged","request"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["github-base","gists","repos"]},"lint":{"reflinks":true}},"gitHead":"9f869212221628d6ab57d1a665b92173b57e3611","_id":"paged-request@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.1.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"e4a5008d2d6f8ae63ab9a8ba30a2fa4aa27eeb9e","size":3370,"noattachment":false,"key":"/paged-request/-/paged-request-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/paged-request/download/paged-request-1.0.0.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/paged-request-1.0.0.tgz_1517389685022_0.6347218109294772"},"directories":{},"publish_time":1517389686107,"_hasShrinkwrap":false,"_cnpm_publish_time":1517389686107}},"readme":"# paged-request [![NPM version](https://img.shields.io/npm/v/paged-request.svg?style=flat)](https://www.npmjs.com/package/paged-request) [![NPM monthly downloads](https://img.shields.io/npm/dm/paged-request.svg?style=flat)](https://npmjs.org/package/paged-request) [![NPM total downloads](https://img.shields.io/npm/dt/paged-request.svg?style=flat)](https://npmjs.org/package/paged-request) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/paged-request.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/paged-request)\n\n> Simplified requests for paged (paginated) content.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save paged-request\n```\n\n## Heads up!\n\nSee the [release notes](#release-notes) for information about changes made in v2.0.\n\n## Usage\n\nThis library recursively calls [needle's](https://github.com/tomas/needle#needlemethod-url-data-options-callback--20x) `.get` method as long as the user-provided `next()` function returns a string (the next url to get). See [an example](#example).\n\n**Example**\n\n```js\nconst request = require('paged-request');\n\nrequest(url, options, next)\n  .then(acc => console.log(acc.pages.length))\n  .catch(console.error);\n```\n\n### Params\n\n* `url` **{string}** - (required) the initial url to get\n* `options` **{object}** - (optional) options object to pass to [needle](https://github.com/tomas/needle)\n* `next` **{function}** - (required) function that returns the next url to get, a promise or undefined.\n\n### `next` function params\n\n* `url` **{string}** - the original (base) user-provided url\n* `resp` **{object}** - [needle](https://github.com/tomas/needle) response object\n* `acc` **{object}** - accumulator object with the following properties:\n  - `options` **{object}** - user-provided options object\n  - `pages` **{array}** - array of responses\n  - `urls` **{array}** - array of requested urls\n\nThe `next` function should return a string (the next url to get), promise or undefined.\n\n## Example\n\nThe following example shows how to loop over pages of `CSS` posts on [smashingmagazine.com](https://www.smashingmagazine.com/category/css) (an arbitrary example, but they have great content!).\n\n```js\nconst request = require('paged-request');\n\nasync function next(url, resp, acc) {\n  // do stuff to check response first if necessary\n  const regex = /href=\"\\/.*?\\/(\\d+)\\/\"/;\n  const num = (regex.exec(resp.data) || [])[1];\n\n  if (num && /^[0-9]+$/.test(num) && +num <= n) {\n    // use the \"original\" url to avoid having to reparse\n    // and recreate the url each time\n    return `${acc.orig}/page/${num}/`;\n  }\n}\n\nrequest('https://www.smashingmagazine.com/category/css', {}, next)\n  .then(acc => console.log(acc.pages.length))\n  .catch(console.error);\n```\n\n## Release notes\n\n### v2.0\n\n* renamed `.hrefs` to `.urls` in response object\n* now using [axios](https://github.com/axios/axios) instead of [needle](https://github.com/tomas/needle). Please see the axios documentation for API information.\n\n## About\n\n<details>\n<summary><strong>Contributing</strong></summary>\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n</details>\n\n<details>\n<summary><strong>Running Tests</strong></summary>\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n</details>\n\n<details>\n<summary><strong>Building docs</strong></summary>\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n</details>\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [gists](https://www.npmjs.com/package/gists): Methods for working with the GitHub Gist API. Node.js/JavaScript | [homepage](https://github.com/jonschlinkert/gists \"Methods for working with the GitHub Gist API. Node.js/JavaScript\")\n* [github-base](https://www.npmjs.com/package/github-base): Low-level methods for working with the GitHub API in node.js/JavaScript. | [homepage](https://github.com/jonschlinkert/github-base \"Low-level methods for working with the GitHub API in node.js/JavaScript.\")\n* [repos](https://www.npmjs.com/package/repos): Tiny wrapper around github-base for getting publicly available information for a repository, or all of… [more](https://github.com/jonschlinkert/repos) | [homepage](https://github.com/jonschlinkert/repos \"Tiny wrapper around github-base for getting publicly available information for a repository, or all of the repositories for one or more users or orgs, from the GitHub API.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 12 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 9  | [doowb](https://github.com/doowb) |  \n| 2  | [whitneyit](https://github.com/whitneyit) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2021, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on January 20, 2021._","_attachments":{},"homepage":"https://github.com/jonschlinkert/paged-request","bugs":{"url":"https://github.com/jonschlinkert/paged-request/issues"},"license":"MIT"}