@verifyhash/csv-lite 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 <OWNER-NAME PLACEHOLDER>
3
+ Copyright (c) 2026 verifyhash
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,12 +1,5 @@
1
1
  # csv-lite
2
2
 
3
- <!-- publish-prep -->
4
- > **TODO (owner): pick the final npm name/scope before publishing.**
5
- > The npm name is **not** finalized. `package.json` uses the placeholder
6
- > `PLACEHOLDER-csv-lite` — replace it with the real published name/scope
7
- > before any `npm publish`. Graduation to a package registry is a
8
- > **needs-human** decision, not something this project does on its own.
9
-
10
3
  A tiny, **zero-dependency, zero-network** Node.js library for **RFC 4180** CSV:
11
4
  parse a CSV string into rows (or objects), and turn rows back into CSV text with
12
5
  minimal, correct quoting. One CommonJS file (`index.js`), no install step, no
@@ -14,6 +7,16 @@ I/O — drop it into any project and `require` it.
14
7
 
15
8
  Spec reference: <https://www.rfc-editor.org/rfc/rfc4180>
16
9
 
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @verifyhash/csv-lite
14
+ ```
15
+
16
+ Published as [`@verifyhash/csv-lite`](https://www.npmjs.com/package/@verifyhash/csv-lite);
17
+ source lives in the [verifyhash/libs](https://github.com/verifyhash/libs) monorepo.
18
+ Zero runtime dependencies — you can also vendor the folder directly.
19
+
17
20
  ## Who it's for
18
21
 
19
22
  JavaScript/Node developers who need to read or write CSV correctly — quoted
package/index.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Type declarations for @verifyhash/csv-lite — zero-dependency RFC 4180 CSV
3
+ * parser and stringifier: quoted fields, embedded delimiters/newlines,
4
+ * doubled-quote escapes, header-object mode, custom delimiters.
5
+ *
6
+ * Streaming is out of scope: parse() takes a complete string and returns the
7
+ * fully materialized result. Both functions are pure and throw TypeError on
8
+ * invalid arguments (non-string text, multi-character or quote/newline
9
+ * delimiters, non-array rows, …).
10
+ */
11
+
12
+ /** Options for parse(). */
13
+ export interface ParseOptions {
14
+ /** Single-character field delimiter (default ','). May not be a quote or newline. */
15
+ delimiter?: string;
16
+ /**
17
+ * When true, treat the first row as a header and return an array of objects
18
+ * keyed by the header names (ragged rows: missing trailing cells become '').
19
+ */
20
+ header?: boolean;
21
+ }
22
+
23
+ /** Options for stringify(). */
24
+ export interface StringifyOptions {
25
+ /** Single-character field delimiter (default ','). May not be a quote or newline. */
26
+ delimiter?: string;
27
+ /**
28
+ * When given, `rows` is treated as an array of objects; a header row of
29
+ * these column names is emitted first and each object is projected onto
30
+ * them in order.
31
+ */
32
+ columns?: string[];
33
+ }
34
+
35
+ /**
36
+ * Parse CSV text into rows (RFC 4180: quoted fields, "" escapes, CRLF/LF/CR
37
+ * record separators, one ignorable trailing newline). Every value comes back
38
+ * as a string — no type coercion; empty input yields []. Without
39
+ * { header: true } the result is a 2D array of strings.
40
+ */
41
+ export function parse(
42
+ text: string,
43
+ options?: ParseOptions & { header?: false }
44
+ ): string[][];
45
+ /** Parse with { header: true }: an array of objects keyed by the first row. */
46
+ export function parse(
47
+ text: string,
48
+ options: ParseOptions & { header: true }
49
+ ): Array<Record<string, string>>;
50
+ /** Parse when `header` is not statically known. */
51
+ export function parse(
52
+ text: string,
53
+ options?: ParseOptions
54
+ ): string[][] | Array<Record<string, string>>;
55
+
56
+ /**
57
+ * Serialize a 2D array of cell values to CSV text (LF record separators, no
58
+ * trailing newline). Fields are quoted only when they must be; embedded
59
+ * double-quotes are doubled; non-strings are coerced with String();
60
+ * null/undefined become empty unquoted fields.
61
+ */
62
+ export function stringify(
63
+ rows: ReadonlyArray<ReadonlyArray<unknown>>,
64
+ options?: StringifyOptions & { columns?: undefined }
65
+ ): string;
66
+ /**
67
+ * Serialize an array of objects to CSV text using `columns` as both the
68
+ * emitted header row and the projection order for each object.
69
+ */
70
+ export function stringify(
71
+ rows: ReadonlyArray<Record<string, unknown> | null | undefined>,
72
+ options: StringifyOptions & { columns: string[] }
73
+ ): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifyhash/csv-lite",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency RFC 4180 CSV parser and stringifier for Node.js: quoted fields, embedded delimiters/newlines, doubled-quote escapes, header-object mode, custom delimiters.",
5
5
  "keywords": [
6
6
  "csv",
@@ -14,13 +14,15 @@
14
14
  "zero-dependency"
15
15
  ],
16
16
  "main": "index.js",
17
+ "types": "index.d.ts",
17
18
  "scripts": {
18
19
  "test": "node test/index.test.js"
19
20
  },
20
21
  "license": "MIT",
21
22
  "files": [
22
23
  "index.js",
23
- "README.md"
24
+ "README.md",
25
+ "index.d.ts"
24
26
  ],
25
27
  "publishConfig": {
26
28
  "access": "public"