@marianmeres/paging-store
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@marianmeres/paging-store

Simple utility for calculating paging data.

Install

$ npm i @marianmeres/paging-store

Example

const paging = calculatePaging({ total: 25, limit: 10, offset: 11 });

// paging is now:
{
    total: 25,
    limit: 10,
    offset: 11,
    isLast: false,
    isFirst: false,
    nextPage: 3,
    previousPage: 1,
    hasNext: true,
    hasPrevious: true,
    nextOffset: 20,
    previosOffset: 0,
    currentPage: 2,
    pageCount: 3,
    firstOffset: 0,
    lastOffset: 20,
}

// store api
const store = createPagingStore({ total: 25, limit: 10, offset: 0 });
store.subscribe((paging) => {/* see shape above */});
store.update(/*any/all of { total: ..., limit: ..., offset: ... }*/);
store.reset(limit?);

Readme

Keywords

Package Sidebar

Install

npm i @marianmeres/paging-store

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

11.8 kB

Total Files

7

Last publish

Collaborators

  • marianmeres