import * as JsYaml from "js-yaml" ; /**
 * encapsulates serialization of arbitrary data into binary formats
 */ export interface Serializer { serialize ( data ) : Buffer ; deserialize ( data ) : any ; } returns export const createJsonSerializer = ( ) : Serializer => ( { serialize : ( data ) : Buffer => Buffer . from ( JSON . stringify ( data ) , "utf8" ) , deserialize : ( data ) : any => JSON . parse ( data . toString ( "utf8" ) ) , } ) ; returns export const createYamlSerializer = ( ) : Serializer => ( { serialize : ( data ) : Buffer => Buffer . from ( JsYaml . safeDump ( data ) , "utf8" ) , deserialize : ( data ) : any => JsYaml . safeLoad ( data . toString ( "utf8" ) ) , } ) ;