Skip to content

Commit

Permalink
feat: ✨ keep emojis on tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
gouz committed Apr 20, 2024
1 parent 379c017 commit c009829
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 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.8",
"version": "0.1.9",
"module": "src/index.ts",
"type": "module",
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/DTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions src/choc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -18,21 +17,21 @@ const choc = async (file: string, options: Options) => {
const { talks, speakers, formats, categories } = json;
const formatsHash = new Map<string, string>();
(formats as Format[]).forEach(({ id, name }) => {
formatsHash.set(id, removeEmojis(name));
formatsHash.set(id, name);
});
const speakerHash = new Map<string, SpeakerData>();
(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<string, string>();
(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
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() || "";
};

0 comments on commit c009829

Please sign in to comment.