-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.js
27 lines (26 loc) · 1.18 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { trimMiddle } from "./index.js";
const demosentences = [
"This is a long string that will be trimmed",
"This is a short string",
"This is a medium string that will be trimmed",
"This 🇺🇳 is 🤡 🐥 a string 🥰 🧑🧑🧒🧒 with compound emoji 😊 ",
"This is a string with a compound emoji 🧑🧑🧒🧒",
"This is a string with a compound emoji 🧑🧑🧒🧒 and a flag 🇺🇳",
"Dies is ein öü deutscher String mit Umlauten äß"
];
demosentences.forEach(sentence => {
console.log(sentence);
console.log(trimMiddle(sentence));
});
console.log(trimMiddle("This is a long string that will be trimmed", 8, "↔"));
// Error cases
// console.log(trimMiddle("This is a long string that will be trimmed", 16, "…"));
// console.log(trimMiddle(4, 16, "…"));
// console.log(trimMiddle("This is a long string that will be trimmed", "16", "…"));
// console.log(trimMiddle("This is a long string that will be trimmed", 4, "…"));
// console.log(trimMiddle("This is a long string that will be trimmed", 16, 4));
console.log(trimMiddle(
"This is a long string that will be trimmed",
11,
"0123456789"
));