utilium 1.7.9 → 1.7.10

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
@@ -122,7 +122,7 @@ export function member(type, length) {
122
122
  * Serializes a struct into a Uint8Array
123
123
  */
124
124
  export function serialize(instance) {
125
- if (isCustom(instance))
125
+ if (isCustom(instance) && typeof instance[Symbol.serialize] == 'function')
126
126
  return instance[Symbol.serialize]();
127
127
  checkInstance(instance);
128
128
  const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;
@@ -175,7 +175,7 @@ export function serialize(instance) {
175
175
  */
176
176
  export function deserialize(instance, _buffer) {
177
177
  const buffer = toUint8Array(_buffer);
178
- if (isCustom(instance))
178
+ if (isCustom(instance) && typeof instance[Symbol.deserialize] == 'function')
179
179
  return instance[Symbol.deserialize](buffer);
180
180
  checkInstance(instance);
181
181
  const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "1.7.9",
3
+ "version": "1.7.10",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
package/src/struct.ts CHANGED
@@ -165,7 +165,7 @@ export function member(type: primitive.Valid | ClassLike, length?: number | stri
165
165
  * Serializes a struct into a Uint8Array
166
166
  */
167
167
  export function serialize(instance: unknown): Uint8Array {
168
- if (isCustom(instance)) return instance[Symbol.serialize]!();
168
+ if (isCustom(instance) && typeof instance[Symbol.serialize] == 'function') return instance[Symbol.serialize]!();
169
169
 
170
170
  checkInstance(instance);
171
171
  const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;
@@ -232,7 +232,8 @@ export function serialize(instance: unknown): Uint8Array {
232
232
  export function deserialize(instance: unknown, _buffer: ArrayBufferLike | ArrayBufferView) {
233
233
  const buffer = toUint8Array(_buffer);
234
234
 
235
- if (isCustom(instance)) return instance[Symbol.deserialize]!(buffer);
235
+ if (isCustom(instance) && typeof instance[Symbol.deserialize] == 'function')
236
+ return instance[Symbol.deserialize]!(buffer);
236
237
 
237
238
  checkInstance(instance);
238
239
  const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;