Socket
Socket
Sign inDemoInstall

async-paginator

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-paginator

Async pagination for big collections


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

paginator

Smart pagination for big collections

Ordered paginator

import { paginator } from 'async-paginator';
const paginate = paginator([1,2,3,4], async (num) => num * 10);
for await (const result of paginate) {
    console.log('Task:', result);
}
// Output will be
/*
Task: 10
Task: 20
Task: 30
Task: 40
*/

Unordered paginator

import { paginatorUnordered } from 'async-paginator';
const paginate = paginatorUnordered([1,2,3,4], async () => {
    if (num % 2 === 0) {
        await sleep(10); // timeout 10ms
    }
    return num * 10;
});
for await (const result of paginate) {
    console.log('Task:', result);
}
// Output will be
/*
Task: { data: 10, index: 0 }
Task: { data: 30, index: 2 }
Task: { data: 20, index: 1 }
Task: { data: 40, index: 3 }
*/

FAQs

Last updated on 12 Jan 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc