utilium 1.7.7 → 1.7.9

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 CHANGED
@@ -91,7 +91,10 @@ export function struct(options = {}) {
91
91
  }
92
92
  context.metadata.struct = { options, members, staticSize };
93
93
  context.addInitializer(function () {
94
- this[Symbol.size] = _structSize.bind(this);
94
+ Object.defineProperty(this.prototype, Symbol.size, {
95
+ get: _structSize.bind(this),
96
+ enumerable: false,
97
+ });
95
98
  });
96
99
  return target;
97
100
  };
@@ -180,7 +183,7 @@ export function deserialize(instance, _buffer) {
180
183
  for (const [name, { type, offset, length: rawLength }] of members) {
181
184
  const length = _memberLength(instance, rawLength, name);
182
185
  for (let i = 0; i < Math.abs(length); i++) {
183
- let object = length != -1 ? instance[name][i] : instance[name];
186
+ let object = length != -1 ? instance[name] : instance;
184
187
  const key = length != -1 ? i : name, iOff = offset + sizeof(type) * i;
185
188
  if (typeof instance[name] == 'string') {
186
189
  instance[name] =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
package/src/struct.ts CHANGED
@@ -130,7 +130,10 @@ export function struct(options: Partial<Options> = {}) {
130
130
  context.metadata.struct = { options, members, staticSize } satisfies Metadata;
131
131
 
132
132
  context.addInitializer(function (this: any) {
133
- this[Symbol.size] = _structSize.bind(this);
133
+ Object.defineProperty(this.prototype, Symbol.size, {
134
+ get: _structSize.bind(this),
135
+ enumerable: false,
136
+ });
134
137
  });
135
138
 
136
139
  return target;
@@ -239,7 +242,7 @@ export function deserialize(instance: unknown, _buffer: ArrayBufferLike | ArrayB
239
242
  for (const [name, { type, offset, length: rawLength }] of members) {
240
243
  const length = _memberLength(instance, rawLength, name);
241
244
  for (let i = 0; i < Math.abs(length); i++) {
242
- let object = length != -1 ? instance[name][i] : instance[name];
245
+ let object = length != -1 ? instance[name] : instance;
243
246
  const key = length != -1 ? i : name,
244
247
  iOff = offset + sizeof(type) * i;
245
248