import * as Compressor from "./compressor" ; import * as Encoder from "./encoder" ; import * as Serializer from "./serializer" ; /**
 * encapsulates data transformation for external transmission
 */ export class Packer { private compressor : Compressor . Compressor ; private encoder : Encoder . Encoder ; private serializer : Serializer . Serializer ; public constructor ( { serializer , compressor , encoder } ) { this . compressor = compressor ; this . encoder = encoder ; this . serializer = serializer ; } param data returns see unpack public pack ( data ) { const serialized = this . serializer . serialize ( data ) ; const compressed = this . compressor . compress ( serialized ) ; const encoded = this . encoder . encode ( compressed ) ; return encoded ; } param data returns see pack public unpack ( packed ) { const decoded = this . encoder . decode ( packed ) ; const decompressed = this . compressor . decompress ( decoded ) ; const deserialized = this . serializer . deserialize ( decompressed ) ; return deserialized ; } } /**
 * bundles the component objects of a Packer
 */ export interface Options { compressor : Compressor . Compressor ; encoder : Encoder . Encoder ; serializer : Serializer . Serializer ; }