Skip to content

Commit

Permalink
0.2.0 - Separated IO classes with and without fs dependent (#4)
Browse files Browse the repository at this point in the history
* Restructured IO directory

* Separated feed reader classes

* Update writer classes

* Updated documents

* Updated exporting
  • Loading branch information
ponlawat-w authored Dec 9, 2023
1 parent 16131d0 commit c612638
Show file tree
Hide file tree
Showing 19 changed files with 736 additions and 569 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Added .js to relative module paths
Splited IO classes between `fs` dependent (for Node) and `fs` independent (for Browser).
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ npm i gtfs-io

```ts
// Synchronously
import { GTFSFeedReader } from 'gtfs-io';
const reader = GTFSFeedReader.fromZip('gtfs.zip');
const reader = GTFSFeedReader.fromDirectory('path/to/dir');
import { GTFSFeedReaderFromFile } from 'gtfs-io';
const reader = GTFSFeedReaderFromFile.fromZip('gtfs.zip');
const reader = GTFSFeedReaderFromFile.fromDirectory('path/to/dir');
const feed = reader.loadFeed();
console.log(feed.stops[0].stop_id);
console.log(feed.trips[1].trip_id);

// Asynchronously
import { GTFSAsyncFeedReader } from 'gtfs-io';
const reader = GTFSAsyncFeedReader.fromZip('gtfs.zip');
const reader = GTFSAsyncFeedReader.fromDirectory('path/to/dir');
import { GTFSAsyncFeedReaderFromFile } from 'gtfs-io';
const reader = GTFSAsyncFeedReaderFromFile.fromZip('gtfs.zip');
const reader = GTFSAsyncFeedReaderFromFile.fromDirectory('path/to/dir');
const feed = await reader.loadFeed();
console.log(feed.stops[0].stop_id);
console.log(feed.trips[1].trip_id);
Expand All @@ -43,14 +43,14 @@ const feed = new GTFSLoadedFeed({
});

// Synchronously
import { GTFSFeedWriter } from 'gtfs-io';
GTFSFeedWriter.writeZip(feed, 'gtfs.zip');
GTFSFeedWriter.writeDirectory(feed, 'path/to/dir');
import { GTFSFeedWriterToFile } from 'gtfs-io';
GTFSFeedWriterToFile.asZip(feed, 'gtfs.zip');
GTFSFeedWriterToFile.asDirectory(feed, 'path/to/dir');

// Asynchronously
import { GTFSAsyncFeedWriter } from 'gtfs-io';
await GTFSAsyncFeedWriter.writeZip(feed, 'gtfs.zip');
await GTFSAsyncFeedWriter.writeDirectory(feed, 'path/to/dir');
import { GTFSAsyncFeedWriterToFile } from 'gtfs-io';
await GTFSAsyncFeedWriterToFile.asZip(feed, 'gtfs.zip');
await GTFSAsyncFeedWriterToFiler.asDirectory(feed, 'path/to/dir');
```

---
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gtfs-io",
"type": "module",
"version": "0.1.0",
"version": "0.2.0",
"description": "IO operations for reading and writing GTFS datasets and GTFS type definitions.",
"main": "dist/index.js",
"keywords": [
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export { GTFSFileIO, GTFSAsyncFileIO } from './io/file.js';
export * from './io/feed-file.js';
export { GTFSFeedReader, GTFSAsyncFeedReader } from './io/feed-reader.js';
export { GTFSFeedWriter, GTFSAsyncFeedWriter } from './io/feed-writer.js';
export { GTFSFileIO, GTFSAsyncFileIO } from './io/file/main.js';
export * from './io/feed/file.js';
export { GTFSFeedReaderFromFile, GTFSAsyncFeedReaderFromFile } from './io/feed/reader-fs.js';
export { GTFSFeedReaderFromMemory, GTFSAsyncFeedReaderFromMemory } from './io/feed/reader-memory.js';
export { GTFSFeedWriter, GTFSAsyncFeedWriter } from './io/feed/writer.js';
export { GTFSFeedWriterToFile, GTFSAsyncFeedWriterToFile } from './io/feed/writer-fs.js';

export * from './feed/iterable.js';
export * from './feed/loaded.js';
Expand All @@ -24,7 +26,7 @@ export { GTFSTripDirection, GTFSTripBikesAllowed } from './files/trip.js';
export type * from './file-info';
export type * from './types';

export type * from './io/types';
export type * from './io/file/types';

export type * from './files/agency';
export type * from './files/area';
Expand Down
Loading

0 comments on commit c612638

Please sign in to comment.