github-pagination

0.1.0 • Public • Published

github-pagination

NPM version

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 borwser

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 Sidebar

Install

npm i github-pagination

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • lisposter