import * as Compressor from "./compressor" ; import * as Encoder from "./encoder" ; import * as Packer from "./packer" ; import * as Serializer from "./serializer" ; param serializer param compressor param encoder returns see createDefaultPacker export const createPacker = ( { serializer , compressor , encoder } ) : Packer . Packer => { const compressorObj = createCompressor ( compressor ) ; const encoderObj = createEncoder ( encoder ) ; const serializerObj = createSerializer ( serializer ) ; return new Packer . Packer ( { compressor : compressorObj , encoder : encoderObj , serializer : serializerObj , } ) ; } ; returns see createPacker export const createDefaultPacker = ( ) : Packer . Packer => createPacker ( { compressor : CompressorType . Identity , encoder : EncoderType . Base64 , serializer : SerializerType . Json , } ) ; /**
 * bundles the component types of a Packer
 */ export interface Options { compressor : CompressorType ; encoder : EncoderType ; serializer : SerializerType ; } export enum CompressorType { Gzip = "gzip" , Identity = "identity" , Zlib = "zlib" } export enum EncoderType { Base64 = "base64" , Plaintext = "plaintext" } export enum SerializerType { Json = "json" , Yaml = "yaml" } ignore const createCompressor = ( type ) : Compressor . Compressor => { switch ( type ) { case CompressorType . Gzip : return Compressor . createGzipCompressor ( ) ; case CompressorType . Identity : return Compressor . createIdentityCompressor ( ) ; case CompressorType . Zlib : return Compressor . createZlibCompressor ( ) ; } } ; ignore const createEncoder = ( type ) : Encoder . Encoder => { switch ( type ) { case EncoderType . Base64 : return Encoder . createBase64Encoder ( ) ; case EncoderType . Plaintext : return Encoder . createPlaintextEncoder ( ) ; } } ; ignore const createSerializer = ( type ) : Serializer . Serializer => { switch ( type ) { case SerializerType . Json : return Serializer . createJsonSerializer ( ) ; case SerializerType . Yaml : return Serializer . createYamlSerializer ( ) ; } } ;