You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
706 B
JavaScript
22 lines
706 B
JavaScript
"use strict";
|
|
|
|
const rules = require("./rules");
|
|
|
|
module.exports = {
|
|
type: function (oldType, newType) {
|
|
return {
|
|
forward: rules.types[oldType].losslessConversionTo[newType],
|
|
backward: rules.types[newType].losslessConversionTo[oldType],
|
|
};
|
|
},
|
|
attribute: function (attribute, oldValue, newValue) {
|
|
let canTransformForward = rules.attributes[attribute].isLossless(oldValue, newValue);
|
|
let canTransformBackward = rules.attributes[attribute].isLossless(newValue, oldValue);
|
|
|
|
return {
|
|
forward: (canTransformForward) ? rules.attributes[attribute].losslessTransformer : undefined,
|
|
backward: (canTransformBackward) ? rules.attributes[attribute].losslessTransformer : undefined,
|
|
};
|
|
}
|
|
};
|