Skip to content

Commit

Permalink
refactor: rename the method opening source/sink of repository
Browse files Browse the repository at this point in the history
  • Loading branch information
tasshi-me committed Apr 27, 2023
1 parent 94644f6 commit 1766365
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/record/export/repositories/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CliKintoneError } from "../../../utils/error";
export class RepositoryError extends CliKintoneError {
constructor(cause: unknown) {
const message =
"An error occurred while exporting records to the data destination";
"An error occurred while exporting records to the data sink";
super(message, cause);

this.name = "RepositoryError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { stringifierFactory } from "./stringifiers";
export class LocalRecordRepositoryFromStream implements LocalRecordRepository {
readonly format = "csv";

private readonly destination: () => NodeJS.WritableStream;
private readonly openWritableSink: () => NodeJS.WritableStream;
private readonly schema: RecordSchema;
private readonly useLocalFilePath: boolean;

constructor(
destination: () => NodeJS.WritableStream,
openWritableSink: () => NodeJS.WritableStream,
schema: RecordSchema,
useLocalFilePath: boolean
) {
this.destination = destination;
this.openWritableSink = openWritableSink;
this.schema = schema;
this.useLocalFilePath = useLocalFilePath;
}
Expand All @@ -24,7 +24,7 @@ export class LocalRecordRepositoryFromStream implements LocalRecordRepository {
schema: this.schema,
useLocalFilePath: this.useLocalFilePath,
});
stringifier.pipe(this.destination());
stringifier.pipe(this.openWritableSink());
return stringifier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export class LocalRecordRepositoryFromStream implements LocalRecordRepository {
readonly reader: () => AsyncGenerator<LocalRecord, void, undefined>;

constructor(
source: () => NodeJS.ReadableStream,
openReadableSource: () => NodeJS.ReadableStream,
format: string,
schema: RecordSchema
) {
this.format = format;
this.length = () => countRecordsFromCsv(source());
this.length = () => countRecordsFromCsv(openReadableSource());

switch (format) {
case "csv":
this.reader = () => csvReader(source, schema);
this.reader = () => csvReader(openReadableSource, schema);
break;
default:
throw new RepositoryError(
Expand Down

0 comments on commit 1766365

Please sign in to comment.