utilium 1.7.5 → 1.7.6
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
@@ -119,6 +119,8 @@ export function member(type, length) {
|
|
119
119
|
* Serializes a struct into a Uint8Array
|
120
120
|
*/
|
121
121
|
export function serialize(instance) {
|
122
|
+
if (isCustom(instance))
|
123
|
+
return instance[Symbol.serialize]();
|
122
124
|
checkInstance(instance);
|
123
125
|
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;
|
124
126
|
const buffer = new Uint8Array(sizeof(instance));
|
package/package.json
CHANGED
package/src/struct.ts
CHANGED
@@ -162,6 +162,8 @@ export function member(type: primitive.Valid | ClassLike, length?: number | stri
|
|
162
162
|
* Serializes a struct into a Uint8Array
|
163
163
|
*/
|
164
164
|
export function serialize(instance: unknown): Uint8Array {
|
165
|
+
if (isCustom(instance)) return instance[Symbol.serialize]!();
|
166
|
+
|
165
167
|
checkInstance(instance);
|
166
168
|
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)].struct;
|
167
169
|
|