@esmate/utils 1.3.0 → 1.3.2
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 +14 -18
- package/dist/string.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,21 +10,11 @@ utilities through a unified interface.
|
|
|
10
10
|
npm install @esmate/utils
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- **es-toolkit**: Modern, high-performance utility functions
|
|
16
|
-
- **Lodash compatibility**: Familiar lodash functions reimplemented with es-toolkit
|
|
17
|
-
- **Math operations**: Comprehensive mathematical utilities via math.js
|
|
18
|
-
- **String utilities**: Advanced string manipulation including title case conversion and typo correction
|
|
19
|
-
|
|
20
13
|
---
|
|
21
14
|
|
|
22
|
-
##
|
|
15
|
+
## ESToolkit Utilities
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Access [es-toolkit](https://es-toolkit.dev/reference/array/at.html) functions through the main package export or the
|
|
27
|
-
dedicated toolkit subpath.
|
|
17
|
+
Access [es-toolkit](https://es-toolkit.dev/reference/array/at.html) functions through the main package export.
|
|
28
18
|
|
|
29
19
|
```ts
|
|
30
20
|
import { delay, invariant } from "@esmate/utils";
|
|
@@ -34,7 +24,7 @@ import { delay, invariant } from "@esmate/utils";
|
|
|
34
24
|
|
|
35
25
|
---
|
|
36
26
|
|
|
37
|
-
|
|
27
|
+
## Lodash Utilities
|
|
38
28
|
|
|
39
29
|
Access [lodash](https://lodash.com/docs) functions reimplemented using es-toolkit's compatibility mode for familiar,
|
|
40
30
|
drop-in replacements.
|
|
@@ -47,7 +37,7 @@ import { chunk, debounce } from "@esmate/utils/lodash";
|
|
|
47
37
|
|
|
48
38
|
---
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
## Math Utilities
|
|
51
41
|
|
|
52
42
|
Leverage the full power of [math.js](https://mathjs.org/docs/index.html) for mathematical operations and calculations.
|
|
53
43
|
|
|
@@ -59,7 +49,15 @@ import { round, sqrt } from "@esmate/utils/math";
|
|
|
59
49
|
|
|
60
50
|
---
|
|
61
51
|
|
|
62
|
-
|
|
52
|
+
## String Utilities
|
|
53
|
+
|
|
54
|
+
Access **string** utilities for common string operations.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { fixTypos, titleize } from "@esmate/utils";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
📚 **Documentation**: [View source](https://github.com/VienDinhCom/esmate/blob/main/packages/utils/src/string.ts)
|
|
63
61
|
|
|
64
62
|
#### `titleize()`
|
|
65
63
|
|
|
@@ -75,8 +73,6 @@ const chicagoTitle = titleize("love of my life", { style: "chicago" }); // "Love
|
|
|
75
73
|
const specialTitle = titleize("i love ESMate", { special: ["ESMate"] }); // "I Love ESMate"
|
|
76
74
|
```
|
|
77
75
|
|
|
78
|
-
📚 **Documentation**: [View source](https://github.com/VienDinhCom/esmate/blob/main/packages/utils/src/string.ts)
|
|
79
|
-
|
|
80
76
|
#### `fixTypos()`
|
|
81
77
|
|
|
82
78
|
Automatically corrects common typographical errors using [typopo](https://www.npmjs.com/package/typopo).
|
|
@@ -87,4 +83,4 @@ import { fixTypos } from "@esmate/utils/string";
|
|
|
87
83
|
const result = fixTypos("This is a text with typos..."); // "This is a text with typos…"
|
|
88
84
|
```
|
|
89
85
|
|
|
90
|
-
|
|
86
|
+
---
|
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 & {
|