npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pager-js

v1.0.1

Published

A very simple and useful pager boilerplate

Downloads

4

Readme

Pager v1.0.1

A very simple and useful pager boilerplate

Bower version npm version


Usage

It's very simple to use Pager. You will need to download the files, or just run some of these following command lines: bower install pager --save or npm i pager-js --save

Then you just need to include the file in your HTML:

<script src="bower_components/pager.min.js"></script>

If you're in a CommonJS environment:

var Pager = require('pager-js');

Or if you're in a AMD environment:

require(['path-to/pager'], function (Pager) {
	// ...
});

Now you can create a new instance:

var myPager = new Pager(length, circular);

Options

  • length Number - Specifies the amount of items
  • circular Boolean - Specifies whether to wrap at the first/last item and jump back to the start/end

API

.set(index)

myPager.set(2); // return number

Sets the current index with the number entered in the index parameter if it is not greater than the last index

.hasPrev()

myPager.hasPrev(); // return boolean

Returns if there is a previous index

.hasNext()

myPager.hasNext(); // return boolean

Returns if there is a next index

.getPrev()

myPager.getPrev(); // return number or false

Returns the previous index if it exists

.getNext()

myPager.getNext(); // return number or false

Returns the next index if it exists

.getFirst()

myPager.getFirst(); // return number

Returns the first index

.getLast()

myPager.getLast(); // return number

Returns the last index

.prev()

myPager.prev(); // return number

Sets and returns the current index with the previous index, if the circular option is true and the current index is 0 it will return the last index

.next()

myPager.next(); // return number

Sets and returns the current index with the next index, if the circular option is true and the current index is the last index it will return the first index

.first()

myPager.first(); // return number

Sets the current index with the first index and return it

.last()

myPager.last(); // return number

Sets the current index with the last index and return it

Building

First of all, you need have installed Node.js and Gulp globally. Then you can:

  • Clone the repo: git clone [email protected]:acauamontiel/pager.git
  • Enter the folder: cd pager
  • Finally install Node dependencies: npm install

Running

You can build by Gulp

Available Gulp commands

Default - gulp

Run gulp to lint and minify the code

Watch - gulp watch

Run gulp watch to watch JavaScript files

License

© 2014 Acauã Montiel

MIT License