Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (31 sloc) 781 Bytes
import {Converter} from "../decorators/converter";
import {IConverter, IDeserializer, ISerializer} from "../interfaces/index";
/**
* Converter component for the `Array` Type.
* @private
* @converters
* @component
*/
@Converter(Array)
export class ArrayConverter implements IConverter {
/**
*
* @param data
* @param target
* @param baseType
* @param deserializer
* @returns {any[]}
*/
deserialize<T>(data: any, target: any, baseType: T, deserializer: IDeserializer): T[] {
return [].concat(data).map(item => deserializer!(item, baseType));
}
/**
*
* @param data
* @param serializer
* @returns {any[]}
*/
serialize(data: any[], serializer: ISerializer) {
return [].concat(data as any).map(item => serializer(item));
}
}
You can’t perform that action at this time.