Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions i7h.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const i18n = (str) => {
if (typeof str !== "string") {
throw new Error("Not string");
}

return str.replace(/\w+/g, ellipsis);
};

const ellipsis = (word) => {
if (word.length < 3) {
return word;
}

return `${word.slice(0, 1)}${word.length - 2}${word.slice(-1)}`;
};