pagination-parser

0.0.4 • Public • Published

pagination-parser

A parser for GitHub API v3 style pagination information.


Installing

$ npm install --save pagination-parser 

Example

const link = `
  <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=15>; rel="next",
  <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>; rel="last",
  <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=1>; rel="first",
  <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=13>; rel="prev"
`;
const parsed = parser(link);
 
/*
{
  first: {
    num: 1,
    url: 'https://api.github.com/search/code?q=addClass+user%3Amozilla&page=1',
  },
  last: {
    num: 34,
    url: 'https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34',
  },
  next: {
    num: 15,
    url: 'https://api.github.com/search/code?q=addClass+user%3Amozilla&page=15',
  },
  prev: {
    num: 13,
    url: 'https://api.github.com/search/code?q=addClass+user%3Amozilla&page=13',
  },
}
*/

Readme

Keywords

Package Sidebar

Install

npm i pagination-parser

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

9.76 kB

Total Files

4

Last publish

Collaborators

  • ymmooot