{"id":34997305,"url":"https://github.com/jacobshirley/csv-stream-lite","last_synced_at":"2026-01-13T22:00:43.228Z","repository":{"id":330636599,"uuid":"1123265489","full_name":"jacobshirley/csv-stream-lite","owner":"jacobshirley","description":"Zero dependency, lightweight TypeScript CSV streaming and stringification library","archived":false,"fork":false,"pushed_at":"2026-01-13T00:59:01.000Z","size":169,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-13T04:41:04.510Z","etag":null,"topics":["csv","parser","parsing","stream","stringification","stringify","type-safe","typescript"],"latest_commit_sha":null,"homepage":"https://jacobshirley.github.io/csv-stream-lite/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobshirley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-26T14:11:43.000Z","updated_at":"2025-12-31T13:27:01.000Z","dependencies_parsed_at":"2025-12-28T12:00:50.154Z","dependency_job_id":null,"html_url":"https://github.com/jacobshirley/csv-stream-lite","commit_stats":null,"previous_names":["jacobshirley/csv-stream-lite"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jacobshirley/csv-stream-lite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Fcsv-stream-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Fcsv-stream-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Fcsv-stream-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Fcsv-stream-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobshirley","download_url":"https://codeload.github.com/jacobshirley/csv-stream-lite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Fcsv-stream-lite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","parser","parsing","stream","stringification","stringify","type-safe","typescript"],"created_at":"2025-12-27T02:41:32.137Z","updated_at":"2026-01-13T22:00:43.206Z","avatar_url":"https://github.com/jacobshirley.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**[Examples](./EXAMPLES.md)** | **[Documentation](https://jacobshirley.github.io/csv-stream-lite/v1)**\n\n# csv-stream-lite\n\nA lightweight, memory-efficient, zero-dependency streaming CSV parser and stringifier written in TypeScript. Process large CSV files without loading them entirely into memory.\n\n[![npm version](https://img.shields.io/npm/v/csv-stream-lite.svg)](https://www.npmjs.com/package/csv-stream-lite)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Features\n\n- 🚀 **Zero Dependencies** - No external dependencies\n- 💪 **TypeScript First** - Written in TypeScript with full type safety\n- 🌊 **Streaming Support** - Process large CSV files without loading them into memory\n- ⚡ **High Performance** - Efficient byte-level parsing\n- 🔄 **Dual Mode** - Both synchronous and asynchronous APIs\n- 🌐 **Universal** - Works in Node.js and browser environments\n- 📝 **Flexible** - Support for custom delimiters, escape characters, and transformers\n- ✅ **Well Tested** - Comprehensive test coverage\n\n## Installation\n\n```bash\nnpm install csv-stream-lite\n```\n\n```bash\nyarn add csv-stream-lite\n```\n\n```bash\npnpm add csv-stream-lite\n```\n\n## Quick Start\n\n### Parsing CSV\n\n```typescript\nimport { Csv } from 'csv-stream-lite'\n\n// Parse CSV string\nconst csvData = `name,age,city\nAlice,30,New York\nBob,25,Los Angeles`\n\nconst csv = new Csv(csvData, { readHeaders: true })\n\n// Sync streaming\nfor (const row of csv.streamObjects()) {\n    console.log(row) // { name: 'Alice', age: '30', city: 'New York' }\n}\n\n// Async streaming (for large files)\nfor await (const row of csv.streamObjectsAsync()) {\n    console.log(row)\n}\n```\n\n### Parsing with Type Transformers\n\n```typescript\nimport { Csv, CsvObjectShape } from 'csv-stream-lite'\n\ninterface User {\n    name: string\n    age: number\n    active: boolean\n}\n\nconst shape: CsvObjectShape\u003cUser\u003e = {\n    name: String,\n    age: Number,\n    active: Boolean,\n}\n\nconst csv = new Csv\u003cUser\u003e(fileStream, { shape })\n\nfor await (const user of csv.streamObjectsAsync()) {\n    console.log(user.age) // Typed as number\n}\n```\n\n### Stringifying to CSV\n\n```typescript\nimport { Csv } from 'csv-stream-lite'\n\nconst data = [\n    { name: 'Alice', age: 30, city: 'New York' },\n    { name: 'Bob', age: 25, city: 'Los Angeles' },\n]\n\n// Sync\nfor (const chunk of Csv.stringify(data, { headers: ['name', 'age', 'city'] })) {\n    process.stdout.write(chunk)\n}\n\n// Async\nfor await (const chunk of Csv.stringifyAsync(data)) {\n    process.stdout.write(chunk)\n}\n\n// Or get complete string\nconst csvString = new CsvStringify(data).toString()\n```\n\n## API Documentation\n\nFull API documentation is available at [https://jacobshirley.github.io/csv-stream-lite/v1](https://jacobshirley.github.io/csv-stream-lite/v1)\n\n## Advanced Usage\n\n### Reading from File Stream (Node.js)\n\n```typescript\nimport { createReadStream } from 'fs'\nimport { Csv } from 'csv-stream-lite'\n\nconst fileStream = createReadStream('large-file.csv')\n\nconst csv = new Csv(fileStream, { readHeaders: true })\n\nfor await (const row of csv.streamObjectsAsync()) {\n    // Process each row without loading entire file into memory\n    console.log(row)\n}\n```\n\n### Custom Delimiters\n\n```typescript\n// Tab-separated values\nconst csv = new Csv(tsvData, {\n    separator: '\\t',\n    readHeaders: true,\n})\n\n// Semicolon-separated values\nconst csv = new Csv(csvData, {\n    separator: ';',\n    readHeaders: true,\n})\n```\n\n### Strict Column Validation\n\n```typescript\nimport { Csv, TooManyColumnsError, TooFewColumnsError } from 'csv-stream-lite'\n\nconst csvData = `name,age,city\nAlice,30,New York\nBob,25,Los Angeles,ExtraColumn`\n\nconst csv = new Csv(csvData, {\n    headers: ['name', 'age', 'city'],\n    strictColumns: true, // Throws error if column count doesn't match\n})\n\ntry {\n    for await (const row of csv.streamObjectsAsync()) {\n        console.log(row)\n    }\n} catch (error) {\n    if (error instanceof TooManyColumnsError) {\n        console.error('Row has too many columns')\n    } else if (error instanceof TooFewColumnsError) {\n        console.error('Row has too few columns')\n    }\n}\n```\n\n### Row Transformation\n\n```typescript\nconst csv = new Csv(csvData, {\n    readHeaders: true,\n    transform: (row) =\u003e ({\n        ...row,\n        fullName: `${row.firstName} ${row.lastName}`,\n        age: Number(row.age),\n    }),\n})\n```\n\n### Writing to File Stream (Node.js)\n\n```typescript\nimport { createWriteStream } from 'fs'\nimport { CsvStringify } from 'csv-stream-lite'\n\nconst writeStream = createWriteStream('output.csv')\n\nconst data = [\n    { name: 'Alice', age: 30 },\n    { name: 'Bob', age: 25 },\n]\n\nconst stringifier = new CsvStringify(data, {\n    headers: ['name', 'age'],\n})\n\nfor await (const chunk of stringifier) {\n    writeStream.write(chunk)\n}\n\nwriteStream.end()\n```\n\n## Error Handling\n\nThe library provides specific error types for different scenarios:\n\n- `CsvStreamLiteError` - Base error class\n- `NoMoreTokensError` - Buffer is empty and more input is needed\n- `EofReachedError` - End of file reached\n- `BufferSizeExceededError` - Buffer size limit exceeded\n- `TooManyColumnsError` - Row has more columns than expected (when `strictColumns: true`)\n- `TooFewColumnsError` - Row has fewer columns than expected (when `strictColumns: true`)\n\n## Performance\n\ncsv-stream-lite is designed for memory efficiency and high performance:\n\n- **Streaming Architecture**: Process files of any size with constant memory usage\n- **Lazy Evaluation**: Data is only parsed as it's consumed\n- **Byte-Level Parsing**: Efficient low-level parsing without intermediate string allocations\n- **Chunked Processing**: Configurable chunk sizes for optimal performance\n\n## TypeScript Support\n\nFull TypeScript support with comprehensive type definitions:\n\n```typescript\nimport { Csv, CsvObjectShape } from 'csv-stream-lite'\n\ninterface User {\n    id: number\n    name: string\n    email: string\n    active: boolean\n}\n\nconst shape: CsvObjectShape\u003cUser\u003e = {\n    id: Number,\n    name: String,\n    email: String,\n    active: Boolean,\n}\n\nconst csv = new Csv\u003cUser\u003e(data, { shape })\n\n// Type-safe iteration\nfor await (const user of csv.streamObjectsAsync()) {\n    console.log(user.id) // TypeScript knows this is a number\n}\n```\n\n## Browser Support\n\ncsv-stream-lite works in modern browsers with support for:\n\n- `ReadableStream` API\n- `AsyncIterable` protocol\n- ES2018+ features\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details.\n\n## License\n\nMIT © [Jacob Shirley](https://github.com/jacobshirley)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobshirley%2Fcsv-stream-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobshirley%2Fcsv-stream-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobshirley%2Fcsv-stream-lite/lists"}