
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Generic pagination algorithm wrapped in a CommonJS module.
When developing any kind of application that involves fetching an arbitrary number of elements from somewhere, you'll almost always want some form of pagination. It's impossible to tell in advance how the rest of the application will work, so a generic module that does -only- the pagination algorithm is useful. Enter Paginator.
Also see the documentation.
var Paginator = require("paginator");
// Arguments are `per_page` and `length`. `per_page` changes the number of
// results per page, `length` changes the number of links displayed.
var paginator = new Paginator(30, 7);
// Arguments are `total_results` and `current_page`. I hope these are self
// explanatory.
var pagination_info = paginator.build(10000, 50);
// The returned object will look something like this.
{
total_pages: 334,
current_page: 50,
first_page: 46,
last_page: 53,
previous_page: 49,
next_page: 51,
has_previous_page: true,
has_next_page: true,
total_results: 10000,
results: 30,
first_result: 1470,
last_result: 1499,
}
Licensed under an MIT license.
FAQs
Generic pagination algorithm wrapped in a CommonJS module
The npm package paginator receives a total of 33,050 weekly downloads. As such, paginator popularity was classified as popular.
We found that paginator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.