{"_id":"@abdullah_zughbi/csvt-parse","_rev":"9-f62e1a33b600bcc55bc31c31f86e54df","name":"@abdullah_zughbi/csvt-parse","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.2":{"name":"@abdullah_zughbi/csvt-parse","version":"1.0.2","keywords":["csv","parser","typescript","schema","validation"],"author":{"name":"Abdullah Zughbi"},"license":"MIT","_id":"@abdullah_zughbi/csvt-parse@1.0.2","maintainers":[{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"}],"dist":{"shasum":"f84c07dc6758e3221aa96beabdf8f40dda39c97d","tarball":"https://registry.npmjs.org/@abdullah_zughbi/csvt-parse/-/csvt-parse-1.0.2.tgz","fileCount":7,"integrity":"sha512-Olnmczn/fQFJb09vugbm4o0+/U+PzfGifGjR3S5vGbDjbn35ehXB7quS3Gx+cLivaAHBXiwoP/Dj1nAD4lE04g==","signatures":[{"sig":"MEYCIQC+nfPXPwJ0dFhImKwbU/nkcDOJlbW9n4ITqmGjYZff7AIhAMnefdIWoa9fzoUM7wxlQCPHML41nPEUjbKuqgIAqjch","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39278},"main":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"},"./examples/basic-usage":"./examples/basic-usage.js"},"_npmUser":{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"},"_npmVersion":"11.3.0","description":"Type-safe CSV parser with schema validation","directories":{},"_nodeVersion":"24.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/csvt-parse_1.0.2_1753062371743_0.35664978214523146","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@abdullah_zughbi/csvt-parse","version":"1.1.0","keywords":["csv","parser","typescript","schema","validation"],"author":{"name":"Abdullah Zughbi"},"license":"MIT","_id":"@abdullah_zughbi/csvt-parse@1.1.0","maintainers":[{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"}],"homepage":"https://github.com/AbdullahZughbi/csvt-parse#readme","bugs":{"url":"https://github.com/AbdullahZughbi/csvt-parse/issues"},"dist":{"shasum":"61326603e4f084f3712aabedbe8ae3b287fb7520","tarball":"https://registry.npmjs.org/@abdullah_zughbi/csvt-parse/-/csvt-parse-1.1.0.tgz","fileCount":10,"integrity":"sha512-rza+y2JtbT7I0vBRnK8EF5LqWOdtWZ2P7XKB/Bmp5HHAhRKnt1JeURoEsmPGKB5QSz2t3DfPbJREci74RiKCCw==","signatures":[{"sig":"MEYCIQCOqJPLVcHuzWmdBwTWPy9S3nSqGQYe6JCIZOzBh+WvagIhAIbJM2s1JBlWgOtgxescBPS09ocq6+rGzbzWFV50dP6a","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69526},"main":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"},"./examples/basic-usage":"./examples/basic-usage.js"},"gitHead":"0f040a6bac3654585f6873a95761b4e2a95327e4","_npmUser":{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"},"repository":{"url":"git+https://github.com/AbdullahZughbi/csvt-parse.git","type":"git"},"_npmVersion":"11.3.0","description":"Type-safe CSV parser with schema validation","directories":{},"_nodeVersion":"24.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/csvt-parse_1.1.0_1753134162484_0.1890582107802945","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@abdullah_zughbi/csvt-parse","version":"1.1.2","description":"Type-safe CSV parser with schema validation","main":"./index.bundle.js","types":"./index.d.ts","exports":{".":{"require":"./index.bundle.js","import":"./index.bundle.js","types":"./index.d.ts"},"./examples/basic-usage":"./examples/basic-usage.js"},"keywords":["csv","parser","typescript","schema","validation"],"author":{"name":"Abdullah Zughbi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/AbdullahZughbi/csvt-parse.git"},"bugs":{"url":"https://github.com/AbdullahZughbi/csvt-parse/issues"},"homepage":"https://github.com/AbdullahZughbi/csvt-parse#readme","_id":"@abdullah_zughbi/csvt-parse@1.1.2","gitHead":"b15d6f43e4e03f32d435ee4bc30dea620fe56768","_nodeVersion":"24.2.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-iKDCIWM7DJQpoeGjaVeipgV8ei4ldYq03aSjOznXWB8mhHPmkfNK/+chcU7D7PsEHwHEXSRZW1IwBYmKXcrZkA==","shasum":"cbaa18887b266c04e3abc62e64d79095bf07844d","tarball":"https://registry.npmjs.org/@abdullah_zughbi/csvt-parse/-/csvt-parse-1.1.2.tgz","fileCount":103,"unpackedSize":305911,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFcBR+NQAjDYP7zZeUhX2+o1nN1S+dseifxC5c0T/BhkAiEA9vsTEAIW0SUF9aNW2T1M2Miidydj1jU20E8NO3NuTzs="}]},"_npmUser":{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"},"directories":{},"maintainers":[{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/csvt-parse_1.1.2_1753139198373_0.5666286539100411"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-21T01:07:36.452Z","modified":"2025-07-21T23:06:39.018Z","1.0.0":"2025-07-21T01:07:37.049Z","1.0.1":"2025-07-21T01:45:28.284Z","1.0.2":"2025-07-21T01:46:11.953Z","1.1.0":"2025-07-21T21:42:42.658Z","1.1.1":"2025-07-21T22:59:18.350Z","1.1.2":"2025-07-21T23:06:38.542Z"},"bugs":{"url":"https://github.com/AbdullahZughbi/csvt-parse/issues"},"author":{"name":"Abdullah Zughbi"},"license":"MIT","homepage":"https://github.com/AbdullahZughbi/csvt-parse#readme","keywords":["csv","parser","typescript","schema","validation"],"repository":{"type":"git","url":"git+https://github.com/AbdullahZughbi/csvt-parse.git"},"description":"Type-safe CSV parser with schema validation","maintainers":[{"name":"abdullah_zughbi","email":"abdullahzughbi159@gmail.com"}],"readme":"# CSVT-Parse\n\nA powerful Node.js library for parsing and writing CSV files with typed column definitions. CSVT-Parse provides comprehensive type validation and robust error handling for working with structured CSV data.\n\n## Features\n\n- 🎯 **Typed Column Definitions**: Define column types directly in the CSV header (`name:string,age:number`)\n- 🔍 **Comprehensive Type Validation**: Built-in validation for 20+ data types including primitives, dates, URLs, emails, UUIDs, and more\n- 🔧 **Enum Types**: Define columns with restricted value sets (`status:enum(pending,approved,rejected)`)\n- 🔀 **Union Types**: Support multiple types per column (`value:string|number|boolean`)\n- 🌟 **Any Type**: Auto-detecting flexible type that infers the best match (`data:any`)\n- 📁 **File I/O Support**: Read from and write to files with async/sync APIs\n- 🛡️ **Error Handling**: Comprehensive error reporting with line and column context\n- 🚀 **High Performance**: Optimized parsing with minimal overhead\n- 📦 **TypeScript First**: Full TypeScript support with complete type definitions\n- 🔒 **Source Protection**: Obfuscated distribution for commercial use\n\n## Installation\n\n```bash\nnpm install @abdullah_zughbi/csvt-parse\n```\n\n## Quick Start\n\n### Basic Usage\n\n```javascript\nconst csvt = require('@abdullah_zughbi/csvt-parse');\n\n// Parse CSVT content with typed columns\nconst csvtContent = `name:string,age:number,active:boolean\n\"John Doe\",30,true\n\"Jane Smith\",25,false`;\n\nconst result = csvt.parseCSVTSync(csvtContent);\nconsole.log(result.data);\n// Output: [\n//   { name: \"John Doe\", age: 30, active: true },\n//   { name: \"Jane Smith\", age: 25, active: false }\n// ]\n```\n\n### File Operations\n\n```javascript\n// Read from CSVT file\nconst fileData = csvt.readFileSync('data.csvt');\nconsole.log(fileData.data);\n\n// Write to CSVT file\nconst data = [\n  { name: 'Alice', score: 95, active: true },\n  { name: 'Bob', score: 87, active: false }\n];\n\nconst columns = [\n  { name: 'name', type: 'string' },\n  { name: 'score', type: 'number' },\n  { name: 'active', type: 'boolean' }\n];\n\ncsvt.writeFileSync('output.csvt', data, columns);\n```\n\n### Complex Data Types\n\n```javascript\n// JSON objects and arrays\nconst complexCSVT = `user:string,preferences:json,history:array\n\"alice\",\"{\"\"theme\"\":\"\"dark\"\",\"\"lang\"\":\"\"en\"\"}\",\"[\"\"login\"\",\"\"purchase\"\"]\"`;\n\nconst result = csvt.parseCSVTSync(complexCSVT);\nconsole.log(result.data[0]);\n// Output: {\n//   user: \"alice\",\n//   preferences: { theme: \"dark\", lang: \"en\" },\n//   history: [\"login\", \"purchase\"]\n// }\n```\n\n### Enum Types\n\n```javascript\n// Restricted value sets\nconst enumCSVT = `status:enum(pending,approved,rejected),priority:enum(low,medium,high)\n\"pending\",\"high\"\n\"approved\",\"medium\"\n\"rejected\",\"low\"`;\n\nconst enumResult = csvt.parseCSVTSync(enumCSVT);\nconsole.log(enumResult.data);\n// Output: [\n//   { status: \"pending\", priority: \"high\" },\n//   { status: \"approved\", priority: \"medium\" },\n//   { status: \"rejected\", priority: \"low\" }\n// ]\n```\n\n### Union Types\n\n```javascript\n// Multiple type options per column\nconst unionCSVT = `id:string|number,value:number|boolean,mixed:string|number|boolean\n\"user123\",42,true\n\"456\",3.14,\"hello\"\n\"789\",0,false`;\n\nconst unionResult = csvt.parseCSVTSync(unionCSVT);\nconsole.log(unionResult.data);\n// Output: [\n//   { id: \"user123\", value: 42, mixed: \"true\" },\n//   { id: \"456\", value: 3.14, mixed: \"hello\" },\n//   { id: \"789\", value: 0, mixed: \"false\" }\n// ]\n```\n\n### Any Type\n\n```javascript\n// Auto-detecting flexible type\nconst anyCSVT = `name:string,data:any,info:any\n\"John\",42,\"text value\"\n\"Jane\",true,\"[1,2,3]\"\n\"Bob\",\"{\"\"key\"\":\"\"value\"\"}\",123.45`;\n\nconst anyResult = csvt.parseCSVTSync(anyCSVT);\nconsole.log(anyResult.data);\n// Output: [\n//   { name: \"John\", data: 42, info: \"text value\" },\n//   { name: \"Jane\", data: true, info: [1,2,3] },\n//   { name: \"Bob\", data: {\"key\":\"value\"}, info: 123.45 }\n// ]\n```\n\n### Escape Sequences\n\n```javascript\n// Enable escape sequence processing for string fields\nconst escapeCSVT = `message:string,path:string\n\"Line 1\\\\nLine 2\",\"C:\\\\\\\\Users\\\\\\\\file.txt\"`;\n\n// Default behavior - preserves literal backslashes\nconst defaultResult = csvt.parseCSVTSync(escapeCSVT, { processEscapes: false });\nconsole.log(defaultResult.data[0].message); // \"Line 1\\\\nLine 2\"\n\n// With escape processing - converts sequences to actual characters\nconst processedResult = csvt.parseCSVTSync(escapeCSVT, { processEscapes: true });\nconsole.log(processedResult.data[0].message); \n// Output: \"Line 1\n//          Line 2\"\n\n// Supported escape sequences: \\\\n \\\\t \\\\r \\\\\" \\\\\\\\\n```\n\n## Supported Types\n\n### Basic Types\n| Type     | Description        | Example                  |\n|----------|--------------------|--------------------------|\n| `string` | Text values        | `\"Hello World\"`          |\n| `number` | Integer or float   | `42`, `3.14`             |\n| `boolean`| Boolean values     | `true`, `false`, `1`, `0`, `yes`, `no` |\n| `array`  | JSON arrays        | `[\"item1\", \"item2\"]`     |\n| `json`   | JSON objects       | `{\"key\": \"value\"}`       |\n| `any`    | Auto-detecting type| Auto-infers best type    |\n| `void`   | Null/empty values  | `null`, `\"\"`             |\n\n### Date & Time Types\n| Type       | Description      | Example                    |\n|------------|------------------|----------------------------|\n| `date`     | Date only        | `\"2024-01-15\"`            |\n| `datetime` | Date with time   | `\"2024-01-15T10:30:00Z\"`  |\n| `time`     | Time only        | `\"10:30:00\"`              |\n\n### Web & Network Types\n| Type        | Description     | Example                        |\n|-------------|-----------------|--------------------------------|\n| `url`       | HTTP/HTTPS URLs | `\"https://example.com\"`        |\n| `email`     | Email addresses | `\"user@example.com\"`          |\n| `ipaddress` | IP addresses    | `\"192.168.1.1\"`               |\n\n### Visual Types\n| Type        | Description      | Example              |\n|-------------|------------------|----------------------|\n| `hexcolor`  | Hex colors       | `\"#FF0000\"`         |\n| `rgba`      | RGBA colors      | `\"rgba(255,0,0,0.5)\"`|\n| `color`     | Named/hex colors | `\"red\"`, `\"#FF0000\"`|\n\n### Identifier Types\n| Type         | Description | Example                        |\n|--------------|-------------|--------------------------------|\n| `uuid`       | UUIDs       | `\"550e8400-e29b-41d4-a716-446655440000\"` |\n| `percentage` | Percentages | `\"75%\"`                        |\n\n### Advanced Types\n| Type    | Description              | Example                          |\n|---------|--------------------------|----------------------------------|\n| `enum`  | Restricted value set     | `status:enum(pending,approved,rejected)` |\n| `union` | Multiple type options    | `value:string\\|number\\|boolean`   |\n\n### Length-Specified Text\n| Type          | Description                    | Example                    |\n|---------------|--------------------------------|----------------------------|\n| `text`        | Unlimited text length          | `description:text`         |\n| `varchar(n)`  | Variable length, max n chars   | `name:varchar(50)`        |\n| `char(n)`     | Fixed length, padded to n chars | `code:char(10)`          |\n\n## API Reference\n\n### Parsing Functions\n\n- `parseCSVTSync(content, options)` - Synchronous parsing\n- `parseCSVT(content, options)` - Asynchronous parsing (returns Promise)\n\n### File Operations\n\n- `readFileSync(filename, options)` - Synchronous file reading\n- `readFile(filename, options)` - Asynchronous file reading\n- `writeFileSync(filename, data, columns, options)` - Synchronous file writing\n- `writeFile(filename, data, columns, options)` - Asynchronous file writing\n\n### Error Handling\n\n```javascript\ntry {\n  const result = csvt.parseCSVTSync(content, { strict: true });\n} catch (error) {\n  if (error instanceof csvt.ValidationError) {\n    console.log(`Error in column \"${error.column}\" at line ${error.line}`);\n    console.log(`Expected: ${error.expectedType}, Got: ${error.actualValue}`);\n  }\n}\n```\n\n### Options\n\n```javascript\nconst options = {\n  delimiter: ',',        // Field delimiter\n  quote: '\"',           // Quote character\n  escape: '\"',          // Escape character\n  skipEmptyLines: true, // Skip empty lines\n  trim: true,           // Trim whitespace\n  strict: false,        // Strict error handling\n  processEscapes: false // Process escape sequences in string fields\n};\n```\n\n#### Escape Sequence Processing\n\nWhen `processEscapes: true` is enabled, the following escape sequences are processed in string fields:\n\n| Sequence | Result | Description |\n|----------|---------|-------------|\n| `\\\\n`    | `\\n`    | Newline character |\n| `\\\\t`    | `\\t`    | Tab character |\n| `\\\\r`    | `\\r`    | Carriage return |\n| `\\\\\"`    | `\"`     | Quote character |\n| `\\\\\\\\`   | `\\`     | Backslash character |\n\n**Important Notes:**\n- Escape processing only applies to `string` type fields\n- For `union` types, processing applies only if the final parsed value is a string\n- Complex types like `json` and `array` are not affected by escape processing\n- Default behavior preserves literal backslashes for compatibility\n\n\n## License\n\nMIT License © 2025 Abdullah Zughbi\n","readmeFilename":"README.md"}