# page-slicer

> Minimal pagination class

Latest version **1.0.2** (published 2018-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install page-slicer
pnpm add page-slicer
yarn add page-slicer
bun add page-slicer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-01 |
| First published | 2016-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | makepost |
| Maintainers | makepost |
| Keywords | page, pager, pagination |

## Links

- npm: https://www.npmjs.com/package/page-slicer
- Repository: https://github.com/makepost/page-slicer
- Homepage: https://github.com/makepost/page-slicer#readme
- Issues: https://github.com/makepost/page-slicer/issues
- npm.io page: https://npm.io/package/page-slicer

## Recent versions

- 1.0.2 (latest) — 2018-08-01
- 1.0.1 — 2016-08-12

## README

# page-slicer

Minimal pagination class for JS.

```javascript
var PageSlicer = require('page-slicer').PageSlicer;

var items = 'abcdefghijklmnopqrstuvwxyz'.split('');
var pager = new PageSlicer({ itemsOnPage: 5 }, items);

console.log([
  pager.count(), // -> 6
  pager.isValid('5'), // true
  pager.isValid('6'), // false
  pager.isValid('-6'), // true
  pager.isValid('-7'), // false

  pager.state, // -> 0
  pager.slice().join(''), // -> 'abcde'
  pager.goNext(),
  pager.slice().join(''), // -> 'fghij'
  pager.goLast(),
  pager.slice().join(''), // -> 'z'

  pager.go(-1),
  pager.slice().join(''), // -> 'vwxyz'
  pager.goPrev(),
  pager.slice().join(''), // -> 'qrstu'
  pager.goFirst(),
  pager.slice().join(''), // -> 'a'
].filter(function (x) {
  return typeof x !== 'undefined';
}));
```

See [index.html](index.html) and [index.js](index.js) for a [mithril](http://mithril.js.org/) pagination boilerplate.

---
_Source: https://npm.io/package/page-slicer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
