isFixedSize
Call Signature
isFixedSize<
TFrom
,TSize
>(encoder
):encoder is FixedSizeEncoder<TFrom, TSize>
Determines whether the given codec, encoder, or decoder is fixed-size.
A fixed-size object is identified by the presence of a fixedSize
property.
If this property exists, the object is considered a FixedSizeCodec,
FixedSizeEncoder, or FixedSizeDecoder.
Otherwise, it is assumed to be a VariableSizeCodec,
VariableSizeEncoder, or VariableSizeDecoder.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the value to encode. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
Parameter | Type |
---|---|
encoder | FixedSizeEncoder <TFrom , TSize > | VariableSizeEncoder <TFrom > |
Returns
encoder is FixedSizeEncoder<TFrom, TSize>
true
if the object is fixed-size, false
otherwise.
Examples
Checking a fixed-size encoder.
Checking a variable-size encoder.
Remarks
This function is commonly used to distinguish between fixed-size and variable-size objects at runtime. If you need to enforce this distinction with type assertions, consider using assertIsFixedSize.
See
Call Signature
isFixedSize<
TTo
,TSize
>(decoder
):decoder is FixedSizeDecoder<TTo, TSize>
Determines whether the given codec, encoder, or decoder is fixed-size.
A fixed-size object is identified by the presence of a fixedSize
property.
If this property exists, the object is considered a FixedSizeCodec,
FixedSizeEncoder, or FixedSizeDecoder.
Otherwise, it is assumed to be a VariableSizeCodec,
VariableSizeEncoder, or VariableSizeDecoder.
Type Parameters
Type Parameter | Description |
---|---|
TTo | The type of the decoded value. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
Parameter | Type |
---|---|
decoder | FixedSizeDecoder <TTo , TSize > | VariableSizeDecoder <TTo > |
Returns
decoder is FixedSizeDecoder<TTo, TSize>
true
if the object is fixed-size, false
otherwise.
Examples
Checking a fixed-size encoder.
Checking a variable-size encoder.
Remarks
This function is commonly used to distinguish between fixed-size and variable-size objects at runtime. If you need to enforce this distinction with type assertions, consider using assertIsFixedSize.
See
Call Signature
isFixedSize<
TFrom
,TTo
,TSize
>(codec
):codec is FixedSizeCodec<TFrom, TTo, TSize>
Determines whether the given codec, encoder, or decoder is fixed-size.
A fixed-size object is identified by the presence of a fixedSize
property.
If this property exists, the object is considered a FixedSizeCodec,
FixedSizeEncoder, or FixedSizeDecoder.
Otherwise, it is assumed to be a VariableSizeCodec,
VariableSizeEncoder, or VariableSizeDecoder.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the value to encode. |
TTo | The type of the decoded value. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
Parameter | Type |
---|---|
codec | FixedSizeCodec <TFrom , TTo , TSize > | VariableSizeCodec <TFrom , TTo > |
Returns
codec is FixedSizeCodec<TFrom, TTo, TSize>
true
if the object is fixed-size, false
otherwise.
Examples
Checking a fixed-size encoder.
Checking a variable-size encoder.
Remarks
This function is commonly used to distinguish between fixed-size and variable-size objects at runtime. If you need to enforce this distinction with type assertions, consider using assertIsFixedSize.
See
Call Signature
isFixedSize<
TSize
>(codec
):codec is { fixedSize: TSize }
Determines whether the given codec, encoder, or decoder is fixed-size.
A fixed-size object is identified by the presence of a fixedSize
property.
If this property exists, the object is considered a FixedSizeCodec,
FixedSizeEncoder, or FixedSizeDecoder.
Otherwise, it is assumed to be a VariableSizeCodec,
VariableSizeEncoder, or VariableSizeDecoder.
Type Parameters
Type Parameter | Description |
---|---|
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
Parameter | Type |
---|---|
codec | { fixedSize : TSize ; } | { maxSize? : number ; } |
Returns
codec is { fixedSize: TSize }
true
if the object is fixed-size, false
otherwise.
Examples
Checking a fixed-size encoder.
Checking a variable-size encoder.
Remarks
This function is commonly used to distinguish between fixed-size and variable-size objects at runtime. If you need to enforce this distinction with type assertions, consider using assertIsFixedSize.