@twin.org/core 0.0.2-next.15 → 0.0.2-next.17
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/index.cjs +9 -9
- package/dist/esm/index.mjs +9 -9
- package/dist/types/helpers/stringHelper.d.ts +16 -4
- package/dist/types/models/IComponent.d.ts +3 -3
- package/dist/types/utils/is.d.ts +1 -1
- package/docs/changelog.md +35 -0
- package/docs/reference/classes/Is.md +8 -2
- package/docs/reference/classes/StringHelper.md +74 -12
- package/docs/reference/interfaces/IComponent.md +14 -14
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -398,26 +398,26 @@ class Is {
|
|
|
398
398
|
*/
|
|
399
399
|
class StringHelper {
|
|
400
400
|
/**
|
|
401
|
-
*
|
|
401
|
+
* Implementation signature for trimTrailingSlashes.
|
|
402
402
|
* @param value The value to trim.
|
|
403
|
-
* @returns The trimmed
|
|
403
|
+
* @returns The trimmed string or the original null/undefined.
|
|
404
404
|
*/
|
|
405
405
|
static trimTrailingSlashes(value) {
|
|
406
|
-
if (Is.
|
|
406
|
+
if (Is.string(value)) {
|
|
407
407
|
return value.replace(/\/+$/, "");
|
|
408
408
|
}
|
|
409
|
-
return
|
|
409
|
+
return value;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
|
-
*
|
|
412
|
+
* Implementation signature for trimLeadingSlashes.
|
|
413
413
|
* @param value The value to trim.
|
|
414
|
-
* @returns The trimmed
|
|
414
|
+
* @returns The trimmed string or the original null/undefined.
|
|
415
415
|
*/
|
|
416
416
|
static trimLeadingSlashes(value) {
|
|
417
|
-
if (Is.
|
|
417
|
+
if (Is.string(value)) {
|
|
418
418
|
return value.replace(/^\/+/, "");
|
|
419
419
|
}
|
|
420
|
-
return
|
|
420
|
+
return value;
|
|
421
421
|
}
|
|
422
422
|
/**
|
|
423
423
|
* Convert the input string to kebab case.
|
|
@@ -2705,7 +2705,7 @@ class ObjectHelper {
|
|
|
2705
2705
|
* @returns The object as bytes.
|
|
2706
2706
|
*/
|
|
2707
2707
|
static toBytes(obj, format = false) {
|
|
2708
|
-
if (obj
|
|
2708
|
+
if (Is.undefined(obj)) {
|
|
2709
2709
|
return new Uint8Array();
|
|
2710
2710
|
}
|
|
2711
2711
|
const json = format ? JSON.stringify(obj, undefined, "\t") : JSON.stringify(obj);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -396,26 +396,26 @@ class Is {
|
|
|
396
396
|
*/
|
|
397
397
|
class StringHelper {
|
|
398
398
|
/**
|
|
399
|
-
*
|
|
399
|
+
* Implementation signature for trimTrailingSlashes.
|
|
400
400
|
* @param value The value to trim.
|
|
401
|
-
* @returns The trimmed
|
|
401
|
+
* @returns The trimmed string or the original null/undefined.
|
|
402
402
|
*/
|
|
403
403
|
static trimTrailingSlashes(value) {
|
|
404
|
-
if (Is.
|
|
404
|
+
if (Is.string(value)) {
|
|
405
405
|
return value.replace(/\/+$/, "");
|
|
406
406
|
}
|
|
407
|
-
return
|
|
407
|
+
return value;
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
410
|
-
*
|
|
410
|
+
* Implementation signature for trimLeadingSlashes.
|
|
411
411
|
* @param value The value to trim.
|
|
412
|
-
* @returns The trimmed
|
|
412
|
+
* @returns The trimmed string or the original null/undefined.
|
|
413
413
|
*/
|
|
414
414
|
static trimLeadingSlashes(value) {
|
|
415
|
-
if (Is.
|
|
415
|
+
if (Is.string(value)) {
|
|
416
416
|
return value.replace(/^\/+/, "");
|
|
417
417
|
}
|
|
418
|
-
return
|
|
418
|
+
return value;
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
421
|
* Convert the input string to kebab case.
|
|
@@ -2703,7 +2703,7 @@ class ObjectHelper {
|
|
|
2703
2703
|
* @returns The object as bytes.
|
|
2704
2704
|
*/
|
|
2705
2705
|
static toBytes(obj, format = false) {
|
|
2706
|
-
if (obj
|
|
2706
|
+
if (Is.undefined(obj)) {
|
|
2707
2707
|
return new Uint8Array();
|
|
2708
2708
|
}
|
|
2709
2709
|
const json = format ? JSON.stringify(obj, undefined, "\t") : JSON.stringify(obj);
|
|
@@ -4,16 +4,28 @@
|
|
|
4
4
|
export declare class StringHelper {
|
|
5
5
|
/**
|
|
6
6
|
* Trim trailing slashes from a string.
|
|
7
|
+
* Overloads preserve null/undefined instead of coercing to empty string.
|
|
7
8
|
* @param value The value to trim.
|
|
8
|
-
* @returns The trimmed value.
|
|
9
|
+
* @returns The trimmed value (same null/undefined passed in).
|
|
9
10
|
*/
|
|
10
|
-
static trimTrailingSlashes(value: string
|
|
11
|
+
static trimTrailingSlashes(value: string): string;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param value
|
|
15
|
+
*/
|
|
16
|
+
static trimTrailingSlashes<T extends null | undefined>(value: T): T;
|
|
11
17
|
/**
|
|
12
18
|
* Trim leading slashes from a string.
|
|
19
|
+
* Overloads preserve null/undefined instead of coercing to empty string.
|
|
13
20
|
* @param value The value to trim.
|
|
14
|
-
* @returns The trimmed value.
|
|
21
|
+
* @returns The trimmed value (same null/undefined passed in).
|
|
22
|
+
*/
|
|
23
|
+
static trimLeadingSlashes(value: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Overload for null/undefined passthrough.
|
|
26
|
+
* @param value The null or undefined value.
|
|
15
27
|
*/
|
|
16
|
-
static trimLeadingSlashes
|
|
28
|
+
static trimLeadingSlashes<T extends null | undefined>(value: T): T;
|
|
17
29
|
/**
|
|
18
30
|
* Convert the input string to kebab case.
|
|
19
31
|
* @param input The input to convert.
|
|
@@ -11,19 +11,19 @@ export interface IComponent {
|
|
|
11
11
|
* @param nodeLoggingComponentType The node logging component type.
|
|
12
12
|
* @returns True if the bootstrapping process was successful.
|
|
13
13
|
*/
|
|
14
|
-
bootstrap?(nodeLoggingComponentType
|
|
14
|
+
bootstrap?(nodeLoggingComponentType?: string): Promise<boolean>;
|
|
15
15
|
/**
|
|
16
16
|
* The component needs to be started when the node is initialized.
|
|
17
17
|
* @param nodeIdentity The identity of the node starting the component.
|
|
18
18
|
* @param nodeLoggingComponentType The node logging component type.
|
|
19
19
|
* @returns Nothing.
|
|
20
20
|
*/
|
|
21
|
-
start?(nodeIdentity
|
|
21
|
+
start?(nodeIdentity?: string, nodeLoggingComponentType?: string): Promise<void>;
|
|
22
22
|
/**
|
|
23
23
|
* The component needs to be stopped when the node is closed.
|
|
24
24
|
* @param nodeIdentity The identity of the node stopping the component.
|
|
25
25
|
* @param nodeLoggingComponentType The node logging component type.
|
|
26
26
|
* @returns Nothing.
|
|
27
27
|
*/
|
|
28
|
-
stop?(nodeIdentity
|
|
28
|
+
stop?(nodeIdentity?: string, nodeLoggingComponentType?: string): Promise<void>;
|
|
29
29
|
}
|
package/dist/types/utils/is.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ export declare class Is {
|
|
|
195
195
|
* @param value The value to test.
|
|
196
196
|
* @returns True if the value is a function.
|
|
197
197
|
*/
|
|
198
|
-
static function(
|
|
198
|
+
static function<FN extends (args?: unknown[]) => unknown = (args?: unknown[]) => unknown>(value: unknown): value is FN;
|
|
199
199
|
/**
|
|
200
200
|
* Is the value a string formatted as an email address.
|
|
201
201
|
* @param value The value to test.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @twin.org/core - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.17](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.16...core-v0.0.2-next.17) (2025-09-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* additional nameof operators ([a5aab60](https://github.com/twinfoundation/framework/commit/a5aab60bf66a86f1b7ff8af7c4f044cb03706d50))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nameof bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
18
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
19
|
+
|
|
20
|
+
## [0.0.2-next.16](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.15...core-v0.0.2-next.16) (2025-09-28)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* improve Is.function definition to retain types ([f20b6b0](https://github.com/twinfoundation/framework/commit/f20b6b0dd16e74b75dc359be72b05989305c6410))
|
|
26
|
+
* nodeIdentity optional in IComponent methods ([c78dc17](https://github.com/twinfoundation/framework/commit/c78dc17f4357d3e1ae40e415f468d3eae13e81f4))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
* The following workspace dependencies were updated
|
|
32
|
+
* dependencies
|
|
33
|
+
* @twin.org/nameof bumped from 0.0.2-next.15 to 0.0.2-next.16
|
|
34
|
+
* devDependencies
|
|
35
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.15 to 0.0.2-next.16
|
|
36
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.15 to 0.0.2-next.16
|
|
37
|
+
|
|
3
38
|
## [0.0.2-next.15](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.14...core-v0.0.2-next.15) (2025-09-22)
|
|
4
39
|
|
|
5
40
|
|
|
@@ -730,10 +730,16 @@ True if the value is a TypedArray.
|
|
|
730
730
|
|
|
731
731
|
### function()
|
|
732
732
|
|
|
733
|
-
> `static` **function
|
|
733
|
+
> `static` **function**\<`FN`\>(`value`): `value is FN`
|
|
734
734
|
|
|
735
735
|
Is the property a function.
|
|
736
736
|
|
|
737
|
+
#### Type Parameters
|
|
738
|
+
|
|
739
|
+
##### FN
|
|
740
|
+
|
|
741
|
+
`FN` *extends* (`args?`) => `unknown` = (`args?`) => `unknown`
|
|
742
|
+
|
|
737
743
|
#### Parameters
|
|
738
744
|
|
|
739
745
|
##### value
|
|
@@ -744,7 +750,7 @@ The value to test.
|
|
|
744
750
|
|
|
745
751
|
#### Returns
|
|
746
752
|
|
|
747
|
-
`value is
|
|
753
|
+
`value is FN`
|
|
748
754
|
|
|
749
755
|
True if the value is a function.
|
|
750
756
|
|
|
@@ -16,45 +16,107 @@ Class to help with string.
|
|
|
16
16
|
|
|
17
17
|
### trimTrailingSlashes()
|
|
18
18
|
|
|
19
|
+
Implementation signature for trimTrailingSlashes.
|
|
20
|
+
|
|
21
|
+
#### Param
|
|
22
|
+
|
|
23
|
+
The value to trim.
|
|
24
|
+
|
|
25
|
+
#### Call Signature
|
|
26
|
+
|
|
19
27
|
> `static` **trimTrailingSlashes**(`value`): `string`
|
|
20
28
|
|
|
21
29
|
Trim trailing slashes from a string.
|
|
30
|
+
Overloads preserve null/undefined instead of coercing to empty string.
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
##### Parameters
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
###### value
|
|
35
|
+
|
|
36
|
+
`string`
|
|
26
37
|
|
|
27
38
|
The value to trim.
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#### Returns
|
|
40
|
+
##### Returns
|
|
32
41
|
|
|
33
42
|
`string`
|
|
34
43
|
|
|
35
|
-
The trimmed value.
|
|
44
|
+
The trimmed value (same null/undefined passed in).
|
|
45
|
+
|
|
46
|
+
#### Call Signature
|
|
47
|
+
|
|
48
|
+
> `static` **trimTrailingSlashes**\<`T`\>(`value`): `T`
|
|
49
|
+
|
|
50
|
+
##### Type Parameters
|
|
51
|
+
|
|
52
|
+
###### T
|
|
53
|
+
|
|
54
|
+
`T` *extends* `undefined` \| `null`
|
|
55
|
+
|
|
56
|
+
##### Parameters
|
|
57
|
+
|
|
58
|
+
###### value
|
|
59
|
+
|
|
60
|
+
`T`
|
|
61
|
+
|
|
62
|
+
##### Returns
|
|
63
|
+
|
|
64
|
+
`T`
|
|
36
65
|
|
|
37
66
|
***
|
|
38
67
|
|
|
39
68
|
### trimLeadingSlashes()
|
|
40
69
|
|
|
70
|
+
Implementation signature for trimLeadingSlashes.
|
|
71
|
+
|
|
72
|
+
#### Param
|
|
73
|
+
|
|
74
|
+
The value to trim.
|
|
75
|
+
|
|
76
|
+
#### Call Signature
|
|
77
|
+
|
|
41
78
|
> `static` **trimLeadingSlashes**(`value`): `string`
|
|
42
79
|
|
|
43
80
|
Trim leading slashes from a string.
|
|
81
|
+
Overloads preserve null/undefined instead of coercing to empty string.
|
|
44
82
|
|
|
45
|
-
|
|
83
|
+
##### Parameters
|
|
46
84
|
|
|
47
|
-
|
|
85
|
+
###### value
|
|
48
86
|
|
|
49
|
-
|
|
87
|
+
`string`
|
|
50
88
|
|
|
51
|
-
|
|
89
|
+
The value to trim.
|
|
52
90
|
|
|
53
|
-
|
|
91
|
+
##### Returns
|
|
54
92
|
|
|
55
93
|
`string`
|
|
56
94
|
|
|
57
|
-
The trimmed value.
|
|
95
|
+
The trimmed value (same null/undefined passed in).
|
|
96
|
+
|
|
97
|
+
#### Call Signature
|
|
98
|
+
|
|
99
|
+
> `static` **trimLeadingSlashes**\<`T`\>(`value`): `T`
|
|
100
|
+
|
|
101
|
+
Overload for null/undefined passthrough.
|
|
102
|
+
|
|
103
|
+
##### Type Parameters
|
|
104
|
+
|
|
105
|
+
###### T
|
|
106
|
+
|
|
107
|
+
`T` *extends* `undefined` \| `null`
|
|
108
|
+
|
|
109
|
+
##### Parameters
|
|
110
|
+
|
|
111
|
+
###### value
|
|
112
|
+
|
|
113
|
+
`T`
|
|
114
|
+
|
|
115
|
+
The null or undefined value.
|
|
116
|
+
|
|
117
|
+
##### Returns
|
|
118
|
+
|
|
119
|
+
`T`
|
|
58
120
|
|
|
59
121
|
***
|
|
60
122
|
|
|
@@ -14,17 +14,17 @@ The name of the component.
|
|
|
14
14
|
|
|
15
15
|
### bootstrap()?
|
|
16
16
|
|
|
17
|
-
> `optional` **bootstrap**(`nodeLoggingComponentType
|
|
17
|
+
> `optional` **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
18
18
|
|
|
19
19
|
Bootstrap the component by creating and initializing any resources it needs.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
23
|
-
##### nodeLoggingComponentType
|
|
23
|
+
##### nodeLoggingComponentType?
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
`string`
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
The node logging component type.
|
|
28
28
|
|
|
29
29
|
#### Returns
|
|
30
30
|
|
|
@@ -36,23 +36,23 @@ True if the bootstrapping process was successful.
|
|
|
36
36
|
|
|
37
37
|
### start()?
|
|
38
38
|
|
|
39
|
-
> `optional` **start**(`nodeIdentity
|
|
39
|
+
> `optional` **start**(`nodeIdentity?`, `nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
40
40
|
|
|
41
41
|
The component needs to be started when the node is initialized.
|
|
42
42
|
|
|
43
43
|
#### Parameters
|
|
44
44
|
|
|
45
|
-
##### nodeIdentity
|
|
45
|
+
##### nodeIdentity?
|
|
46
46
|
|
|
47
47
|
`string`
|
|
48
48
|
|
|
49
49
|
The identity of the node starting the component.
|
|
50
50
|
|
|
51
|
-
##### nodeLoggingComponentType
|
|
51
|
+
##### nodeLoggingComponentType?
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
`string`
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
The node logging component type.
|
|
56
56
|
|
|
57
57
|
#### Returns
|
|
58
58
|
|
|
@@ -64,23 +64,23 @@ Nothing.
|
|
|
64
64
|
|
|
65
65
|
### stop()?
|
|
66
66
|
|
|
67
|
-
> `optional` **stop**(`nodeIdentity
|
|
67
|
+
> `optional` **stop**(`nodeIdentity?`, `nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
68
68
|
|
|
69
69
|
The component needs to be stopped when the node is closed.
|
|
70
70
|
|
|
71
71
|
#### Parameters
|
|
72
72
|
|
|
73
|
-
##### nodeIdentity
|
|
73
|
+
##### nodeIdentity?
|
|
74
74
|
|
|
75
75
|
`string`
|
|
76
76
|
|
|
77
77
|
The identity of the node stopping the component.
|
|
78
78
|
|
|
79
|
-
##### nodeLoggingComponentType
|
|
79
|
+
##### nodeLoggingComponentType?
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
`string`
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
The node logging component type.
|
|
84
84
|
|
|
85
85
|
#### Returns
|
|
86
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/core",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.17",
|
|
4
4
|
"description": "Helper methods/classes for data type checking/validation/guarding/error handling",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
17
|
+
"@twin.org/nameof": "0.0.2-next.17",
|
|
18
18
|
"intl-messageformat": "10.7.16",
|
|
19
19
|
"rfc6902": "5.1.2"
|
|
20
20
|
},
|