![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
skaleb-simple-paginator
Advanced tools
This simple paginator was built to allow for easily paginating through arrays that may be client side. Usually these types of things take place when the data is being sourced from either a database or API but on the odd occasion, it could arise that you already have too much data client side. This paginator provides a simple interface to manipulate these arrays.
This paginator was built specifically with TypeScript in mind.
To install this package you can simply use the install command below.
$ npm i --save skaleb-simple-paginator
Importing the package into your class.
import { SimplePaginator } from './SimplePaginator'
// Variables that will be used below in `Instantiation`
const pageSize: number = 5
const pageNumber: number = 1
const arr: Array<string> = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g' ]
Instantiating a new instance of the paginator.
const paginator = new SimplePaginator()
.setArray(arr)
.setPageSize(pageSize)
.setPageNumber(pageNumber)
// You can also instantiate the `SimplePaginator` with the variables in the constructor
const paginator = new SimplePaginator(arr, pageNumber, pageSize)
.setArray(x)
sets the array to be paginated. The returned items should retain their types.
// The paginator will use the array defined above to paginate
paginator.setArray(arr)
.getPage()
returns the number of items specified which are on the page specified.
// Should return `PaginatorResponse` with five items being equal to
// [ 'a', 'b', 'c', 'd', 'e' ]
console.log('Page 1 from paginator', paginator.getPage())
.incrementPage()
increases the page number within the paginator by one.
// Should return `PaginatorResponse` with two items being equal to
// [ 'f', 'g' ]
console.log('Page 2 from paginator', paginator.incrementPage()
.getPage())
.decrementPage()
decreases the page number within the paginator by one. If the page number is less than one then the
page number defaults to one.
// Should return `PaginatorResponse` with five items being equal to
// [ 'a', 'b', 'c', 'd', 'e' ]
console.log('Page 1 from paginator', paginator.decrementPage()
.getPage())
.setPageNumber(x)
sets the page number within the paginator to the value specified. If the value specified is less
than one then the page number defaults to one.
// Should return `PaginatorResponse` with two items being equal to
// [ 'f', 'g' ]
console.log('Page 2 from paginator', paginator.setPageNumber(2)
.getPage())
// Should return `PaginatorResponse` with five items being equal to
// [ 'a', 'b', 'c', 'd', 'e' ]
console.log('Page 1 from paginator', paginator.setPageNumber(-1)
.getPage())
.setPageSize(x)
sets the number of items to be returned in the PaginatorResponse
for any given page to the value
specified. If the value specified is less than one then the page size defaults to one.
// Should return `PaginatorResponse` with three items being equal to
// [ 'a', 'b', 'c' ]
console.log('Page 1 from paginator', paginator.setPageSize(3)
.getPage())
// Should return `PaginatorResponse` with one item being equal to
// [ 'a' ]
console.log('Page 1 from paginator', paginator.setPageSize(-1)
.getPage())
This project is completely covered by unit tests. Various cases have been accounted for both in the codebase and in the tests covering it. If a bug is picked up regarding the test suite or code, feel free to make a contribution to help correct the bug.
To run the tests, you can simply run the following test
command/s.
npm run test
npm run coverage
npm run lint
Feedback and contributions are more than welcome. Should you feel there is something you wish to contribute to this paginator, feel free to make a merge request. Ensure that whatever proposed change, has tests covering various cases for the change.
FAQs
Simple client for client-side pagination making use of generic types and allowing for chainable methods
The npm package skaleb-simple-paginator receives a total of 3 weekly downloads. As such, skaleb-simple-paginator popularity was classified as not popular.
We found that skaleb-simple-paginator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.