Converter.js
/**
* @copyright 2020 Tridium, Inc. All Rights Reserved.
* @author Cody Short
*/
/**
* API Status: **Development**
* @module nmodule/converters/rc/Converter
*/
define([
'baja!', 'Promise' ], function (
baja, Promise) {
"use strict";
/**
* A base class for converters to extend from and override.
*
* @abstract
* @alias module:nmodule/converters/rc/Converter
* @extends baja.Struct
*/
class Converter extends baja.Struct {
/**
* Gives the converter an opportunity to initialize itself based upon from
* and to types.
*
* @param {baja.Object} from
* @param {baja.Object} to
* @returns {Promise|*}
*/
init(from, to) {
return Promise.resolve();
}
/**
* Convert the first object to the second object's type.
*
* @abstract
* @param {baja.Object} from
* @param {baja.Object} to
* @param {Object} cx
* @returns {baja.Object|Promise<baja.Object>|*}
*/
convert(from, to, cx) {
throw new Error("Not implemented");
}
}
return Converter;
});