npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arraypress/csv

v1.0.0

Published

CSV generation for edge runtimes — string, streaming, and Response helper.

Readme

@arraypress/csv

CSV generation for edge runtimes. String output for small datasets, streaming for large ones, and a ready-made Response helper for Cloudflare Workers and Hono routes.

Zero dependencies. Uses Web Streams API — works in Cloudflare Workers, Node.js 18+, Deno, Bun, and browsers.

Installation

npm install @arraypress/csv

Usage

Quick Export (small datasets)

import { csvResponse } from '@arraypress/csv';

app.get('/api/export/customers', async (c) => {
  const data = await db.prepare('SELECT * FROM customers').all();

  return csvResponse({
    filename: 'customers.csv',
    columns: ['ID', 'Email', 'Name', 'Country', 'Orders'],
    rows: data.results.map(c => [c.id, c.email, c.name, c.country, c.order_count]),
  });
});

Streaming Export (large datasets)

import { csvResponse } from '@arraypress/csv';

app.get('/api/export/orders', async (c) => {
  return csvResponse({
    filename: 'orders.csv',
    columns: ['Order #', 'Email', 'Amount', 'Currency', 'Status', 'Date'],
    stream: async function* () {
      let offset = 0;
      while (true) {
        const batch = await db.prepare('SELECT * FROM orders LIMIT 500 OFFSET ?')
          .bind(offset).all();
        if (!batch.results.length) break;
        for (const o of batch.results) {
          yield [o.order_number, o.email, o.amount, o.currency, o.status, o.created_at];
        }
        offset += 500;
      }
    },
  });
});

Build CSV String

import { createCSV } from '@arraypress/csv';

const csv = createCSV({
  columns: ['Name', 'Email', 'Amount'],
  rows: [
    ['Alice', '[email protected]', 1999],
    ['Bob', '[email protected]', 2500],
  ],
});
// "Name,Email,Amount\nAlice,[email protected],1999\nBob,[email protected],2500\n"

API

csvResponse({ filename, columns, rows?, stream? })

Create a complete Response with CSV data, Content-Type, and Content-Disposition headers. Ready to return from any Worker/Hono route.

  • filename — download filename (e.g. 'orders.csv')
  • columns — header row
  • rows — array of row arrays (for small datasets)
  • stream — async generator yielding row arrays (for large datasets)
  • includeHeader — include header row (default true)

If both rows and stream are provided, stream takes precedence.

createCSV({ columns, rows })

Returns a CSV string. Best for small datasets or when you need the string for something other than a Response (email attachment, file write, etc.).

createCSVStream({ columns, stream })

Returns a ReadableStream. Best for large datasets where you need the stream directly (piping to another stream, etc.).

Escaping

All values are automatically escaped per RFC 4180:

  • Values containing commas are wrapped in quotes: "Smith, John"
  • Values containing quotes have quotes doubled: "Say ""hello"""
  • Values containing newlines are wrapped in quotes
  • Null and undefined become empty strings
  • Numbers and booleans are converted to strings

License

MIT