Skip to content

Commit

Permalink
feat: ✨ Simplify companies and addresses on tsv export
Browse files Browse the repository at this point in the history
  • Loading branch information
gouz committed Apr 18, 2024
1 parent ad513e0 commit cea63e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "choc",
"version": "0.1.5",
"version": "0.1.6",
"module": "src/index.ts",
"type": "module",
"devDependencies": {
Expand Down
17 changes: 11 additions & 6 deletions src/DTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export const DTO = (
}
);

const cleanArray = (arrayString: (string | undefined)[]): string[] =>
Array.from(
new Set(arrayString.map((c) => c?.toLowerCase() || "").filter((c) => c))
).sort();

export const DTOExport = (
talks: Talk[],
options: Options,
Expand Down Expand Up @@ -136,16 +141,16 @@ export const DTOExport = (
let addCompanies = {};
if (options.withCompanies)
addCompanies = {
company: speakers
.map((uid: string) => speakerHash.get(uid)?.company)
.join(", "),
company: cleanArray(
speakers.map((uid: string) => speakerHash.get(uid)?.company)
).join(", "),
};
let addAddresses = {};
if (options.withAddresses)
addAddresses = {
address: speakers
.map((uid: string) => speakerHash.get(uid)?.address)
.join(", "),
address: cleanArray(
speakers.map((uid: string) => speakerHash.get(uid)?.address)
),
};
let addLink = {};
if (options.links) {
Expand Down

0 comments on commit cea63e7

Please sign in to comment.