-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-basic-usage.ts
More file actions
26 lines (23 loc) · 783 Bytes
/
Copy path01-basic-usage.ts
File metadata and controls
26 lines (23 loc) · 783 Bytes
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
/**
* @simpill/string.utils - Basic usage
*
* Run: npx ts-node examples/01-basic-usage.ts
*/
import {
formatString,
StringBuilder,
slugify,
toCamelCase,
truncate,
truncateWords,
} from "@simpill/string.utils";
const builder = new StringBuilder()
.append("Hello ")
.appendFormat("{name}", { name: "Ada" })
.appendLine("!");
console.log("StringBuilder:", builder.toString());
console.log("formatString('User: {0}', ['Ada']):", formatString("User: {0}", ["Ada"]));
console.log("toCamelCase('hello-world'):", toCamelCase("hello-world"));
console.log("truncate('hello world', 8):", truncate("hello world", 8));
console.log("truncateWords('one two three', 2):", truncateWords("one two three", 2));
console.log("slugify('Creme brulee'):", slugify("Creme brulee"));