Code Explainers

Code explainers tagged #cursors

javascript
const express = require('express');
const router = express.Router();
 
router.get('/exports/orders', async (req, res) => {

Streaming a large JSON export in Express

streaming backpressure cursors
Advanced 9 steps
typescript
interface Page<T> {
  items: T[];
  nextCursor: string | null;
}

Streaming cursor pagination with async generators

async-generators pagination generics
Intermediate 8 steps
javascript
async function fetchAllPages(baseUrl, { pageSize = 100, headers = {} } = {}) {
  const results = [];
  let cursor = null;
 

Cursor-based pagination with fetch

pagination async-await fetch
Intermediate 6 steps