nested_json_to_csv
Version:
23 lines (21 loc) • 713 B
text/typescript
import { IFactory } from "../../interfaces/IFactory";
import { CsvParserService } from "../services/CsvParserService";
import { JsonParserService } from "../services/JsonParserService";
export class ParserFactory implements IFactory {
make(className: string, ...args: any[]) {
try {
if (className == "jsonParser") {
return new JsonParserService(args[0], args[1]);
}
if (className == "csvParser") {
return new CsvParserService(args[0]);
}
//TODO: add NULL desgin pattern here
} catch (error) {
console.log(error);
throw new Error(
"Something broke in the facotry please make sure you are passing the right paramers"
);
}
}
}