@esmate/utils 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/string.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,8 +23,7 @@ npm install @esmate/utils
|
|
|
23
23
|
|
|
24
24
|
### ESToolkit Utilities
|
|
25
25
|
|
|
26
|
-
Access [es-toolkit](https://es-toolkit.dev/reference/array/at.html) functions through the main package export
|
|
27
|
-
dedicated toolkit subpath.
|
|
26
|
+
Access [es-toolkit](https://es-toolkit.dev/reference/array/at.html) functions through the main package export.
|
|
28
27
|
|
|
29
28
|
```ts
|
|
30
29
|
import { delay, invariant } from "@esmate/utils";
|
|
@@ -61,6 +60,14 @@ import { round, sqrt } from "@esmate/utils/math";
|
|
|
61
60
|
|
|
62
61
|
### String Utilities
|
|
63
62
|
|
|
63
|
+
Access **string** utilities for common string operations.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { fixTypos, titleize } from "@esmate/utils";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
📚 **Documentation**: [View source](https://github.com/VienDinhCom/esmate/blob/main/packages/utils/src/string.ts)
|
|
70
|
+
|
|
64
71
|
#### `titleize()`
|
|
65
72
|
|
|
66
73
|
Converts strings to proper title case using the [title](https://www.npmjs.com/package/title) package.
|
|
@@ -75,8 +82,6 @@ const chicagoTitle = titleize("love of my life", { style: "chicago" }); // "Love
|
|
|
75
82
|
const specialTitle = titleize("i love ESMate", { special: ["ESMate"] }); // "I Love ESMate"
|
|
76
83
|
```
|
|
77
84
|
|
|
78
|
-
📚 **Documentation**: [View source](https://github.com/VienDinhCom/esmate/blob/main/packages/utils/src/string.ts)
|
|
79
|
-
|
|
80
85
|
#### `fixTypos()`
|
|
81
86
|
|
|
82
87
|
Automatically corrects common typographical errors using [typopo](https://www.npmjs.com/package/typopo).
|
|
@@ -86,5 +91,3 @@ import { fixTypos } from "@esmate/utils/string";
|
|
|
86
91
|
|
|
87
92
|
const result = fixTypos("This is a text with typos..."); // "This is a text with typos…"
|
|
88
93
|
```
|
|
89
|
-
|
|
90
|
-
📚 **Documentation**: [View source](https://github.com/VienDinhCom/esmate/blob/main/packages/utils/src/string.ts)
|
package/dist/string.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Configuration, Locale } from "typopo";
|
|
|
3
3
|
* Formats a string to be used as a title.
|
|
4
4
|
* @param str The string to format.
|
|
5
5
|
* @param options The options to use.
|
|
6
|
+
* @param options.style The style of the title.
|
|
7
|
+
* @param options.special A list of special words to keep as-is.
|
|
6
8
|
* @returns The formatted string.
|
|
7
9
|
*/
|
|
8
10
|
export declare function titleize(str: string, options?: {
|
|
@@ -12,7 +14,8 @@ export declare function titleize(str: string, options?: {
|
|
|
12
14
|
/**
|
|
13
15
|
* Fixes typos in a string using typopo.
|
|
14
16
|
* @param str The string to fix.
|
|
15
|
-
* @param options The options to use.
|
|
17
|
+
* @param options The options to use, including `typopo` configuration.
|
|
18
|
+
* @param options.locale The locale to use (e.g., "en-us", "ru").
|
|
16
19
|
* @returns The fixed string.
|
|
17
20
|
*/
|
|
18
21
|
export declare function fixTypos(str: string, options?: Configuration & {
|