
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
basicpaginate
Advanced tools
Paginate a NodeList like there's no tomorrow.
basicPaginate turns a list of elements into a JS-controlled pagination.
| Name | Description | Link |
|---|---|---|
| Default | Includes most features. | Try it on CodePen |
basicPaginate depends on the following browser features and APIs:
Some of these APIs are capable of being polyfilled in older browsers. Check the linked resources above to determine if you must polyfill to achieve your desired level of browser support.
We recommend installing basicPaginate using npm or yarn.
npm install basicpaginate
yarn add basicpaginate
Include the JS file at the end of your body tag…
<script src="dist/basicPaginate.min.js"></script>
…or skip the JS file and use basicPaginate as a module:
const basicPaginate = require('basicpaginate')
import * as basicPaginate from 'basicpaginate'
This demo shows how to use basicPaginate to turn a bunch of elements into a paginated list.
<!-- Elements that should be paginated -->
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<div class="item">Item 4</div>
<div class="item">Item 5</div>
<div class="item">Item 6</div>
<div class="item">Item 7</div>
<div class="item">Item 8</div>
<!-- Placeholder for the pagination -->
<div class="placeholder"></div>
// 1) Create a new pagination with the items and show up to 4 elements per page
const instance = basicPaginate.create(document.querySelectorAll('.item'), 4)
// 2) Use the `render` function to generate the HTML and to render it to the DOM
instance.render((instance) => {
const placeholder = document.querySelector('.placeholder')
// 3) Generate the HTML of your pagination
// Note: It doesn't matter how you generate the HTML as basicPaginate works with any structure
placeholder.innerHTML = `
<div class="pagination">
<button data-basicpaginate-prev>←</button>
<button data-basicpaginate-next>→</button>
</div>
`
// 4) Return the created element so basicPaginate can look for special attributes
// Note: You can also bind the event manually without adding attributes to the elements
return placeholder
})
// 5) Control every aspect of the pagination programmatically
instance.first()
instance.last()
instance.prev()
instance.next()
instance.goto(0)
Creates a new basicPaginate instance.
Be sure to assign your instance to a variable. Using your instance, you can…
Example:
const instance = basicPaginate.create(document.querySelectorAll('.item'), 4)
Parameters:
elems {NodeList} Elements that should be part of the pagination.elemsPerPage {Number} Number of elements per page.Returns:
{Object} The created instance.Each basicPaginate instance has a handful of handy functions. Below are all of them along with a short description.
Returns an array in which each item contains the DOM element/node objects of a page.
Example:
const pages = instance.pages()
Returns:
{Array} Array in which each item contains the DOM element/node objects of a page.Returns the total number of pages.
Example:
const length = instance.length()
Returns:
{Number} Total number of pages.Returns the current page index.
Example:
const current = instance.current()
Returns:
{Number} Current page index.Navigates to a specific page.
Example:
instance.goto(0)
Parameters:
newIndex {Number} Index of the page to be displayed.Navigates to the first page.
Example:
instance.first()
Navigates to the last page.
Example:
instance.last()
Navigates to the previous page or to the last page when the current page is already the first one.
Example:
instance.prev()
Navigates to the next page or to the first page when the current page is already the last one.
Example:
instance.next()
basicPaginate doesn't render anything by default. Use this function to build the HTML of your pagination and to render it onto your site.
The render function accepts a function that will called every time the page of the pagination changes. It receives the current instance and allows you to generate the HTML for the pagination. Return the created element or the element containing the generated element and basicPaginate will look for special data attributes to automatically bind events. The supported attributes are data-basicpaginate-first, data-basicpaginate-last, data-basicpaginate-prev, data-basicpaginate-next and data-basicpaginate-goto. Their behaviour is equal to the functions of the instance. You can also skip the attributes or return nothing to handle the event binding on your own.
Examples:
instance.render((instance) => {
const placeholder = document.querySelector('.placeholder')
// Use the data attributes of basicPaginate to get automatic event binding
placeholder.innerHTML = `
<div class="pagination">
<button data-basicpaginate-first>First</button>
<button data-basicpaginate-prev>←</button>
${ instance.pages().map((_, index) => `
<button class="${ index === instance.current() ? 'active' : '' }" data-basicpaginate-goto="${ index }">${ index + 1 }</button>
`).join('') }
<button data-basicpaginate-next>→</button>
<button data-basicpaginate-last>Last</button>
</div>
`
// Return the created element so basicPaginate can look for special attributes
return placeholder
})
instance.render((instance) => {
const placeholder = document.querySelector('.placeholder')
placeholder.innerHTML = `
<div class="pagination">
<button class="pagination__prev">←</button>
<button class="pagination__next">→</button>
</div>
`
// Handle the event binding on your own
placeholder.querySelector('.pagination__prev').onclick = instance.prev
placeholder.querySelector('.pagination__next').onclick = instance.next
})
instance.render((instance) => {
const placeholder = document.querySelector('.placeholder')
// Build the HTML of your pagination with document.createElement
const prev = document.createElement('button')
const next = document.createElement('button')
prev.innerText = '←'
next.innerText = '→'
// Handle the event binding on your own
prev.onclick = instance.prev
next.onclick = instance.next
})
FAQs
Paginate a NodeList like there's no tomorrow
The npm package basicpaginate receives a total of 1 weekly downloads. As such, basicpaginate popularity was classified as not popular.
We found that basicpaginate 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.