diff --git a/package.json b/package.json index 579d536..bff7809 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choc", - "version": "0.1.8", + "version": "0.1.9", "module": "src/index.ts", "type": "module", "devDependencies": { diff --git a/src/DTO.ts b/src/DTO.ts index 823c23a..397a732 100644 --- a/src/DTO.ts +++ b/src/DTO.ts @@ -47,12 +47,12 @@ export const DTO = ( let addFormats = {}; if (options.withFormats) addFormats = { - format: formatsHash.get(formats), + format: removeEmojis(formatsHash.get(formats)), }; let addCategories = {}; if (options.withCategories) addCategories = { - categories: categoriesHash.get(categories), + categories: removeEmojis(categoriesHash.get(categories)), }; let addLanguages = {}; if (options.withLanguages) diff --git a/src/choc.ts b/src/choc.ts index 6fb7cae..c924630 100644 --- a/src/choc.ts +++ b/src/choc.ts @@ -8,7 +8,6 @@ import type { Talk, TalkRow, } from "./types"; -import { removeEmojis } from "./utils"; const choc = async (file: string, options: Options) => { const json = await Bun.file(file).json(); @@ -18,21 +17,21 @@ const choc = async (file: string, options: Options) => { const { talks, speakers, formats, categories } = json; const formatsHash = new Map(); (formats as Format[]).forEach(({ id, name }) => { - formatsHash.set(id, removeEmojis(name)); + formatsHash.set(id, name); }); const speakerHash = new Map(); (speakers as Speaker[]).forEach( ({ uid, displayName, company, address }) => { speakerHash.set(uid, { - name: removeEmojis(displayName), - company: removeEmojis(company ?? ""), - address: removeEmojis(address?.formattedAddress ?? ""), + name: displayName, + company: company ?? "", + address: address?.formattedAddress ?? "", }); } ); const categoriesHash = new Map(); (categories as Format[]).forEach(({ id, name }) => { - categoriesHash.set(id, removeEmojis(name)); + categoriesHash.set(id, name); }); const talksLines = (talks as Talk[]).sort((a, b) => a.rating <= b.rating ? 1 : -1 diff --git a/src/utils.ts b/src/utils.ts index ab9d4a7..6b093fd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -17,6 +17,6 @@ export const splitString = (str: string, n: number): string[] => { return result; }; -export const removeEmojis = (str: string): string => { - return str?.replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "").trim(); +export const removeEmojis = (str: string | undefined): string => { + return str?.replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "").trim() || ""; };