Skip to content

lisposter/github-pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •