utilium 0.6.0 → 0.6.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/dist/struct.js +2 -0
- package/package.json +1 -1
- package/src/struct.ts +2 -0
package/dist/struct.js
CHANGED
@@ -31,6 +31,7 @@ export function align(value, alignment) {
|
|
31
31
|
export function struct(options = {}) {
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
33
33
|
return function __decorateStruct(target, context) {
|
34
|
+
context.metadata ??= {};
|
34
35
|
context.metadata[init] ||= [];
|
35
36
|
let size = 0;
|
36
37
|
const members = new Map();
|
@@ -64,6 +65,7 @@ export function member(type, length) {
|
|
64
65
|
if (!name) {
|
65
66
|
throw new ReferenceError('Invalid name for struct member');
|
66
67
|
}
|
68
|
+
context.metadata ??= {};
|
67
69
|
context.metadata[init] ||= [];
|
68
70
|
context.metadata[init].push({ name, type, length });
|
69
71
|
return value;
|
package/package.json
CHANGED
package/src/struct.ts
CHANGED
@@ -54,6 +54,7 @@ export function align(value: number, alignment: number): number {
|
|
54
54
|
export function struct(options: Partial<Options> = {}) {
|
55
55
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
56
56
|
return function __decorateStruct<const T extends StaticLike>(target: T, context: ClassDecoratorContext & DecoratorContext): T {
|
57
|
+
context.metadata ??= {};
|
57
58
|
context.metadata[init] ||= [];
|
58
59
|
let size = 0;
|
59
60
|
const members = new Map();
|
@@ -91,6 +92,7 @@ export function member(type: primitive.Valid | ClassLike, length?: number) {
|
|
91
92
|
throw new ReferenceError('Invalid name for struct member');
|
92
93
|
}
|
93
94
|
|
95
|
+
context.metadata ??= {};
|
94
96
|
context.metadata[init] ||= [];
|
95
97
|
context.metadata[init].push({ name, type, length } satisfies MemberInit);
|
96
98
|
return value;
|