@xaendar/common 0.9.3 → 0.9.4
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/xaendar-common.es.d.ts +22 -0
- package/dist/xaendar-common.es.js +22 -0
- package/package.json +1 -1
|
@@ -24,6 +24,28 @@ export declare function indent(lines: string[]): string[];
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function isValidCustomElementName(tagName: string): boolean;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Returns a substring of `value`, copying the result via JSON
|
|
29
|
+
* serialization (to obtain a "clean" new string instance).
|
|
30
|
+
*
|
|
31
|
+
* This method ensure to resolve a note V8 Engine's problem
|
|
32
|
+
* about Sliced String and how they are hard to be garbage collectable
|
|
33
|
+
* and can lead to preserve a indefinite number of closure occupying
|
|
34
|
+
* unnecessary memory
|
|
35
|
+
* https://stackoverflow.com/questions/79478418/how-to-correctly-unref-a-v8-substring-sliced-string-from-its-source-string
|
|
36
|
+
*
|
|
37
|
+
* @param value - The source string to extract the substring from.
|
|
38
|
+
* @param start - The zero-based index at which to start extraction. If omitted, starts from the beginning of the string.
|
|
39
|
+
* If negative, it is treated as `value.length + start`.
|
|
40
|
+
* @param end - The zero-based index at which to end extraction (exclusive). If omitted, extraction goes to the end of the string.
|
|
41
|
+
* If negative, it is treated as `value.length + end`.
|
|
42
|
+
* @returns The substring extracted from `value` between `start` and `end`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* slice("Hello world", 0, 5); // "Hello"
|
|
46
|
+
* slice("Hello world", 6); // "world"
|
|
47
|
+
* slice("Hello world", -5); // "world"
|
|
48
|
+
*/
|
|
27
49
|
export declare function slice(value: string, start?: number, end?: number): string;
|
|
28
50
|
|
|
29
51
|
/**
|
|
@@ -51,6 +51,28 @@ function indent(lines) {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region ../packages/common/src/utils/string/string.utils.ts
|
|
54
|
+
/**
|
|
55
|
+
* Returns a substring of `value`, copying the result via JSON
|
|
56
|
+
* serialization (to obtain a "clean" new string instance).
|
|
57
|
+
*
|
|
58
|
+
* This method ensure to resolve a note V8 Engine's problem
|
|
59
|
+
* about Sliced String and how they are hard to be garbage collectable
|
|
60
|
+
* and can lead to preserve a indefinite number of closure occupying
|
|
61
|
+
* unnecessary memory
|
|
62
|
+
* https://stackoverflow.com/questions/79478418/how-to-correctly-unref-a-v8-substring-sliced-string-from-its-source-string
|
|
63
|
+
*
|
|
64
|
+
* @param value - The source string to extract the substring from.
|
|
65
|
+
* @param start - The zero-based index at which to start extraction. If omitted, starts from the beginning of the string.
|
|
66
|
+
* If negative, it is treated as `value.length + start`.
|
|
67
|
+
* @param end - The zero-based index at which to end extraction (exclusive). If omitted, extraction goes to the end of the string.
|
|
68
|
+
* If negative, it is treated as `value.length + end`.
|
|
69
|
+
* @returns The substring extracted from `value` between `start` and `end`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* slice("Hello world", 0, 5); // "Hello"
|
|
73
|
+
* slice("Hello world", 6); // "world"
|
|
74
|
+
* slice("Hello world", -5); // "world"
|
|
75
|
+
*/
|
|
54
76
|
function slice(value, start, end) {
|
|
55
77
|
return JSON.parse(JSON.stringify(value.slice(start, end)));
|
|
56
78
|
}
|