xypriss 9.12.18 → 9.12.19
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/dist/cjs/src/xhsc/UtilsApi.js +54 -7
- package/dist/cjs/src/xhsc/UtilsApi.js.map +1 -1
- package/dist/cjs/src/xhsc/utils/StringUtils.js +607 -0
- package/dist/cjs/src/xhsc/utils/StringUtils.js.map +1 -1
- package/dist/esm/src/xhsc/UtilsApi.js +54 -7
- package/dist/esm/src/xhsc/UtilsApi.js.map +1 -1
- package/dist/esm/src/xhsc/utils/StringUtils.js +607 -0
- package/dist/esm/src/xhsc/utils/StringUtils.js.map +1 -1
- package/dist/index.d.ts +512 -7
- package/package.json +1 -1
|
@@ -70,9 +70,42 @@ var LoggerUtils = require('./utils/LoggerUtils.js');
|
|
|
70
70
|
*/
|
|
71
71
|
class UtilsApi {
|
|
72
72
|
constructor() {
|
|
73
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* **StringUtils — XyPriss String Utilities**
|
|
75
|
+
*
|
|
76
|
+
* A collection of dependency-free helpers for everyday string manipulation:
|
|
77
|
+
* case conversion (`camelCase`, `kebab-case`, `snake_case`, `Title Case`),
|
|
78
|
+
* sanitization (HTML escaping/stripping, accent stripping, whitespace
|
|
79
|
+
* normalization), validation (emails, URLs, palindromes), extraction
|
|
80
|
+
* (emails, URLs, substrings between markers), masking of sensitive data,
|
|
81
|
+
* fuzzy comparison (Levenshtein distance, similarity score), text layout
|
|
82
|
+
* (word wrap, chunking), and generation (random strings, UUIDs).
|
|
83
|
+
*
|
|
84
|
+
* All methods are pure functions with no side effects and no external
|
|
85
|
+
* dependencies — instantiate once and reuse across your application.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* The public API surface of this class is conventionally exposed as `str.**`
|
|
89
|
+
* (e.g. `str.slugify(...)`, `str.toCamelCase(...)`) in XyPriss.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { StringUtils } from "xypriss";
|
|
94
|
+
*
|
|
95
|
+
* const str = new StringUtils();
|
|
96
|
+
*
|
|
97
|
+
* str.slugify("Hello World!"); // "hello-world"
|
|
98
|
+
* str.toCamelCase("hello-world"); // "helloWorld"
|
|
99
|
+
* str.truncate("A very long text", 10); // "A very ..."
|
|
100
|
+
* str.mask("4111111111111111", { visibleStart: 4, visibleEnd: 4 }); // "4111********1111"
|
|
101
|
+
* ```
|
|
102
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/strings
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
74
105
|
this.str = new StringUtils.StringUtils();
|
|
75
|
-
/** **Number & Math Utilities** (`clamp`, `lerp`, `formatBytes`, etc.)
|
|
106
|
+
/** **Number & Math Utilities** (`clamp`, `lerp`, `formatBytes`, etc.)
|
|
107
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/numbers
|
|
108
|
+
*/
|
|
76
109
|
this.num = new NumberUtils.NumberUtils();
|
|
77
110
|
/**
|
|
78
111
|
* @file DateUtils.ts
|
|
@@ -95,6 +128,7 @@ class UtilsApi {
|
|
|
95
128
|
* du.formatDuration(3_661_000); // "1h 1m 1s"
|
|
96
129
|
* du.startOf("month"); // 2026-04-01T00:00:00.000Z
|
|
97
130
|
* ```
|
|
131
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/dates
|
|
98
132
|
*/
|
|
99
133
|
this.date = new DateUtils.DateUtils();
|
|
100
134
|
/**
|
|
@@ -123,17 +157,28 @@ class UtilsApi {
|
|
|
123
157
|
* .pick(["a", "b"])
|
|
124
158
|
* .value(); // { a: 1, b: 2 }
|
|
125
159
|
* ```
|
|
160
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/data#object-utilities
|
|
126
161
|
*/
|
|
127
162
|
this.obj = new ObjectUtils.ObjectUtils();
|
|
128
|
-
/** **Array Utilities** (`chunk`, `unique`, `groupBy`, etc.)
|
|
163
|
+
/** **Array Utilities** (`chunk`, `unique`, `groupBy`, etc.)
|
|
164
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/data#array-utilities
|
|
165
|
+
*/
|
|
129
166
|
this.arr = new ArrayUtils.ArrayUtils();
|
|
130
|
-
/** **Async & Control Flow Utilities** (`sleep`, `retry`, `debounce`, etc.)
|
|
167
|
+
/** **Async & Control Flow Utilities** (`sleep`, `retry`, `debounce`, etc.)
|
|
168
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/logic#async-utilities
|
|
169
|
+
*/
|
|
131
170
|
this.async = new AsyncUtils.AsyncUtils();
|
|
132
|
-
/** **Validation Utilities** (`email`, `url`, `nullish`)
|
|
171
|
+
/** **Validation Utilities** (`email`, `url`, `nullish`)
|
|
172
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/logic#validation-utilities
|
|
173
|
+
*/
|
|
133
174
|
this.is = new ValidationUtils.ValidationUtils();
|
|
134
|
-
/** **Identity Utilities** (`uuid`)
|
|
175
|
+
/** **Identity Utilities** (`uuid`)
|
|
176
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/primitives#identity-utilities
|
|
177
|
+
*/
|
|
135
178
|
this.id = new IdUtils.IdUtils();
|
|
136
|
-
/** **Functional Utilities** (`memo`)
|
|
179
|
+
/** **Functional Utilities** (`memo`)
|
|
180
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/primitives#functional-utilities
|
|
181
|
+
*/
|
|
137
182
|
this.fn = new FunctionUtils.FunctionUtils();
|
|
138
183
|
/**
|
|
139
184
|
* **Logger Utilities** — Structured, colorful console logger.
|
|
@@ -147,6 +192,7 @@ class UtilsApi {
|
|
|
147
192
|
* __sys__.utils.log.warn("Low memory", { freeKb: 128 });
|
|
148
193
|
* __sys__.utils.log.error("Crash", new Error("OOM"));
|
|
149
194
|
* ```
|
|
195
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/logger
|
|
150
196
|
*/
|
|
151
197
|
this.log = new LoggerUtils.LoggerUtils();
|
|
152
198
|
}
|
|
@@ -164,6 +210,7 @@ class UtilsApi {
|
|
|
164
210
|
* // Plain mode — no ANSI colors (great for log files / CI)
|
|
165
211
|
* const ciLog = __sys__.utils.createLogger({ namespace: "CI", plain: true });
|
|
166
212
|
* ```
|
|
213
|
+
* @see https://xypriss.nehonix.com/docs/system/utils/logger#scoped-loggers
|
|
167
214
|
*/
|
|
168
215
|
createLogger(opts = {}) {
|
|
169
216
|
return new LoggerUtils.LoggerUtils(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilsApi.js","sources":["../../../../src/xhsc/UtilsApi.ts"],"sourcesContent":[null],"names":["StringUtils","NumberUtils","DateUtils","ObjectUtils","ArrayUtils","AsyncUtils","ValidationUtils","IdUtils","FunctionUtils","LoggerUtils"],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBiF;AACjF;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;MACU,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA
|
|
1
|
+
{"version":3,"file":"UtilsApi.js","sources":["../../../../src/xhsc/UtilsApi.ts"],"sourcesContent":[null],"names":["StringUtils","NumberUtils","DateUtils","ObjectUtils","ArrayUtils","AsyncUtils","ValidationUtils","IdUtils","FunctionUtils","LoggerUtils"],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBiF;AACjF;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;MACU,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA;AACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACa,QAAA,IAAA,CAAA,GAAG,GAAG,IAAIA,uBAAW,EAAE;AAEvC;;AAEG;AACa,QAAA,IAAA,CAAA,GAAG,GAAG,IAAIC,uBAAW,EAAE;AAEvC;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACa,QAAA,IAAA,CAAA,IAAI,GAAG,IAAIC,mBAAS,EAAE;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACa,QAAA,IAAA,CAAA,GAAG,GAAG,IAAIC,uBAAW,EAAE;AAEvC;;AAEG;AACa,QAAA,IAAA,CAAA,GAAG,GAAG,IAAIC,qBAAU,EAAE;AAEtC;;AAEG;AACa,QAAA,IAAA,CAAA,KAAK,GAAG,IAAIC,qBAAU,EAAE;AAExC;;AAEG;AACa,QAAA,IAAA,CAAA,EAAE,GAAG,IAAIC,+BAAe,EAAE;AAE1C;;AAEG;AACa,QAAA,IAAA,CAAA,EAAE,GAAG,IAAIC,eAAO,EAAE;AAElC;;AAEG;AACa,QAAA,IAAA,CAAA,EAAE,GAAG,IAAIC,2BAAa,EAAE;AAExC;;;;;;;;;;;;;AAaG;AACa,QAAA,IAAA,CAAA,GAAG,GAAG,IAAIC,uBAAW,EAAE;IAuB3C;AArBI;;;;;;;;;;;;;;;AAeG;IACI,YAAY,CACf,OAAqD,EAAE,EAAA;AAEvD,QAAA,OAAO,IAAIA,uBAAW,CAAC,IAAI,CAAC;IAChC;AACH;;;;"}
|