@cfworker/csv 1.10.2 → 1.11.0
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/dist/encode.d.ts +2 -1
- package/package.json +5 -5
- package/src/encode.ts +3 -6
- package/tsconfig.json +7 -2
package/dist/encode.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
export declare function encode(rows: any[]): ReadableStream;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfworker/csv",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Streaming CSV encoding for Cloudflare Workers and service workers",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"test": "cfworker test test/**/*.spec.ts"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@cfworker/dev": "^1.
|
|
31
|
-
"@types/chai": "^4.2.
|
|
32
|
-
"@types/mocha": "^
|
|
30
|
+
"@cfworker/dev": "^1.11.0",
|
|
31
|
+
"@types/chai": "^4.2.22",
|
|
32
|
+
"@types/mocha": "^9.0.0",
|
|
33
33
|
"chai": "^4.3.4",
|
|
34
|
-
"mocha": "^
|
|
34
|
+
"mocha": "^9.1.3",
|
|
35
35
|
"typescript": "^4.5.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/encode.ts
CHANGED
|
@@ -4,9 +4,9 @@ const delimiter = ',';
|
|
|
4
4
|
const rowDelimiter = '\r\n';
|
|
5
5
|
const requiresQuoteRegex = /["\r\n,]/;
|
|
6
6
|
|
|
7
|
-
export function encode(rows: any[]): ReadableStream
|
|
7
|
+
export function encode(rows: any[]): ReadableStream {
|
|
8
8
|
// Cloudflare Workers cannot construct a ReadableStream
|
|
9
|
-
const { readable, writable } = new TransformStream
|
|
9
|
+
const { readable, writable } = new TransformStream();
|
|
10
10
|
|
|
11
11
|
(async () => {
|
|
12
12
|
const writer = writable.getWriter();
|
|
@@ -17,10 +17,7 @@ export function encode(rows: any[]): ReadableStream<Uint8Array> {
|
|
|
17
17
|
return readable;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async function writeRows(
|
|
21
|
-
writer: WritableStreamDefaultWriter<Uint8Array>,
|
|
22
|
-
rows: any[]
|
|
23
|
-
) {
|
|
20
|
+
async function writeRows(writer: WritableStreamDefaultWriter, rows: any[]) {
|
|
24
21
|
const text = new TextEncoder();
|
|
25
22
|
const utf8 = text.encode.bind(text);
|
|
26
23
|
const write = writer.write.bind(writer);
|
package/tsconfig.json
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
"extends": "../../tsconfig-base",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "ES2021",
|
|
5
|
-
"lib": ["esnext"
|
|
6
|
-
"types": [
|
|
5
|
+
"lib": ["esnext"],
|
|
6
|
+
"types": [
|
|
7
|
+
"chai",
|
|
8
|
+
"mocha",
|
|
9
|
+
"@cfworker/worker-types",
|
|
10
|
+
"@cloudflare/workers-types"
|
|
11
|
+
],
|
|
7
12
|
"outDir": "dist",
|
|
8
13
|
"rootDir": "./src"
|
|
9
14
|
},
|