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

@cendo91/csv-export-kit

v0.1.1

Published

Framework-independent CSV serialization and browser downloads

Readme

CSV Export Kit

@cendo91/csv-export-kit 提供 CSV 序列化和浏览器下载。包使用 ESM,附带 TypeScript 类型,运行时零依赖。

安装

npm install @cendo91/csv-export-kit

使用

import { downloadCsv, serializeCsv } from "@cendo91/csv-export-kit";

const csv = serializeCsv({
  columns: [
    { title: "商品", dataIndex: ["product", "name"] },
    { title: "单价", dataIndex: "price", formatter: (value) => Number(value).toFixed(2) },
  ],
  dataSource: [{ product: { name: "笔记本" }, price: 12.5 }],
});

// 在浏览器中调用。
await downloadCsv(csv, "商品清单");

API

  • serializeCsv({ columns, dataSource, bom? }) 在 Node 或浏览器中将记录转换为 CSV 字符串。字段以逗号分隔,记录以 CRLF 换行。默认包含 UTF-8 BOM,可用 bom: false 省略。
  • 列通过 dataIndex 或 key 取值。嵌套字段使用路径数组,自定义导出值使用 formatter(value, row, index)。字符串和数字标题直接用于表头,其余标题回退到 key 或 dataIndex。
  • 表头和格式化后的文本若以常见公式字符开头,会在引号内加 Tab 前缀,以降低表格软件执行公式的风险。数值保持原样,程序重新导入时应考虑文本中的 Tab 前缀。
  • downloadCsv(csv, fileName?) 在浏览器中触发下载,自动补 .csv 扩展名,默认文件名是 export.csv。Promise 在触发下载后完成。

许可证

本项目采用 MIT 许可证。 LICENSE