src/serializers/index.js
function resolve(opt) {
	if (opt instanceof Serializers.Base) {
		return opt;
	} else if (_.isString(opt)) {
		let SerializerClass = getByName(opt);
		if (SerializerClass)
			return new SerializerClass();
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt}'.`, { type: opt });

	} else if (_.isObject(opt)) {
		let SerializerClass = getByName(opt.type || "JSON");
		if (SerializerClass)
			return new SerializerClass(opt.options);
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt.type}'.`, { type: opt.type });
	}

	return new Serializers.JSON();
}
function resolve(opt) {
	if (opt instanceof Serializers.Base) {
		return opt;
	} else if (_.isString(opt)) {
		let SerializerClass = getByName(opt);
		if (SerializerClass)
			return new SerializerClass();
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt}'.`, { type: opt });

	} else if (_.isObject(opt)) {
		let SerializerClass = getByName(opt.type || "JSON");
		if (SerializerClass)
			return new SerializerClass(opt.options);
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt.type}'.`, { type: opt.type });
	}

	return new Serializers.JSON();
}
function resolve ( opt ) { if ( opt instanceof Serializers . Base ) { return opt ; } else if ( _ . isString ( opt ) ) { let SerializerClass = getByName ( opt ) ; if ( SerializerClass ) return new SerializerClass ( ) ; else throw new BrokerOptionsError ( ` ${ opt } ` , { type : opt } ) ; } else if ( _ . isObject ( opt ) ) { let SerializerClass = getByName ( opt . type || "JSON" ) ; if ( SerializerClass ) return new SerializerClass ( opt . options ) ; else throw new BrokerOptionsError ( ` ${ opt . type } ` , { type : opt . type } ) ; } return new Serializers . JSON ( ) ; }
Resolve serializer by name

@param {object|string} opt
@returns {Serializer}
@memberof ServiceBroker
Resolve serializer by name