🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@execaman/pagination

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@execaman/pagination

browse your data like a book, page by page

1.1.1
unpublished
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Contents

  • Import
  • Usage
  • Properties
  • Getters
  • Methods
  • Contributing

Import

Node.js

import Book from "@execaman/pagination"; // ESM
// or
const Book = require("@execaman/pagination"); // CommonJS

Browser

// you can use any CDN
// preferably unpkg for latest version
<script src="https://unpkg.com/@execaman/pagination/lib/index.js" type="text/javascript"></script>
<script>
  console.log(new Book([1, 2, 3, 4, 5]));
</script>

Usage

const book = new Book(
  [6, 7, 8, 9, 10], // current pages
  [1, 2, 3, 4, 5] // previous pages (if any)
);

console.log(book.current); // 6

Properties

.left

list of previous pages (pages turned over)

returns: Page[]

.right

list of current pages (pages left to read)

returns: Page[]

Getters

.size

total number of pages

returns: number

.page

current page number

returns: number

.pages

array of all pages; previous pages are brought to the front

returns: Page[]

.current

the current page

returns: Page

.previous

the previous page

returns: Page | undefined

.next

the next page

returns: Page | undefined

Methods

.first(jump)

ParameterTypeOptionalDefaultDescription
jumpbooleanYesfalsewhether to set the first page as the current page

returns: Page | undefined

.last(jump)

ParameterTypeOptionalDefaultDescription
jumpbooleanYesfalsewhether to set the last page as the current page

returns: Page | undefined

.at(page)

ParameterTypeOptionalDescription
pageintegerNopage number; negative to look from back, positive for front

returns: Page | undefined

.jump(page)

ParameterTypeOptionalDescription
pageintegerNopage number; negative to look from back, positive for front

returns: Page | undefined

.find(query, all, jump)

ParameterTypeOptionalDefaultDescription
query(page: Page) => booleanNoN/Afunction to run over pages
allbooleanYesfalsewhether to include previous pages in query
jumpbooleanYesfalsewhether to set it as the current page (if found)

returns: Page | undefined

.random(jump)

ParameterTypeOptionalDefaultDescription
jumpbooleanYesfalsewhether to set it as the curent page

returns: Page | undefined

.erase()

erases both halves (previous and current pages) of the book, making it non-informative and non-functional

returns: void

Contributing

My opinion alone won't make this package as reliable as it would be with more people; if you want to report a bug, drop a suggestion, or are willing to contribute, please do so. I shall be grateful to assist or learn from you.

Copyright (c) 2023 Aman, under the MIT License

Keywords

menu

FAQs

Package last updated on 14 Nov 2023

Did you know?

Socket

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.

Install

Related posts