Fix ArrayType: support null or undefined values.
This commit is contained in:
parent
c1b8e8adb1
commit
cfbf74911b
1 changed files with 6 additions and 0 deletions
|
@ -16,6 +16,9 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser
|
||||||
|
|
||||||
serialize(value: SharkitekValueType[]): SerializedValueType[]
|
serialize(value: SharkitekValueType[]): SerializedValueType[]
|
||||||
{
|
{
|
||||||
|
if (value === undefined) return undefined;
|
||||||
|
if (value === null) return null;
|
||||||
|
|
||||||
return value.map((value) => (
|
return value.map((value) => (
|
||||||
// Serializing each value of the array.
|
// Serializing each value of the array.
|
||||||
this.valueType.serialize(value)
|
this.valueType.serialize(value)
|
||||||
|
@ -24,6 +27,9 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser
|
||||||
|
|
||||||
deserialize(value: SerializedValueType[]): SharkitekValueType[]
|
deserialize(value: SerializedValueType[]): SharkitekValueType[]
|
||||||
{
|
{
|
||||||
|
if (value === undefined) return undefined;
|
||||||
|
if (value === null) return null;
|
||||||
|
|
||||||
return value.map((serializedValue) => (
|
return value.map((serializedValue) => (
|
||||||
// Deserializing each value of the array.
|
// Deserializing each value of the array.
|
||||||
this.valueType.deserialize(serializedValue)
|
this.valueType.deserialize(serializedValue)
|
||||||
|
|
Loading…
Reference in a new issue