Skip to content

Commit 262aa43

Browse files
authored
tests->test + add examples/ and npm run examples (#27)
* tests->test + add examples/ and npm run examples * export more types, and edit README * add github action for typedoc * fix docs + change lint scripts + adapt ci action
1 parent 5d2a6b3 commit 262aa43

31 files changed

Lines changed: 424 additions & 92 deletions

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@ jobs:
1313
- run: npm ci
1414
- run: npm run build
1515

16-
lint:
16+
eslint:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
2020
- run: npm ci
21-
- run: npm run lint
21+
- run: npm run lint:eslint
2222

23-
typecheck:
23+
lint-types:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
2727
- run: npm ci
28-
- run: npm run typecheck
28+
- run: npm run lint:types
29+
30+
lint-docs:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- run: npm ci
35+
- run: npm run lint:docs
2936

3037
test-node:
3138
runs-on: ubuntu-latest

.github/workflows/docs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: TSDoc Actions
3+
4+
on:
5+
push:
6+
# Trigger deployment only on pushes to the main branch
7+
branches:
8+
- main
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
jobs:
19+
# Single deploy job since we're just deploying
20+
deploy:
21+
name: Deploy Documentation
22+
23+
# Deploy to the github-pages environment
24+
environment:
25+
name: github-pages
26+
url: ${{ steps.deployment.outputs.page_url }}
27+
28+
# Specify runner + deployment step
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
34+
- name: Setup Node
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: 25
38+
cache: "npm"
39+
40+
- name: TSDoc Action
41+
uses: erikyo/tsdoc-action@v1
42+
with:
43+
source_dir: ./src/*
44+
output_dir: ./docs
45+
front_page: README.md
46+
47+
- name: Setup Pages
48+
uses: actions/configure-pages@v3
49+
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v2
52+
with:
53+
# Upload entire repository
54+
path: "./docs"
55+
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@v2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ dist
55

66
# Vitest
77
/coverage/
8+
9+
/docs/

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## [0.0.7]
1717

18-
- export toURL utility function
18+
- export toBlobURL utility function
1919

2020
## [0.0.6]
2121

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010
Fetch and parse ranges of CSV file.
1111

12-
## Early version
13-
14-
This is an early version. The API may change completely:
15-
16-
- until version 0.1.0, breaking changes may be introduced at any time.
17-
- from version 0.1.0 to 1.0.0, breaking changes will be introduced only in minor versions.
18-
- from version 1.0.0, breaking changes will be introduced only in major versions.
19-
2012
## Install
2113

2214
```bash
@@ -37,6 +29,14 @@ console.log(rows)
3729
// Output: [ [ 'A', 'B', 'C' ], [ 'X', 'Y', 'Z' ] ]
3830
```
3931

32+
## Early version
33+
34+
This is an early version. The API may change completely:
35+
36+
- until version 0.1.0, breaking changes may be introduced at any time.
37+
- from version 0.1.0 to 1.0.0, breaking changes will be introduced only in minor versions.
38+
- from version 1.0.0, breaking changes will be introduced only in major versions.
39+
4040
## Thanks
4141

4242
The code is heavily inspired by [Papaparse](https://www.papaparse.com/).

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ export default defineConfig([
3030
'simple-import-sort/exports': 'error',
3131
'jsdoc/require-yields-type': 'off',
3232
'jsdoc/require-param-type': 'off',
33+
'jsdoc/require-property-type': 'off',
3334
'jsdoc/require-returns-type': 'off',
3435
},
3536
},
3637
{
37-
files: ['tests/*.ts'],
38+
files: ['examples/**/*.ts', 'test/**/*.ts'],
3839
rules: {
3940
'jsdoc/require-jsdoc': 'off',
4041
},

examples/examples.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expect, it } from 'vitest'
2+
3+
import { type ParseResult, parseURL } from '../src'
4+
5+
describe('README examples', () => {
6+
it('parses a remote CSV file', async () => {
7+
const rows = []
8+
for await (const { row } of parseURL('https://data.source.coop/severo/csv-papaparse-test-files/sample.csv')) {
9+
rows.push(row)
10+
}
11+
expect(rows).toEqual([['A', 'B', 'C'], ['X', 'Y', 'Z']])
12+
})
13+
14+
it('parses a remote CSV, and we can use Array.fromAsync for convenience', async () => {
15+
// The test might fail if fromAsync is not yet available in the node.js version running the tests
16+
17+
// @ts-expect-error ts(2345) - fromAsync is available now
18+
const rows = await Array.fromAsync(
19+
parseURL('https://data.source.coop/severo/csv-papaparse-test-files/sample.csv'),
20+
async (result: ParseResult) => result.row,
21+
)
22+
expect(rows).toEqual([['A', 'B', 'C'], ['X', 'Y', 'Z']])
23+
})
24+
})

0 commit comments

Comments
 (0)