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

@molecule/api-import-export-csv

v1.0.1

Published

CSV import/export provider for molecule.dev

Readme

@molecule/api-import-export-csv

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

CSV import/export provider for molecule.dev.

Implements the {@link ImportExportProvider} contract using pure TypeScript CSV parsing/formatting and the bonded @molecule/api-database DataStore for all database operations.

Quick Start

import { setProvider } from '@molecule/api-import-export'
import { provider } from '@molecule/api-import-export-csv'

// Wire the CSV provider at startup
setProvider(provider)

Type

provider

Installation

npm install @molecule/api-import-export-csv @molecule/api-database @molecule/api-import-export

API

Interfaces

CsvProviderOptions

Configuration options for the CSV import/export provider.

interface CsvProviderOptions {
  /** CSV field delimiter character. Defaults to `','`. */
  delimiter?: string

  /** Maximum number of rows to process per batch during import. Defaults to `1000`. */
  defaultBatchSize?: number

  /** Maximum number of rows to export in a single query. Defaults to `50000`. */
  maxExportRows?: number
}

Functions

createProvider(options)

Creates a CSV import/export provider instance.

Uses the bonded @molecule/api-database DataStore for all database operations. CSV parsing/formatting is done in pure TypeScript with no native dependencies.

function createProvider(options?: CsvProviderOptions): ImportExportProvider
  • options — Provider configuration options.

Returns: A fully configured ImportExportProvider implementation.

formatCSV(rows, columns, delimiter)

Formats an array of row objects into a CSV string.

function formatCSV(rows: Record<string, unknown>[], columns?: string[], delimiter?: string): string
  • rows — Array of row objects to format.
  • columns — Optional ordered list of column names. Defaults to all keys of the first row.
  • delimiter — Field delimiter character. Defaults to ','.

Returns: CSV-formatted string.

formatExcel(rows, columns)

Formats row objects as an XML Spreadsheet 2003 document (opens in Excel/LibreOffice).

function formatExcel(rows: Record<string, unknown>[], columns?: string[]): string
  • rows — Array of row objects to format.
  • columns — Optional ordered list of column names.

Returns: XML Spreadsheet string.

parseCSV(text, delimiter)

Parses a CSV string into an array of row objects using the header row as keys.

function parseCSV(text: string, delimiter?: string): Record<string, string>[]
  • text — The CSV text to parse.
  • delimiter — Field delimiter character. Defaults to ','.

Returns: Array of parsed row objects keyed by header names.

Constants

provider

Default lazily-initialized CSV import/export provider. Uses the bonded DataStore for database operations.

const provider: ImportExportProvider

Core Interface

Implements @molecule/api-import-export interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/api-import-export'
import { provider } from '@molecule/api-import-export-csv'

export function setupImportExportCsv(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-database ^1.0.1
  • @molecule/api-import-export ^1.0.1

Runtime Dependencies

  • @molecule/api-database
  • @molecule/api-import-export

E2E Tests

Integration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip:

  • [ ] Exporting from the UI downloads a file whose rows and columns match the data on screen (spot-check at least one row's values).
  • [ ] Importing a valid file adds the records: they appear in the UI and survive a full reload.
  • [ ] If the app surfaces column mapping, a file whose headers differ from the field names imports into the RIGHT fields via the mapping.
  • [ ] A malformed file (wrong columns, broken rows) is rejected with a readable error — no silent partial import; per-row errors (if reported) are truthful.
  • [ ] Re-importing the same file honors the app's duplicate policy (e.g. skip-duplicates does not double the rows).
  • [ ] Round-trip integrity: export, then re-import the same file — values, encodings, and special characters come back unchanged.