feat(struct): add Uint8ClampedArray type

This commit is contained in:
Simon Chan 2021-01-06 18:45:57 +08:00
parent c37e3dd953
commit b601f7a7f2
4 changed files with 21 additions and 6 deletions

View file

@ -1,5 +1,5 @@
import { createRuntimeObject, FieldDefinition, FieldRuntimeValue, getRuntimeValue, setRuntimeValue, StructDefaultOptions, StructDeserializationContext, StructOptions, StructSerializationContext } from './basic';
import { ArrayBufferFieldType, ArrayBufferLikeFieldType, Evaluate, FixedLengthArrayBufferLikeFieldDefinition, FixedLengthArrayBufferLikeFieldOptions, Identity, KeysOfType, NumberFieldDefinition, NumberFieldType, Overwrite, StringFieldType, VariableLengthArrayBufferLikeFieldDefinition, VariableLengthArrayBufferLikeFieldOptions } from './types';
import { ArrayBufferFieldType, ArrayBufferLikeFieldType, Evaluate, FixedLengthArrayBufferLikeFieldDefinition, FixedLengthArrayBufferLikeFieldOptions, Identity, KeysOfType, NumberFieldDefinition, NumberFieldType, Overwrite, StringFieldType, Uint8ClampedArrayFieldType, VariableLengthArrayBufferLikeFieldDefinition, VariableLengthArrayBufferLikeFieldOptions } from './types';
/**
* Extract the value type of the specified `Struct`
@ -354,6 +354,19 @@ export default class Struct<
return this.arrayBufferLike(name, ArrayBufferFieldType.instance, options);
};
public uint8ClampedArray: ArrayBufferTypeFieldDefinitionCreator<
TValue,
TInit,
TExtra,
TPostDeserialized,
Uint8ClampedArrayFieldType
> = (
name: PropertyKey,
options: any
): any => {
return this.arrayBufferLike(name, Uint8ClampedArrayFieldType.instance, options);
};
public string: ArrayBufferTypeFieldDefinitionCreator<
TValue,
TInit,