github-pagination

A simple js lib for parse GitHub's pagination info from API's response.

MIT License

Downloads
9
Stars
14
Committers
3

github-pagination

A simple js lib for parse GitHub's pagination info from API's response.


Installation

$ npm install github-pagination --save

or

$ bower install github-pagination --save

Example

in node.js / io.js

var octopage = require('./');

var test = '<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"';

console.log(octopage.parser(test));
// { next: '15', last: '34', first: '1', prev: '13' }

in browser

link this script and then,

<script src="octopage.js"></script>
<script>
  var test = '<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"';

  console.log(octopage.parser(test));
  // { next: '15', last: '34', first: '1', prev: '13' }
</script>

License

MIT © Leigh Zhu

Package Rankings
Top 19.59% on Npmjs.org
Top 19.57% on Bower.io
Badges
Extracted from project README
NPM version
Related Projects